diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index f398469..074cb8d 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -24,8 +24,9 @@ This is intentional. For a private repository, server-side `git clone` adds unne ### Production - same deployment mechanism -- different server +- usually a different server - env file on server: `.env.prod` +- branch: `main` - should run behind real HTTPS - should keep `DEBUG=0` @@ -198,6 +199,44 @@ HEALTH_URL=http://192.168.2.55:8088/healthz/ \ ./scripts/deploy_test_from_mac.sh ``` +## Manual production deployment +For production, use a dedicated helper instead of the test script. + +### One-command production deployment from your Mac +Use: +```bash +./scripts/deploy_prod_from_mac.sh +``` + +What it does: +1. requires the current branch to be `main` +2. fast-forwards from `origin/main` +3. verifies that the server env file exists before syncing +4. syncs the repo to the production path via `rsync` +5. runs the remote deployment script with `RUN_DJANGO_CHECK=1` +6. verifies the production health endpoint +7. prints the deployed commit and branch + +Important: +- the production helper preserves server-local env files: + - `.env.test` + - `.env.prod` +- do not use the test helper for production + +Default assumptions: +- target host: `root@192.168.2.55` +- target path: `/opt/workdock` +- env file: `.env.prod` +- health URL: `https://workdock.bostame.de/healthz/` + +Optional overrides: +```bash +DEPLOY_HOST=root@192.168.2.55 \ +DEPLOY_PATH=/opt/workdock \ +HEALTH_URL=https://workdock.bostame.de/healthz/ \ +./scripts/deploy_prod_from_mac.sh +``` + ### Manual server-side deploy only If the latest code is already on the server: ```bash @@ -208,7 +247,7 @@ RUN_DJANGO_CHECK=0 DEPLOY_HEALTH_URL="http://127.0.0.1:8088/healthz/" ./scripts/ Manual production deployment: ```bash cd /opt/workdock -RUN_DJANGO_CHECK=1 ./scripts/deploy_stack.sh .env.prod docker-compose.prod.yml +RUN_DJANGO_CHECK=1 DEPLOY_HEALTH_URL="https://workdock.bostame.de/healthz/" ./scripts/deploy_stack.sh .env.prod docker-compose.prod.yml ``` ## Runtime config sync diff --git a/backend/workflows/templates/workflows/developer_handbook.html b/backend/workflows/templates/workflows/developer_handbook.html index f4b64ef..7ce2bb6 100644 --- a/backend/workflows/templates/workflows/developer_handbook.html +++ b/backend/workflows/templates/workflows/developer_handbook.html @@ -362,6 +362,7 @@ make backup-verify BACKUP_DIR=backups/backup_YYYYmmdd_HHMMSS
main.main and a separate helper.develop into main.main.From the Mac, only after the change has been promoted into main:
git checkout main
+./scripts/deploy_prod_from_mac.sh
+ This helper script does all of the following:
+mainorigin/main/opt/workdock with rsync.env.test and .env.prodRUN_DJANGO_CHECK=1The preferred 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, 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.
The helper scripts explicitly preserve server-local env files such as .env.test and .env.prod so deployment does not wipe machine-specific secrets.
Use the production helper only from main:
git checkout main
+./scripts/deploy_prod_from_mac.sh
+ This script fast-forwards main, checks that .env.prod exists on the target server, syncs the repo, runs the production deployment with RUN_DJANGO_CHECK=1, verifies https://workdock.bostame.de/healthz/, and prints the deployed commit hash.
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
+ cd /opt/workdock
+RUN_DJANGO_CHECK=1 DEPLOY_HEALTH_URL="https://workdock.bostame.de/healthz/" ./scripts/deploy_stack.sh .env.prod docker-compose.prod.yml
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"
@@ -566,11 +593,19 @@ docker compose restart worker
./scripts/deploy_test_from_mac.sh
Sync the current develop checkout to the LAN test server and deploy it.
./scripts/deploy_prod_from_mac.sh
+ Sync the current main checkout to the production target and deploy it with production checks enabled.
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
Deploy when code is already present on the server.
+cd /opt/workdock
+RUN_DJANGO_CHECK=1 DEPLOY_HEALTH_URL="https://workdock.bostame.de/healthz/" ./scripts/deploy_stack.sh .env.prod docker-compose.prod.yml
+ Production deploy when code is already present on the server.