migrate website to Poetry and simplify arch.#751
Merged
DavidCruciani merged 1 commit intoMISP:mainfrom Dec 11, 2025
Merged
Conversation
Consolidates the `website/` app around Poetry, a single `main.py` entrypoint, and `.env`-based configuration. Adds systemd service templates and log rotation. BREAKING CHANGE: configuration moved from `conf/config.py` and `config.cfg*` to `.env`. Dependency management - Replace `requirements.txt` with `pyproject.toml` and Poetry; add `poetry.lock`. - Define CLI commands via `main.py`: `--dev`, `--db-init`, `--db-migrate`, `--db-upgrade`, `--db-downgrade`. Application architecture - Consolidate `app_creation.py`, `launch.py`, and `migrate.py` into a single `website/main.py`. - Provide a module-level WSGI app (`main:app`) so Gunicorn can run the site. - Keep Flask DB operations available via CLI; initialization performed in `--db-init`. Configuration - Load settings from `.env` in `app/__init__.py` (e.g., `DATABASE_URI`, `SECRET_KEY`, `FLASK_URL`, `FLASK_PORT`, `MISP_MODULE`, `SESSION_*`). - Remove `FLASK_ENV`; development is explicit via `--dev`. Utilities - Refactor `app/utils/utils.py` to cache env vars (`MISP_MODULE`, `QUERIES_LIMIT`, `ADMIN_PASSWORD`). - Replace `ADMIN_USER` with `ADMIN_PASSWORD` presence; in dev, auto-generate if missing; in prod, warn if absent. - Remove file-based storage (`admin_password.txt`, `config.cfg`). Linting and formatting - Add `website/.flake8` and configure flake8. - Configure Black and isort in `website/pyproject.toml` (style, line length, import sorting). - `.gitignore` updated in `website/` for virtualenv/Poetry and local files. System integration - Add systemd service templates: `etc/systemd/system/misp-modules.service`, `etc/systemd/system/misp-modules-website.service`. - Run website with Gunicorn using `"main:app"`; use `.env` for bind URL/port; stdout/stderr captured to logs. - Add logrotate configs for service logs. Removed files - `website/app_creation.py`, `website/launch.py`, `website/migrate.py`. - `website/conf/config.py`, `website/conf/config.cfg*`. - `website/requirements.txt`. Notes - Assumes `misp-modules` is Poetry-managed in the parent directory for `--dev`. - Set `ADMIN_PASSWORD` in `.env` for production to enable admin features. - Service and logrotate files are templates; adjust paths/users for deployment.
Contributor
|
I had some troubles to run the app with poetry andthe new main.py so I made changes that I'll push just after merging this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consolidates the
website/app around Poetry, a singlemain.pyentrypoint, and.env-based configuration. Adds systemd service templates and log rotation.BREAKING CHANGE: configuration moved from
conf/config.pyandconfig.cfg*to.env.Dependency management
requirements.txtwithpyproject.tomland Poetry; addpoetry.lock.main.py:--dev,--db-init,--db-migrate,--db-upgrade,--db-downgrade.Application architecture
app_creation.py,launch.py, andmigrate.pyinto a singlewebsite/main.py.main:app) so Gunicorn can run the site.--db-init.Configuration
.envinapp/__init__.py(e.g.,DATABASE_URI,SECRET_KEY,FLASK_URL,FLASK_PORT,MISP_MODULE,SESSION_*).FLASK_ENV; development is explicit via--dev.Utilities
app/utils/utils.pyto cache env vars (MISP_MODULE,QUERIES_LIMIT,ADMIN_PASSWORD).ADMIN_USERwithADMIN_PASSWORDpresence; in dev, auto-generate if missing; in prod, warn if absent.admin_password.txt,config.cfg).Linting and formatting
website/.flake8and configure flake8.website/pyproject.toml(style, line length, import sorting)..gitignoreupdated inwebsite/for virtualenv/Poetry and local files.System integration
etc/systemd/system/misp-modules.service,etc/systemd/system/misp-modules-website.service."main:app"; use.envfor bind URL/port; stdout/stderr captured to logs.Removed files
website/app_creation.py,website/launch.py,website/migrate.py.website/conf/config.py,website/conf/config.cfg*.website/requirements.txt.Notes
misp-modulesis Poetry-managed in the parent directory for--dev.ADMIN_PASSWORDin.envfor production to enable admin features.