- Backend Dockerfile: Python 3.12, non-root user, healthcheck - Frontend Dockerfile: Multi-stage build, production stage - docker-compose.yml: env_file, healthchecks, restart policies - docker-compose.prod.yml: Production config with nginx - .env.example: Updated with all variables Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
78 lines
1.6 KiB
YAML
78 lines
1.6 KiB
YAML
# Production Docker Compose
|
|
# Usage: docker-compose -f docker-compose.prod.yml up -d
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
container_name: galaxy-po-db
|
|
environment:
|
|
POSTGRES_USER: ${DB_USER}
|
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
|
POSTGRES_DB: ${DB_NAME}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: always
|
|
networks:
|
|
- galaxy-net
|
|
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: galaxy-po-backend
|
|
env_file:
|
|
- .env.prod
|
|
environment:
|
|
DATABASE_URL: postgresql://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}
|
|
PYTHONPATH: /app
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
restart: always
|
|
networks:
|
|
- galaxy-net
|
|
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
target: production
|
|
container_name: galaxy-po-frontend
|
|
environment:
|
|
NEXT_PUBLIC_API_URL: ${API_URL}
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
restart: always
|
|
networks:
|
|
- galaxy-net
|
|
|
|
nginx:
|
|
image: nginx:alpine
|
|
container_name: galaxy-po-nginx
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./certs:/etc/nginx/certs:ro
|
|
depends_on:
|
|
- frontend
|
|
- backend
|
|
restart: always
|
|
networks:
|
|
- galaxy-net
|
|
|
|
volumes:
|
|
postgres_data:
|
|
driver: local
|
|
|
|
networks:
|
|
galaxy-net:
|
|
driver: bridge
|