Production
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
# Single-VPS production deployment. No Kubernetes, no microservices, no message broker —
|
||||
# none of it is needed for one company and a handful of MRs, and every piece of
|
||||
# infrastructure added here is a piece somebody has to operate at 2am.
|
||||
#
|
||||
# Only Caddy publishes ports. The database and the API are reachable solely on the
|
||||
# internal compose network. For local development add the dev overlay:
|
||||
# docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d db
|
||||
|
||||
x-logging: &default-logging
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "5"
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-pharma}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-pharma}
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
logging: *default-logging
|
||||
|
||||
api:
|
||||
build: .
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-pharma}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-pharma}
|
||||
SECRET_KEY: ${SECRET_KEY:?set SECRET_KEY in .env (64+ random characters)}
|
||||
ENVIRONMENT: ${ENVIRONMENT:-production}
|
||||
CORS_ORIGINS: ${CORS_ORIGINS:-["https://celtic.upskalor.com","https://www.celtic.upskalor.com","http://localhost:5173","http://localhost:3000"]}
|
||||
PDF_STORAGE_PATH: /srv/storage/pdf
|
||||
BACKDATING_WINDOW_DAYS: ${BACKDATING_WINDOW_DAYS:-7}
|
||||
SUBMISSION_DEADLINE_DAYS: ${SUBMISSION_DEADLINE_DAYS:-1}
|
||||
WEB_CONCURRENCY: ${WEB_CONCURRENCY:-2}
|
||||
volumes:
|
||||
- pdfstore:/srv/storage/pdf
|
||||
# Immutable container: the only writable places are the PDF volume and tmpfs.
|
||||
read_only: true
|
||||
tmpfs:
|
||||
- /tmp
|
||||
- /home/appuser/.cache
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
cap_drop:
|
||||
- ALL
|
||||
restart: unless-stopped
|
||||
logging: *default-logging
|
||||
|
||||
# Responsive React web application. It is static after its production build;
|
||||
# Caddy below provides the public TLS endpoint.
|
||||
web:
|
||||
build: ./web
|
||||
restart: unless-stopped
|
||||
logging: *default-logging
|
||||
|
||||
# Automatic HTTPS via Let's Encrypt — two lines of config, auto-renewal,
|
||||
# no certbot cron job to forget about.
|
||||
caddy:
|
||||
image: caddy:2-alpine
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
web:
|
||||
condition: service_started
|
||||
ports:
|
||||
- "${HTTP_PORT:-80}:80"
|
||||
- "${HTTPS_PORT:-443}:443"
|
||||
environment:
|
||||
DOMAIN: ${DOMAIN:-localhost}
|
||||
volumes:
|
||||
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
||||
- caddydata:/data
|
||||
- caddyconfig:/config
|
||||
restart: unless-stopped
|
||||
logging: *default-logging
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
pdfstore:
|
||||
caddydata:
|
||||
caddyconfig:
|
||||
Reference in New Issue
Block a user