Files
appointment-booking-software/docker-compose.prod.yml
T

120 lines
2.8 KiB
YAML

services:
postgres:
image: postgres:16-alpine
container_name: appointment-booking-postgres
restart: unless-stopped
user: postgres
environment:
POSTGRES_DB_FILE: /run/secrets/postgres_db
POSTGRES_USER_FILE: /run/secrets/postgres_user
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256 --auth-local=scram-sha-256"
secrets:
- postgres_db
- postgres_user
- postgres_password
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init-db:/docker-entrypoint-initdb.d:ro
networks:
- appointment-booking-internal
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$(cat /run/secrets/postgres_user) -d $$(cat /run/secrets/postgres_db)"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
cap_add:
- CHOWN
- DAC_OVERRIDE
- FOWNER
- SETGID
- SETUID
tmpfs:
- /tmp
- /var/run/postgresql
read_only: true
app:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: appointment-booking-app
restart: unless-stopped
user: "1001:1001"
environment:
NODE_ENV: production
POSTGRES_DB_FILE: /run/secrets/postgres_db
POSTGRES_USER_FILE: /run/secrets/postgres_user
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
secrets:
- postgres_db
- postgres_user
- postgres_password
depends_on:
postgres:
condition: service_healthy
networks:
- appointment-booking-internal
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
tmpfs:
- /tmp
read_only: true
caddy:
image: caddy:2-alpine
container_name: appointment-booking-caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
networks:
- appointment-booking-internal
depends_on:
app:
condition: service_healthy
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
cap_add:
- NET_BIND_SERVICE
secrets:
postgres_db:
file: ./secrets/postgres_db.txt
postgres_user:
file: ./secrets/postgres_user.txt
postgres_password:
file: ./secrets/postgres_password.txt
volumes:
postgres_data:
driver: local
caddy_data:
driver: local
caddy_config:
driver: local
networks:
appointment-booking-internal:
driver: bridge
internal: false