mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-06 17:15:38 -08:00
3.1 KiB
Executable File
3.1 KiB
Executable File
NetAlertX Devcontainer Notes
This devcontainer replicates the production container as closely as practical, with a few development-oriented differences.
Key behavior
- No init process: Services are managed by shell scripts using killall, setsid, and nohup. Startup and restarts are script-driven rather than supervised by an init system.
- Autogenerated Dockerfile: The effective devcontainer Dockerfile is generated on demand by
.devcontainer/scripts/generate-dockerfile.sh. It combines the rootDockerfile(with certain COPY instructions removed) and an extra "devcontainer" stage from.devcontainer/resources/devcontainer-Dockerfile. When you change the resource Dockerfile, re-run the generator to refresh.devcontainer/Dockerfile. - Where to put setup: Prefer baking setup into
.devcontainer/resources/devcontainer-Dockerfile. Use.devcontainer/scripts/setup.shonly for steps that must happen at container start (e.g., cleaning up nginx/php ownership, creating directories, touching runtime files) or depend on runtime paths.
Debugging (F5) The Frontend and backend run in debug mode always. You can attach your debugger at any time.
- Python Backend Debug: Attach - The backend runs with a debugger on port 5678. Set breakpoints in the code and press F5 to begin triggering them.
- PHP Frontend (XDebug) Xdebug listens on 9003. Start listening and use an Xdebug extension in your browser to debug PHP.
Common workflows (F1->Tasks: Run Task)
- Regenerate the devcontainer Dockerfile: Run the VS Code task "Generate Dockerfile" or execute
.devcontainer/scripts/generate-dockerfile.sh. The result is.devcontainer/Dockerfile. - Re-run startup provisioning: Use the task "Re-Run Startup Script" to execute
.devcontainer/scripts/setup.shin the container. - Start services:
- Backend (GraphQL/Flask):
.devcontainer/scripts/restart-backend.shstarts it under debugpy and logs to/app/log/app.log - Frontend (nginx + PHP-FPM): Started via setup.sh; can be restarted by the task "Start Frontend (nginx and PHP-FPM)".
- Backend (GraphQL/Flask):
Production Container Evaulation
- F1 → Tasks: Shutdown services ([Dev Container] Stop Frontend & Backend Services)
- F1 → Tasks: Docker system and build prune ([Any] Docker system and build Prune)
- F1 → Remote: Close Unused Forwarded Ports (VS Code command)
- F1 → Tasks: Build & Launch Production (Build & Launch Prodcution Docker
- visit http://localhost:20211
Unit tests
- F1 → Tasks: Rebuild test container ([Any] Build Unit Test Docker image)
- F1 → Test: Run all tests
Testing
- pytest is installed via Alpine packages (py3-pytest, py3-pytest-cov).
- PYTHONPATH includes workspace and venv site-packages so tests can import
server/*modules and third-party libs. - Run tests via VS Code Pytest Runner or
pytest -qfrom the workspace root.
Conventions
- Don’t edit
.devcontainer/Dockerfiledirectly; edit.devcontainer/resources/devcontainer-Dockerfileand regenerate. - Keep setup in the resource Dockerfile when possible; reserve
setup.shfor runtime fixes. - Avoid hardcoding ports/secrets; prefer existing settings and helpers (see
.github/copilot-instructions.md).