Skip to content

fix(deploy): make deployment portable across servers - #61

Closed
ArnavBallinCode wants to merge 1 commit into
devfrom
deploy/portable-config
Closed

ArnavBallinCode wants to merge 1 commit into
devfrom
deploy/portable-config

Conversation

@ArnavBallinCode

Copy link
Copy Markdown
Owner

Why

Production is moving from AWS to an Azure VM that already runs another app. That app uses host port 8000 and may get its own Caddy site. The deploy workflow assumes it owns the whole server, so pointing it at the new host would fail the health check or route voxbento.com to the other app. This PR removes those assumptions. It changes nothing on the current server beyond a one-time Caddy layout move (details below).

Changes

  • Deploy directory: $HOME/voxbento, overridable with VOXBENTO_DIR, instead of the hardcoded /home/ubuntu/voxbento. This is the same path on the current server.
  • PORTAL_HOST_PORT (default 8000) sets the portal's host port in docker-compose.yml, the deploy health check and the Caddy upstream. Containers still use portal:8000. A non-numeric value stops the deploy before it builds anything.
  • MediaMTX public host: MTX_WEBRTCADDITIONALHOSTS is built from MEDIAMTX_PUBLIC_HOSTS, falling back to JVB_ADVERTISE_IPS. The server IP is no longer hardcoded in mediamtx.yml. Production already sets JVB_ADVERTISE_IPS to its public IP, so its candidates stay the same, except that the voxbento.com hostname candidate is dropped. That name resolves to Cloudflare, so the candidate couldn't carry media anyway.
  • Caddy layout: the repo Caddyfile now holds only VoxBento's sites. Deploys install it as /etc/caddy/sites/voxbento.caddy, and the main /etc/caddy/Caddyfile contains import /etc/caddy/sites/*.caddy.
    • If the main file is the old VoxBento one, the first deploy saves it as Caddyfile.before-sites and replaces it with the import line.
    • If the main file was written by someone else, the deploy stops and says which line to add.
    • The whole host config is validated before Caddy reloads. If it's invalid, the previous files are restored.
  • Host-local Compose overrides: files listed in COMPOSE_FILE but not tracked in Git are copied into the candidate worktree. Before this, compose config failed for them.
  • Image pruning: docker image prune is limited to images labelled com.docker.compose.project=voxbento, so images belonging to other apps on the host are kept.
  • Updated .env.example, the Caddyfile header and website/docs/configuration/deployment.mdx.

First deploy on the current server

No .env changes are needed: PORTAL_HOST_PORT defaults to 8000 and JVB_ADVERTISE_IPS is already set. The main Caddyfile there starts with the expected header, so it is moved to the new layout once, with a backup kept as /etc/caddy/Caddyfile.before-sites. Sentinel's snippet under /etc/caddy/voxbento-routes/ is still imported inside the voxbento.com site.

Testing

  • tests/test_deploy_workflow.py: the existing tests were updated, and new ones cover the custom host port (health check and rendered Caddy upstream), an invalid port, host-local overrides, the old-layout migration, a main file VoxBento didn't write, restoring files after a failed host validation, and the MediaMTX env wiring. 16 passed.
  • tests/test_config.py, tests/test_program_ingest_media.py and tests/test_proxy_trust.py (the other tests that read these files) pass: 42 passed, 1 skipped in total.
  • docker compose config was checked with no variables set, with only JVB_ADVERTISE_IPS, and with MEDIAMTX_PUBLIC_HOSTS plus PORTAL_HOST_PORT=8001.
  • The full test suite was not run locally: it runs serially here and was stopped at the 30-minute limit. CI covers it.

Created with Claude Opus 5.5 in Claude Code, run from T3 Code.

Production is moving to a server shared with another app. Remove the
assumptions that tie deploys to the current host:

- Deploy from $HOME/voxbento (VOXBENTO_DIR overrides) instead of
  /home/ubuntu/voxbento.
- PORTAL_HOST_PORT (default 8000) sets the portal's host port, the deploy
  health check and the Caddy upstream.
- MediaMTX WebRTC host candidates come from MEDIAMTX_PUBLIC_HOSTS,
  defaulting to JVB_ADVERTISE_IPS, instead of an IP in mediamtx.yml.
- The repo Caddyfile is installed as /etc/caddy/sites/voxbento.caddy,
  imported by the host's main Caddyfile, so other apps keep their sites.
  The first deploy migrates the old layout once, the whole host config is
  validated before reload, and files are restored if it is invalid.
- Untracked Compose overrides listed in COMPOSE_FILE reach the candidate
  worktree.
- Image pruning is limited to the voxbento Compose project.
@ArnavBallinCode

Copy link
Copy Markdown
Owner Author

Opened upstream instead: fossasia#1347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant