diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6f6fce1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,119 @@ +# Contributing Guide + +## Purpose +This repository is the standalone productized Workdock platform. + +Use this file as the quick-start guide for future coders. It complements: +- `DEPLOYMENT.md` +- `backend/workflows/templates/workflows/project_wiki.html` +- `backend/workflows/templates/workflows/developer_handbook.html` + +If you change architecture, deployment flow, or operational behavior, update the relevant documentation in the same branch. + +## Branch Policy +- `develop`: active integration branch +- `main`: stable branch for production promotion +- short-lived feature branches: branch from `develop`, merge back into `develop` + +Do not use `main` as the default development branch. + +## Current Delivery Model +- GitHub Actions is used for CI +- the current test server is local/LAN-only +- deployment to the test server is manual from a LAN-connected machine + +Standard test deployment command: + +```bash +./scripts/deploy_test_from_mac.sh +``` + +Why: +- GitHub-hosted runners cannot reliably reach the private LAN target at `192.168.2.55` + +## Architecture Summary +Main stack: +- Django +- Celery +- PostgreSQL +- Redis +- Caddy + +Important repository areas: +- `backend/config/`: Django configuration +- `backend/workflows/`: application code +- `backend/workflows/templates/workflows/`: templates and in-app documentation +- `backend/workflows/static/workflows/`: CSS and JS +- `backend/media/templates/`: PDF HTML templates + +Current backend modularization: +- `views.py`: thin route wrapper layer +- split view modules: + - `request_views.py` + - `account_views.py` + - `admin_config_views.py` + - `form_builder_views.py` + - `observability_views.py` + - `integration_admin_views.py` + - `welcome_email_views.py` + - `intro_builder_views.py` +- `tasks.py`: async task entrypoints/orchestration +- `pdf_rendering.py` and `pdf_sections.py`: PDF rendering +- `email_workflows.py` and `notification_dispatch.py`: mail/notification orchestration +- `models.py`: stable import facade over split model modules + +## Engineering Rules +1. Preserve runtime behavior while refactoring. +2. Prefer shared UI/system primitives over page-local one-off patterns. +3. Do not silently overwrite environment-specific configuration data. +4. Treat database-backed admin configuration as runtime state, not seed data. +5. Update docs when workflow or architecture changes. + +## Code vs Data +Not all visible behavior comes from code. + +Code-driven: +- page layout +- permissions +- routing +- task behavior +- deploy scripts + +Database-driven: +- app registry order and visibility +- branding and company config +- builder settings +- intro checklist items +- notification templates and rules + +If local UI and server UI differ, check the database-backed config before assuming a code drift. + +## Testing Rules +Minimum validation after non-trivial changes: + +```bash +docker compose exec -T web python manage.py check +docker compose exec -T web python manage.py test +``` + +Also verify specifically when changing: +- PDFs +- deployment/config +- templates/UI + +## Documentation Rules +Keep these current: +- `DEPLOYMENT.md` +- `PRODUCTIZATION_ROADMAP.md` +- `backend/workflows/templates/workflows/project_wiki.html` +- `backend/workflows/templates/workflows/developer_handbook.html` + +## Recommended Change Flow +1. Start from `develop` +2. Implement the change +3. Validate locally +4. Update docs if needed +5. Push to GitHub +6. Let CI run +7. Deploy from the Mac if runtime verification is needed +8. Promote `develop` to `main` when stable diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 2af6f36..4d45bcd 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -172,9 +172,17 @@ Use: What it does: 1. requires the current branch to be `develop` 2. fast-forwards from `origin/develop` -3. syncs the repo to `/opt/workdock` via `rsync` -4. runs the remote deployment script -5. verifies the health endpoint +3. verifies that the server env file exists before syncing +4. syncs the repo to `/opt/workdock` via `rsync` +5. runs the remote deployment script +6. verifies the health endpoint +7. prints the deployed commit and branch + +Important: +- the helper preserves server-local env files: + - `.env.test` + - `.env.prod` +- those files are not supposed to be replaced from your Mac checkout Default assumptions: - target host: `root@192.168.2.55` diff --git a/backend/workflows/templates/workflows/developer_handbook.html b/backend/workflows/templates/workflows/developer_handbook.html index 1ee31f2..01b9dea 100644 --- a/backend/workflows/templates/workflows/developer_handbook.html +++ b/backend/workflows/templates/workflows/developer_handbook.html @@ -23,9 +23,11 @@
workdock-platform (current local path; legacy compose project name may still be retained for runtime continuity)CONTRIBUTING.md/backend/config/: Django settings, WSGI, URL config/backend/workflows/: application logic, views, models, tasks, templates, static assets/backend/workflows/views.py: thin route wrapper layer; most view logic now lives in split modules by domain/backend/workflows/models.py: stable model import surface over split model modules/backend/workflows/tasks.py: async task entrypoints; PDF and notification logic were moved into dedicated modules/backend/workflows/templates/workflows/base_shell.html: standard page shell for new staff-facing pages/backend/workflows/roles.py: centralized role names, capability matrix, and template permission helpersbase_shell.html; do not rebuild topbar/frame logic in page-local templates./.github/workflows/i18n.yml: translation compile validation in CIdevelop is the active integration branch.main is the stable branch intended for production promotion.develop and merge back into develop.developdevelop into main when stablecd /path/to/workdock-platform
docker compose up -d --build
@@ -81,7 +109,7 @@ docker compose up -d --build
user_test / user12345docker compose up -d --build
docker compose restart web
docker compose restart worker
@@ -93,7 +121,7 @@ docker compose down -v
The source code is bind-mounted into the container. Most template/view/static changes only require a web restart, not a full rebuild. Image changes such as system packages require docker compose up -d --build.
- docker compose exec -T web python manage.py makemigrations
docker compose exec -T web python manage.py migrate
docker compose exec -T web python manage.py check
@@ -101,6 +129,7 @@ docker compose exec -T web python manage.py check
entrypoint-web.sh.roles.py, gate the view, and hide the UI affordance when the capability is absent.make i18n-update-en
make i18n-compile
@@ -134,11 +183,12 @@ docker compose exec -T web django-admin compilemessages
preferred_language is normalized in model save() and also has a DB default of de, so alternate creation paths cannot insert null values.xhtml2pdf.templates.pdf, but can now be replaced from Admin Apps → Branding.backend/workflows/tasks.py.backend/workflows/tasks.py.pdf_rendering.py and pdf_sections.py.preferred_language, with German fallback.DEFAULT_NOTIFICATION_TEMPLATES in tasks.py.NotificationTemplate and NotificationRule.preferred_language value.email_workflows.py and notification_dispatch.py.backend/workflows/services.py.PortalBranding.Branding.workflows/app_registry.py.PortalAppConfig./admin-tools/apps/ for Platform Owner.PortalTrialConfig./admin-tools/trial/ for Platform Owner.FormFieldConfig + FormOptionform_builder_config.py.form_builder_runtime.py.form_builder.py is the stable facade import path./admin-tools/backups/ for create, verify, and delete actions. Keep real restore CLI-only.docker compose exec -T web python manage.py check
docker compose exec -T web python manage.py test
docker compose exec -T web python manage.py run_staging_e2e_check
@@ -247,7 +301,7 @@ docker compose exec -T web python manage.py run_staging_e2e_check
submitted, and enqueue the appropriate Celery task again.make backup-create
make backup-verify BACKUP_DIR=backups/backup_YYYYmmdd_HHMMSS
Invalid HTTP_HOST header failure happens before normal page routing, so a broken hostname cannot render a custom error page on that same broken host. Use a working host or IP to access the runbook and fix the env file.develop for the test deployment, main reserved for production..github/workflows/deploy-test.yml..github/workflows/deploy-prod.yml.192.168.2.55. For the current local test server, the correct CD path is manual deployment from a LAN machine or a self-hosted runner inside the same network.development and production.TEST_DEPLOY_HOSTTEST_DEPLOY_USERTEST_DEPLOY_PORTTEST_DEPLOY_PATHTEST_DEPLOY_SSH_KEYPROD_DEPLOY_HOSTPROD_DEPLOY_USERPROD_DEPLOY_PORTPROD_DEPLOY_PATHPROD_DEPLOY_SSH_KEYSettings.Environments in the left sidebar.development.production.development.Environment secrets, add the deployment secrets one by one.production.192.168.2.55root/opt/workdockhttp://192.168.2.55:8088TEST_DEPLOY_HOST=192.168.2.55TEST_DEPLOY_USER=rootTEST_DEPLOY_PORT=22TEST_DEPLOY_PATH=/opt/workdockTEST_DEPLOY_SSH_KEY=<full private key content>Deploy Test on branch develop.http://192.168.2.55:8088/healthz/ returns HTTP 200.DJANGO_DEBUG=1 in .env.test because the security checks correctly reject insecure cookie settings when DEBUG=0 and the deployment is still plain HTTP. This is acceptable for the internal test box only. Production must run with HTTPS and DEBUG=0.
+ develop.main.The test server is inside the local network and uses a private IP address 192.168.2.55. GitHub-hosted runners on the public internet cannot reliably reach that target. Because of that, the correct deployment path today is:
Automatic CD from GitHub becomes appropriate only after moving to a public server or using a self-hosted runner inside the LAN.
+develop.develop into main.From the Mac on the same network:
+git checkout develop
+./scripts/deploy_test_from_mac.sh
+ This helper script does all of the following:
+developorigin/develop/opt/workdock with rsync.env.test and .env.prod192.168.2.55root/opt/workdock.env.testhttp://192.168.2.55:8088/healthz/https://workdock.bostame.de/.github/workflows/deploy-test.yml exists, but GitHub-hosted deploy to the LAN server is not the recommended path right now..github/workflows/deploy-prod.yml exists for later production use./opt/workdock/.env.test still exists on the server.ssh -4 root@192.168.2.55
+ curl -I http://192.168.2.55:8088/healthz/
+ ssh root@192.168.2.55 "cd /opt/workdock && docker compose --env-file .env.test -f docker-compose.prod.yml ps"
+ DJANGO_DEBUG=1 in .env.test because the security checks correctly reject insecure cookie settings when DEBUG=0 and the deployment is still plain HTTP behind a local test topology. This is acceptable for the test box only. Production must run with HTTPS and DEBUG=0.
+ docker-compose.prod.ymlThe preferred current test-deployment path is the local helper script from a Mac or another LAN-connected workstation:
./scripts/deploy_test_from_mac.sh
- This script fast-forwards develop, syncs the repo to the server with rsync, runs the remote deployment, and verifies the health endpoint.
This script fast-forwards develop, checks that the remote env file exists, syncs the repo to the server with rsync, runs the remote deployment, verifies the health endpoint, and prints the deployed commit hash.
The script explicitly preserves server-local env files such as .env.test and .env.prod so deployment does not wipe machine-specific secrets.
Direct server-side deploy is still available if the code is already on the server:
cd /opt/workdock
RUN_DJANGO_CHECK=0 DEPLOY_HEALTH_URL="http://127.0.0.1:8088/healthz/" ./scripts/deploy_stack.sh .env.test docker-compose.prod.yml
@@ -419,7 +499,7 @@ lxc.mount.entry: /dev/null sys/module/apparmor/parameters/enabled none bind 0 0<
web and hard-refresh browserchardet==5.2.0 is installed in the rebuilt image and restart web/workerapp user..env, not in tracked files.{% trans "Engineering documentation for architecture, local setup, Docker, migrations, translations, deployment, testing, and long-term maintenance." %}
+{% trans "Engineering runbook for architecture, branch workflow, deployment, CI/CD, code guidelines, and long-term maintenance." %}