version: '3.8' # Configuration Docker Compose optimisée pour Production # Usage: docker-compose -f docker-compose.prod.yml up -d services: # Base de données PostgreSQL Production regisflow-db: image: postgres:15-alpine container_name: regisflow-db-prod environment: POSTGRES_DB: regisflow POSTGRES_USER: regisflow POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256 --auth-local=scram-sha-256" volumes: - postgres_data_prod:/var/lib/postgresql/data - ./postgresql.conf:/etc/postgresql/postgresql.conf:ro ports: - "5433:5432" restart: unless-stopped deploy: resources: limits: memory: 1G cpus: '1.0' reservations: memory: 512M cpus: '0.5' healthcheck: test: ["CMD-SHELL", "pg_isready -U regisflow -d regisflow"] interval: 30s timeout: 10s retries: 5 start_period: 60s command: postgres -c config_file=/etc/postgresql/postgresql.conf # Application RegisFlow Production regisflow: build: context: . dockerfile: Dockerfile target: production args: - NODE_ENV=production image: regisflow:production container_name: regisflow-app-prod depends_on: regisflow-db: condition: service_healthy pull_policy: never environment: NODE_ENV: production PORT: 5000 DATABASE_URL: postgresql://regisflow:${POSTGRES_PASSWORD}@regisflow-db:5432/regisflow SESSION_SECRET: ${SESSION_SECRET} TZ: ${TZ:-Europe/Paris} SECURE_COOKIES: ${SECURE_COOKIES:-true} DATA_RETENTION_MONTHS: ${DATA_RETENTION_MONTHS:-19} BACKUP_RETENTION_DAYS: ${BACKUP_RETENTION_DAYS:-90} MAX_BACKUP_COUNT: ${MAX_BACKUP_COUNT:-20} NODE_OPTIONS: "--max-old-space-size=1024" volumes: - backup_data_prod:/app/backups - logs_data_prod:/app/logs ports: - "5000:5000" restart: unless-stopped deploy: resources: limits: memory: 1.5G cpus: '2.0' reservations: memory: 512M cpus: '0.5' healthcheck: test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:5000/health || exit 1"] interval: 30s timeout: 15s retries: 3 start_period: 120s logging: driver: "json-file" options: max-size: "100m" max-file: "5" # Volumes persistants pour production volumes: postgres_data_prod: driver: local driver_opts: type: none o: bind device: /opt/regisflow/data/postgres backup_data_prod: driver: local driver_opts: type: none o: bind device: /opt/regisflow/data/backups logs_data_prod: driver: local driver_opts: type: none o: bind device: /opt/regisflow/data/logs # Réseau pour reverse proxy networks: default: name: regisflow-network driver: bridge