81 lines
2.3 KiB
YAML
81 lines
2.3 KiB
YAML
# Production stack for a home server (Phase 13): Postgres, the API server,
|
|
# Caddy serving the web app with /api proxied to the server, and nightly backups.
|
|
# From this folder: docker compose --env-file .env up -d --build
|
|
# Settings come from deploy/.env (copy .env.example).
|
|
name: deadhead
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:18
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-deadhead}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in deploy/.env}
|
|
POSTGRES_DB: ${POSTGRES_DB:-deadhead}
|
|
volumes:
|
|
- postgres-data:/var/lib/postgresql
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 30
|
|
|
|
server:
|
|
build:
|
|
context: ..
|
|
dockerfile: deploy/server.Dockerfile
|
|
restart: unless-stopped
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
environment:
|
|
DATABASE_URL: postgres://${POSTGRES_USER:-deadhead}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-deadhead}
|
|
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:?set BETTER_AUTH_SECRET in deploy/.env}
|
|
BETTER_AUTH_URL: ${PUBLIC_URL:?set PUBLIC_URL in deploy/.env}
|
|
LOG_LEVEL: ${LOG_LEVEL:-info}
|
|
WORKERS_ENABLED: "true"
|
|
|
|
web:
|
|
build:
|
|
context: ..
|
|
dockerfile: deploy/web.Dockerfile
|
|
args:
|
|
APP_BUILD: ${APP_BUILD:-dev}
|
|
restart: unless-stopped
|
|
depends_on:
|
|
server:
|
|
condition: service_healthy
|
|
environment:
|
|
SITE_ADDRESS: ${SITE_ADDRESS:?set SITE_ADDRESS in deploy/.env}
|
|
ports:
|
|
- "${HTTP_PORT:-80}:80"
|
|
- "${HTTPS_PORT:-443}:443"
|
|
- "${HTTPS_PORT:-443}:443/udp"
|
|
volumes:
|
|
- caddy-data:/data
|
|
- caddy-config:/config
|
|
|
|
backup:
|
|
image: postgres:18
|
|
restart: unless-stopped
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
entrypoint: ["/bin/sh", "/scripts/schedule.sh"]
|
|
environment:
|
|
PGHOST: postgres
|
|
PGUSER: ${POSTGRES_USER:-deadhead}
|
|
PGPASSWORD: ${POSTGRES_PASSWORD}
|
|
PGDATABASE: ${POSTGRES_DB:-deadhead}
|
|
BACKUP_HOUR: ${BACKUP_HOUR:-3}
|
|
BACKUP_KEEP_DAYS: ${BACKUP_KEEP_DAYS:-14}
|
|
TZ: ${TZ:-UTC}
|
|
volumes:
|
|
- ./backup:/scripts:ro
|
|
- ${BACKUP_DIR:?set BACKUP_DIR in deploy/.env}:/backups
|
|
|
|
volumes:
|
|
postgres-data:
|
|
caddy-data:
|
|
caddy-config:
|