Files
HabitForge-zepp/docker-compose.prod.yml

75 lines
1.8 KiB
YAML

version: "3.8"
services:
backup:
image: postgres:15-alpine
volumes:
- postgres_data_prod:/var/lib/postgresql/data:ro
- ./backups:/backups
- ./scripts/backup_db.sh:/backup_db.sh:ro
environment:
- POSTGRES_HOST=db
- POSTGRES_PORT=5432
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
env_file:
- .env.production
entrypoint: ["/bin/sh", "-c"]
command: ["chmod +x /backup_db.sh && while true; do /backup_db.sh; sleep 86400; done"]
depends_on:
- db
restart: unless-stopped
web:
build: .
command: gunicorn backend.main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000
volumes:
- ./frontend:/app/frontend:ro
ports:
- "8000:8000"
depends_on:
- db
env_file:
- .env.production
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
db:
image: postgres:15-alpine
volumes:
- postgres_data_prod:/var/lib/postgresql/data
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
env_file:
- .env.production
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
interval: 10s
timeout: 5s
retries: 5
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./frontend:/usr/share/nginx/html:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
depends_on:
- web
restart: unless-stopped
volumes:
postgres_data_prod: