version: '3.8' services: db: image: postgres:15-alpine volumes: - postgres_data:/var/lib/postgresql/data environment: POSTGRES_DB: ${POSTGRES_DB} POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} restart: unless-stopped network_mode: host redis: image: redis:7-alpine volumes: - redis_data:/data restart: unless-stopped network_mode: host app: network_mode: host build: context: . dockerfile: Dockerfile command: /usr/local/bin/gunicorn rbox.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 volumes: - app_data:/app/data # For uploaded files environment: DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB} REDIS_URL: redis://redis:6379/0 SECRET_KEY: ${SECRET_KEY} DOMAIN_NAME: ${DOMAIN_NAME} # Add other environment variables as needed depends_on: - db - redis restart: unless-stopped nginx: image: nginx:stable-alpine ports: - "80:80" - "443:443" volumes: - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf - certbot_certs:/etc/letsencrypt - app_data:/app/data # Serve static files from here depends_on: - app restart: unless-stopped certbot: image: certbot/certbot volumes: - certbot_certs:/etc/letsencrypt - ./certbot/conf:/etc/nginx/conf.d command: certonly --webroot --webroot-path=/var/www/certbot --email ${CERTBOT_EMAIL} --agree-tos --no-eff-email -d ${DOMAIN_NAME} depends_on: - nginx environment: DOMAIN_NAME: ${DOMAIN_NAME} CERTBOT_EMAIL: ${CERTBOT_EMAIL} volumes: postgres_data: redis_data: app_data: certbot_certs: