# Production stack. Dev layers docker-compose.dev.yml on top. # Container names come from the *_HOST variables in .env, which Caddy also # uses for its upstreams, so the two always agree. networks: # Subnet pinned so it cannot collide with the LAN. app-network: driver: bridge ipam: config: - subnet: 172.28.0.0/16 # internal: code submitted to the usaco runner cannot reach the internet # or anything on app-network. usaco-runner-net: driver: bridge internal: true # Named volumes survive `down`; only `down -v` deletes them. volumes: # Deleting this wipes posts, users and messages. dbdata: # Private attachments, plus any upload Garage refused. Caddy serves # /uploads/ from the bucket first, then from here. uploads: # Back up meta and data together: the bytes are unreadable without meta. # A fresh pair needs garage/bootstrap.sh. garage_meta: garage_data: # Written by the one-shot `vue` build container, served by Caddy. vue_dist: # Named only so the image's VOLUME doesn't leave anonymous volumes behind. caddy_config: services: # One-shot build: Exited (0) is the healthy state. vue: build: context: ./vue dockerfile: Dockerfile container_name: vue volumes: - vue_dist:/output networks: - app-network # Explicit environment list so the edge never sees DB or JWT secrets; a # variable the Caddyfile reads must be added here. Defaults live here, not # in the Caddyfile, because Caddy's {$X:default} keeps a set-but-empty value. # No depends_on: Caddy resolves upstreams per dial. caddy: build: context: ./caddy dockerfile: Dockerfile container_name: caddy restart: always environment: - DOMAIN=${DOMAIN} - BACKEND_HOST=${BACKEND_HOST} - BACKEND_PORT=${BACKEND_PORT} - BACKEND_ENDPOINT=${BACKEND_ENDPOINT} - ICECAST_HOST=${ICECAST_HOST} - ICECAST_PORT=${ICECAST_PORT} - GITEA_HOST=${GITEA_HOST} - GITEA_PORT=${GITEA_PORT} - SILVERBULLET_HOST=${SILVERBULLET_HOST:-silverbullet} - SILVERBULLET_PORT=${SILVERBULLET_PORT:-3000} - SILVERBULLET_PUBLIC_HOST=${SILVERBULLET_PUBLIC_HOST:-silverbullet-public} - SILVERBULLET_PUBLIC_PORT=${SILVERBULLET_PUBLIC_PORT:-3000} - PYTHON_HOST=${PYTHON_HOST:-python} - PYTHON_PORT=${PYTHON_PORT:-8000} # A dead port by default, so /receipt/ reads "offline". - RECEIPT_WEB_UPSTREAM=${RECEIPT_WEB_UPSTREAM:-127.0.0.1:9} - RECEIPT_WEB_TOKEN=${RECEIPT_WEB_TOKEN:-} # The adamf/cto stack's web container; "offline" while that stack is down. - RADAR_UPSTREAM=${RADAR_UPSTREAM:-radar-web:80} - CLOUDFLARE_DNS_API_TOKEN=${CLOUDFLARE_DNS_API_TOKEN:-} # Keeps the Gitea hop on the LAN; public DNS points at Cloudflare. extra_hosts: - "${GITEA_HOST}:${GITEA_UPSTREAM}" networks: app-network: # So cloudflared's origin (https://www.DOMAIN) lands here under a name # the certificate covers. aliases: - ${DOMAIN} - www.${DOMAIN} - radar.${DOMAIN} # Matches cloudflared's extra_hosts. ipv4_address: 172.28.255.251 ports: - 80:80 - 443:443 volumes: # Private key material; never commit. - ./caddy/data:/data - caddy_config:/config - uploads:/srv/uploads:ro - vue_dist:/srv/www:ro - ./logs/caddy:/var/log/caddy # restart: always misses a hung server; autoheal restarts on unhealthy. healthcheck: test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1/caddy-health"] interval: 30s timeout: 10s retries: 3 start_period: 30s labels: - autoheal=true # Remotely-managed Cloudflare Tunnel; routes live in the dashboard. # Fixed IP because Caddy trusts CF-Connecting-IP from this address only. cloudflared: image: cloudflare/cloudflared:2026.9.3 container_name: cloudflared restart: always command: ["tunnel", "--no-autoupdate", "run"] environment: - TUNNEL_TOKEN=${CLOUDFLARE_TUNNEL_TOKEN:-} depends_on: - caddy # A stopped Caddy loses its aliases, and public DNS would loop the tunnel # back to Cloudflare (error 1000). Pinning makes it a plain 502 instead. extra_hosts: - "${DOMAIN}:172.28.255.251" - "www.${DOMAIN}:172.28.255.251" - "radar.${DOMAIN}:172.28.255.251" networks: app-network: ipv4_address: 172.28.255.250 backend: build: context: ./backend dockerfile: Dockerfile container_name: "${BACKEND_HOST}" restart: always depends_on: db: condition: service_healthy extra_hosts: - "${GITEA_HOST}:${GITEA_UPSTREAM}" networks: - app-network env_file: - ./.env volumes: # Spotify refresh token; without this every deploy forces a re-auth. - ./backend/token/:/backend/token - ${OBSIDIAN_DIR}:/backend/notes - ./logs:/backend/logs - uploads:/backend/uploads - ./icecast2/fallback_music:/backend/fallback_music # Informational only: autoheal does not watch this container. healthcheck: test: ["CMD", "wget", "-qO-", "http://localhost:8080/"] interval: 30s timeout: 5s retries: 3 start_period: 10s # Holds the app DB plus the job and activity trackers' (created by hand). db: image: postgres:16 container_name: "${POSTGRES_HOST}" restart: always env_file: - ./.env networks: - app-network volumes: - dbdata:/var/lib/postgresql/data # Long start_period for cold first boots. $$ defers expansion to the # container's shell. healthcheck: test: ["CMD-SHELL", "pg_isready -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\" -q"] interval: 10s timeout: 5s retries: 10 start_period: 90s # icecast2 + liquidsoap. The harbor port is a raw live-DJ source input, # so it is published directly rather than proxied. icecast2: build: context: ./icecast2 dockerfile: Dockerfile container_name: "${ICECAST_HOST}" restart: always networks: - app-network env_file: - ./.env volumes: - ./icecast2/fallback_music:/music:ro ports: - "${LIQUIDSOAP_HARBOR_PORT:-8001}:${LIQUIDSOAP_HARBOR_PORT:-8001}" # Vault editor at /sb/ (admin-gated). silverbullet: image: ghcr.io/silverbulletmd/silverbullet:2.11.0 container_name: "${SILVERBULLET_HOST:-silverbullet}" restart: always networks: - app-network environment: SB_PORT: "${SILVERBULLET_PORT:-3000}" # Caddy must not strip /sb/: the app builds its URLs from this. SB_URL_PREFIX: /sb # Newline separated; commas are silently ignored. SB_SPACE_IGNORE: | .obsidian PUID: "1000" PGID: "1000" volumes: - ${OBSIDIAN_DIR}:/data # Public read-only notes at /notes/. private/ stays private only with all # three: SB_SPACE_IGNORE (hides from listings, not direct fetches), Caddy's # /notes/ deny regex (keep its folder list in step), and SB_REVISIONS # disabled (else history is served from the vault's .git). # Keep the image tag in step with the editor. silverbullet-public: image: ghcr.io/silverbulletmd/silverbullet:2.11.0 container_name: "${SILVERBULLET_PUBLIC_HOST:-silverbullet-public}" restart: always networks: - app-network environment: SB_PORT: "${SILVERBULLET_PUBLIC_PORT:-3000}" SB_URL_PREFIX: /notes SB_READ_ONLY: "true" SB_REVISIONS: disabled SB_SPACE_IGNORE: | private/ templates/ .obsidian PUID: "1000" PGID: "1000" volumes: - ${OBSIDIAN_DIR}:/data:ro # Commits/pulls the vault. Separate from SilverBullet so its shell backend # stays off (it would give command execution to anyone past the admin gate). silverbullet-git: image: alpine/git:v2.54.0 container_name: "${SILVERBULLET_GIT_HOST:-silverbullet-git}" restart: always networks: - app-network # Gitea SSH on the LAN; public DNS points at Cloudflare. extra_hosts: - "${GITEA_HOST}:${GITEA_UPSTREAM}" # Match SilverBullet's uid so .git objects stay host-owned. user: "1000:1000" environment: SYNC_INTERVAL: "${SILVERBULLET_GIT_INTERVAL:-300}" GIT_AUTHOR_NAME: silverbullet GIT_AUTHOR_EMAIL: "silverbullet@${DOMAIN}" GIT_COMMITTER_NAME: silverbullet GIT_COMMITTER_EMAIL: "silverbullet@${DOMAIN}" HOME: /tmp GIT_SSH_COMMAND: "ssh -i /ssh/id_ed25519 -o UserKnownHostsFile=/ssh/known_hosts -o IdentitiesOnly=yes" entrypoint: ["/bin/sh", "/git-sync.sh"] volumes: - ${OBSIDIAN_DIR}:/space - ./silverbullet/git-sync.sh:/git-sync.sh:ro - ./silverbullet/ssh:/ssh:ro - ./silverbullet/passwd:/etc/passwd:ro # Mounted at /py/ (prefix stripped). Explicit env list: no DB or other secrets. python: build: context: ./python dockerfile: Dockerfile container_name: "${PYTHON_HOST:-python}" restart: always networks: - app-network environment: - PYTHON_PORT=${PYTHON_PORT:-8000} - ROOT_PATH=/py - TFL_APP_KEY=${TFL_APP_KEY:-} - CLAUDE_API_KEY=${CLAUDE_API_KEY:-} - CLAUDE_MODEL=${CLAUDE_MODEL:-} healthcheck: test: ["CMD", "python", "-c", "import urllib.request,os; urllib.request.urlopen(f\"http://localhost:{os.environ.get('PYTHON_PORT','8000')}/health\")"] interval: 30s timeout: 5s retries: 3 start_period: 10s # Job tracker (adamf/job-tracker). No login of its own: it asks # validate-admin with the visitor's cookies. ./jobs-data must be uid 1000. jobs: image: adam-french.co.uk/adamf/job-tracker:${JOBS_IMAGE_TAG:-latest} container_name: jobs restart: always depends_on: db: condition: service_healthy networks: - app-network environment: - DATABASE_URL=postgres://${POSTGRES_JOBS_USER:-jobs}:${POSTGRES_JOBS_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_JOBS_DB:-jobs}?sslmode=disable - AUTH_VALIDATE_URL=http://${BACKEND_HOST}:${BACKEND_PORT}/auth/validate-admin - CLAUDE_API_KEY=${CLAUDE_API_KEY:-} - CLAUDE_MODEL=${CLAUDE_MODEL:-} - EMAIL_BACKEND=${EMAIL_BACKEND:-} - EMAIL_SYNC_ENABLED=${EMAIL_SYNC_ENABLED:-} - EMAIL_SYNC_INTERVAL=${EMAIL_SYNC_INTERVAL:-} - MSGRAPH_CLIENT_ID=${MSGRAPH_CLIENT_ID:-} - MSGRAPH_CLIENT_SECRET=${MSGRAPH_CLIENT_SECRET:-} - MSGRAPH_TENANT_ID=${MSGRAPH_TENANT_ID:-} - MSGRAPH_REDIRECT_URI=${MSGRAPH_REDIRECT_URI:-} - IMAP_HOST=${IMAP_HOST:-} - IMAP_PORT=${IMAP_PORT:-} - IMAP_EMAIL=${IMAP_EMAIL:-} - IMAP_PASSWORD=${IMAP_PASSWORD:-} - JOB_LEADS_ENABLED=${JOB_LEADS_ENABLED:-} - JOB_LEADS_INTERVAL=${JOB_LEADS_INTERVAL:-} - ADZUNA_APP_ID=${ADZUNA_APP_ID:-} - ADZUNA_APP_KEY=${ADZUNA_APP_KEY:-} - REED_API_KEY=${REED_API_KEY:-} volumes: - ./jobs-data:/data # USACO log (adamf/usaco). Git is its store, cloned into ./usaco-data # (must be uid 1000). The S3_* vars are all-or-nothing, hence the :+ forms. # stop_grace_period must exceed the app's SHUTDOWN_GRACE (5m). usaco: image: adam-french.co.uk/adamf/usaco:${USACO_IMAGE_TAG:-latest} container_name: usaco restart: always stop_grace_period: 6m depends_on: - usaco-runner extra_hosts: - "${GITEA_HOST}:${GITEA_UPSTREAM}" networks: - app-network - usaco-runner-net environment: - GIT_REMOTE_URL=http://${GITEA_HOST}:${GITEA_PORT}/adamf/usaco.git - GIT_TOKEN=${USACO_GIT_TOKEN:-} - WEBHOOK_SECRET=${USACO_WEBHOOK_SECRET:-} - AUTH_VALIDATE_URL=http://${BACKEND_HOST}:${BACKEND_PORT}/auth/validate-admin - CLAUDE_API_KEY=${CLAUDE_API_KEY:-} - CLAUDE_MODEL=${USACO_CLAUDE_MODEL:-} - CLAUDE_MONTHLY_BUDGET=${USACO_CLAUDE_MONTHLY_BUDGET:-} - TRANSCRIBE_API_KEY=${USACO_OPENAI_API_KEY:-} - S3_ACCESS_KEY_ID=${USACO_S3_ACCESS_KEY_ID:-} - S3_SECRET_ACCESS_KEY=${USACO_S3_SECRET_ACCESS_KEY:-} - S3_ENDPOINT=${USACO_S3_ACCESS_KEY_ID:+http://garage:3900} - S3_REGION=${USACO_S3_ACCESS_KEY_ID:+garage} - S3_BUCKET=${USACO_S3_ACCESS_KEY_ID:+usaco-audio} - RUNNER_URL=http://usaco-runner:8081 volumes: - ./usaco-data:/data # Runs submitted code: no secrets, no network but the site's. # tmpfs must allow exec (compiled programs run there). pids_limit is the # fork-bomb guard, since the runner can't use RLIMIT_NPROC. usaco-runner: image: adam-french.co.uk/adamf/usaco-runner:${USACO_RUNNER_IMAGE_TAG:-latest} container_name: usaco-runner restart: always networks: - usaco-runner-net read_only: true tmpfs: - /tmp:size=256m,exec mem_limit: 1g cpus: 2 pids_limit: 128 cap_drop: - ALL security_opt: - no-new-privileges:true # Activity tracker (adamf/ccp), at /tracker/ (prefix stripped). activity-tracker: image: adam-french.co.uk/adamf/activity-tracker:${ACTIVITY_TRACKER_IMAGE_TAG:-latest} container_name: activity-tracker restart: always depends_on: db: condition: service_healthy networks: - app-network environment: - DATABASE_URL=postgres://${POSTGRES_TRACKER_USER:-tracker}:${POSTGRES_TRACKER_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_TRACKER_DB:-tracker}?sslmode=disable - TRACKER_TZ=${TRACKER_TZ:-} - AUTH_VALIDATE_URL=http://${BACKEND_HOST}:${BACKEND_PORT}/auth/validate-admin # Tails Caddy's payload log so Dozzle shows it as its own stream. traffic: image: busybox:1.38.0 container_name: traffic restart: always command: ["tail", "-n0", "-F", "/logs/payloads.log"] network_mode: none volumes: - ./logs/caddy:/logs:ro # The Docker socket is root-equivalent even :ro, so: no published port, # admin gate in front, container actions left off. dozzle: image: amir20/dozzle:v11.2.0 container_name: dozzle restart: always networks: - app-network environment: - DOZZLE_BASE=/dozzle - DOZZLE_NO_ANALYTICS=true volumes: - /var/run/docker.sock:/var/run/docker.sock:ro # Restarts containers labelled autoheal=true when unhealthy. # Root via the socket, so: no network, and pinned by digest. To bump: # `docker buildx imagetools inspect willfarrell/autoheal:`. autoheal: image: willfarrell/autoheal@sha256:31f580ef0279eaced5b38d631b08c474d70d8403c1c2fdd6ddcf2e879d5f3f7c container_name: autoheal restart: always network_mode: none environment: - AUTOHEAL_CONTAINER_LABEL=autoheal volumes: - /var/run/docker.sock:/var/run/docker.sock # Public uploads bucket. Nothing depends on it: Caddy and the backend fall # back to the `uploads` volume. First run: garage/bootstrap.sh. garage: image: dxflrs/garage:v2.5.0 container_name: garage restart: always networks: - app-network environment: - GARAGE_RPC_SECRET=${GARAGE_RPC_SECRET} - GARAGE_ADMIN_TOKEN=${GARAGE_ADMIN_TOKEN} volumes: - ./garage/garage.toml:/etc/garage.toml:ro - garage_meta:/var/lib/garage/meta - garage_data:/var/lib/garage/data healthcheck: test: ["CMD", "/garage", "status"] interval: 30s timeout: 5s retries: 3 start_period: 10s # Admin-gated at /garage/; holds the admin token, so never publish it. # Files uploaded here are public at /uploads/ with no backend checks. garage-webui: image: khairul169/garage-webui:1.1.0 container_name: garage-webui restart: always depends_on: - garage networks: - app-network environment: - BASE_PATH=/garage - API_BASE_URL=http://garage:3903 - API_ADMIN_KEY=${GARAGE_ADMIN_TOKEN} - S3_ENDPOINT_URL=http://garage:3900 - S3_REGION=garage # No /tmp in the image; large multipart uploads spool there. tmpfs: - /tmp volumes: - ./garage/garage.toml:/etc/garage.toml:ro