services: redis: image: redis:7-alpine restart: unless-stopped # appendonly: persist the queue to disk so it survives restarts. # appendfsync everysec: at most 1 second of data loss, balanced against write performance. command: redis-server --appendonly yes --appendfsync everysec volumes: - redis-data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 5 server: build: . command: node dist/server.js restart: unless-stopped env_file: .env environment: PORT: "3000" REDIS_URL: "redis://redis:6379" depends_on: redis: condition: service_healthy # Scale horizontally with: docker compose up --scale worker=N worker: build: . command: node dist/worker.js restart: unless-stopped env_file: .env environment: REDIS_URL: "redis://redis:6379" METRICS_ENABLED: "${METRICS_ENABLED:-false}" METRICS_PORT: "${METRICS_PORT:-9091}" ports: - "${METRICS_PORT:-9091}:${METRICS_PORT:-9091}" depends_on: redis: condition: service_healthy prometheus: image: prom/prometheus:v3.3.0 profiles: [monitoring] restart: unless-stopped volumes: - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus-data:/prometheus command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.retention.time=30d' depends_on: - server - worker grafana: image: grafana/grafana:11.6.0 profiles: [monitoring] restart: unless-stopped environment: GF_AUTH_ANONYMOUS_ENABLED: "true" GF_AUTH_ANONYMOUS_ORG_ROLE: "Viewer" volumes: - ./monitoring/grafana/provisioning:/etc/grafana/provisioning:ro - ./monitoring/grafana/dashboards:/var/lib/grafana/dashboards:ro - grafana-data:/var/lib/grafana ports: - "3001:3000" depends_on: - prometheus nginx: image: nginx:1.27-alpine restart: unless-stopped ports: - "80:80" - "443:443" volumes: - ./nginx/conf.d:/etc/nginx/conf.d:ro - ./data/certbot/www:/var/www/certbot:ro - ./data/certbot/certs:/etc/letsencrypt:ro depends_on: - server # Run via scripts/init-tls.sh for initial issuance, then on a timer for renewals: # docker compose run --rm certbot renew certbot: image: certbot/certbot:latest volumes: - ./data/certbot/www:/var/www/certbot - ./data/certbot/certs:/etc/letsencrypt volumes: redis-data: prometheus-data: grafana-data: