services: postgres: image: postgres:15-alpine container_name: knowfoolery-postgres restart: unless-stopped env_file: - .env.prod environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} ports: - "${POSTGRES_PORT}:5432" volumes: - postgres_data:/var/lib/postgresql/data - ../dev/init-scripts:/docker-entrypoint-initdb.d:ro healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] interval: 10s timeout: 5s retries: 5 networks: - backend redis: image: redis:7-alpine container_name: knowfoolery-redis restart: unless-stopped env_file: - .env.prod ports: - "${REDIS_PORT}:6379" volumes: - redis_data:/data command: redis-server --appendonly yes healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 networks: - backend question-bank-service: build: context: ../.. dockerfile: infrastructure/services/question-bank.Dockerfile container_name: knowfoolery-question-bank-service restart: unless-stopped env_file: - .env.prod environment: QUESTION_BANK_PORT: ${QUESTION_BANK_PORT} POSTGRES_HOST: postgres POSTGRES_DB: questions REDIS_HOST: redis TRACING_ENABLED: ${TRACING_ENABLED} TRACING_OTLP_ENDPOINT: ${TRACING_OTLP_ENDPOINT} TRACING_JAEGER_ENDPOINT: ${TRACING_JAEGER_ENDPOINT} METRICS_ENABLED: ${METRICS_ENABLED} ports: - "${QUESTION_BANK_PORT}:8081" depends_on: postgres: condition: service_healthy redis: condition: service_healthy healthcheck: test: ["CMD-SHELL", "wget -qO- http://localhost:${QUESTION_BANK_PORT}/health || exit 1"] interval: 10s timeout: 3s retries: 10 networks: - backend user-service: build: context: ../.. dockerfile: infrastructure/services/user.Dockerfile container_name: knowfoolery-user-service restart: unless-stopped env_file: - .env.prod environment: USER_SERVICE_PORT: ${USER_SERVICE_PORT} POSTGRES_HOST: postgres POSTGRES_DB: users TRACING_ENABLED: ${TRACING_ENABLED} TRACING_OTLP_ENDPOINT: ${TRACING_OTLP_ENDPOINT} TRACING_JAEGER_ENDPOINT: ${TRACING_JAEGER_ENDPOINT} METRICS_ENABLED: ${METRICS_ENABLED} ports: - "${USER_SERVICE_PORT}:8082" depends_on: postgres: condition: service_healthy healthcheck: test: ["CMD-SHELL", "wget -qO- http://localhost:${USER_SERVICE_PORT}/health || exit 1"] interval: 10s timeout: 3s retries: 10 networks: - backend game-session-service: build: context: ../.. dockerfile: infrastructure/services/game-session.Dockerfile container_name: knowfoolery-game-session-service restart: unless-stopped env_file: - .env.prod environment: GAME_SESSION_PORT: ${GAME_SESSION_PORT} POSTGRES_HOST: postgres POSTGRES_DB: game_sessions REDIS_HOST: redis QUESTION_BANK_BASE_URL: http://question-bank-service:${QUESTION_BANK_PORT} USER_SERVICE_BASE_URL: http://user-service:${USER_SERVICE_PORT} TRACING_ENABLED: ${TRACING_ENABLED} TRACING_OTLP_ENDPOINT: ${TRACING_OTLP_ENDPOINT} TRACING_JAEGER_ENDPOINT: ${TRACING_JAEGER_ENDPOINT} METRICS_ENABLED: ${METRICS_ENABLED} ports: - "${GAME_SESSION_PORT}:8080" depends_on: postgres: condition: service_healthy redis: condition: service_healthy question-bank-service: condition: service_healthy user-service: condition: service_healthy healthcheck: test: ["CMD-SHELL", "wget -qO- http://localhost:${GAME_SESSION_PORT}/health || exit 1"] interval: 10s timeout: 3s retries: 10 networks: - backend leaderboard-service: build: context: ../.. dockerfile: infrastructure/services/leaderboard.Dockerfile container_name: knowfoolery-leaderboard-service restart: unless-stopped env_file: - .env.prod environment: LEADERBOARD_PORT: ${LEADERBOARD_PORT} POSTGRES_HOST: postgres POSTGRES_DB: leaderboards REDIS_HOST: redis TRACING_ENABLED: ${TRACING_ENABLED} TRACING_OTLP_ENDPOINT: ${TRACING_OTLP_ENDPOINT} TRACING_JAEGER_ENDPOINT: ${TRACING_JAEGER_ENDPOINT} METRICS_ENABLED: ${METRICS_ENABLED} ports: - "${LEADERBOARD_PORT}:8083" depends_on: postgres: condition: service_healthy redis: condition: service_healthy healthcheck: test: ["CMD-SHELL", "wget -qO- http://localhost:${LEADERBOARD_PORT}/health || exit 1"] interval: 10s timeout: 3s retries: 10 networks: - backend admin-service: build: context: ../.. dockerfile: infrastructure/services/admin.Dockerfile container_name: knowfoolery-admin-service restart: unless-stopped env_file: - .env.prod environment: ADMIN_SERVICE_PORT: ${ADMIN_SERVICE_PORT} POSTGRES_HOST: postgres POSTGRES_DB: admin TRACING_ENABLED: ${TRACING_ENABLED} TRACING_OTLP_ENDPOINT: ${TRACING_OTLP_ENDPOINT} TRACING_JAEGER_ENDPOINT: ${TRACING_JAEGER_ENDPOINT} METRICS_ENABLED: ${METRICS_ENABLED} ports: - "${ADMIN_SERVICE_PORT}:8085" depends_on: postgres: condition: service_healthy healthcheck: test: ["CMD-SHELL", "wget -qO- http://localhost:${ADMIN_SERVICE_PORT}/health || exit 1"] interval: 10s timeout: 3s retries: 10 networks: - backend gateway-service: build: context: ../.. dockerfile: infrastructure/services/gateway.Dockerfile container_name: knowfoolery-gateway-service restart: unless-stopped env_file: - .env.prod environment: GATEWAY_INTERNAL_PORT: ${GATEWAY_INTERNAL_PORT} REDIS_HOST: redis GAME_SESSION_BASE_URL: http://game-session-service:${GAME_SESSION_PORT} QUESTION_BANK_BASE_URL: http://question-bank-service:${QUESTION_BANK_PORT} USER_SERVICE_BASE_URL: http://user-service:${USER_SERVICE_PORT} LEADERBOARD_BASE_URL: http://leaderboard-service:${LEADERBOARD_PORT} ADMIN_SERVICE_BASE_URL: http://admin-service:${ADMIN_SERVICE_PORT} TRACING_ENABLED: ${TRACING_ENABLED} TRACING_OTLP_ENDPOINT: ${TRACING_OTLP_ENDPOINT} TRACING_JAEGER_ENDPOINT: ${TRACING_JAEGER_ENDPOINT} METRICS_ENABLED: ${METRICS_ENABLED} ports: - "${GATEWAY_INTERNAL_PORT}:${GATEWAY_INTERNAL_PORT}" depends_on: redis: condition: service_healthy game-session-service: condition: service_healthy question-bank-service: condition: service_healthy user-service: condition: service_healthy leaderboard-service: condition: service_healthy admin-service: condition: service_healthy healthcheck: test: ["CMD-SHELL", "wget -qO- http://localhost:${GATEWAY_INTERNAL_PORT}/health || exit 1"] interval: 10s timeout: 3s retries: 10 networks: - backend nginx: image: nginx:1.27-alpine container_name: knowfoolery-nginx restart: unless-stopped ports: - "${GATEWAY_PORT}:8086" volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf:ro depends_on: gateway-service: condition: service_healthy networks: - public - backend prometheus: image: prom/prometheus:latest container_name: knowfoolery-prometheus restart: unless-stopped env_file: - .env.prod ports: - "${PROMETHEUS_PORT}:9090" volumes: - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus_data:/prometheus command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--web.enable-lifecycle' depends_on: gateway-service: condition: service_healthy networks: - backend grafana: image: grafana/grafana:latest container_name: knowfoolery-grafana restart: unless-stopped env_file: - .env.prod ports: - "${GRAFANA_PORT}:3000" environment: GF_SECURITY_ADMIN_USER: ${GRAFANA_ADMIN_USER} GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD} GF_USERS_ALLOW_SIGN_UP: false volumes: - grafana_data:/var/lib/grafana depends_on: prometheus: condition: service_started networks: - backend jaeger: image: jaegertracing/all-in-one:latest container_name: knowfoolery-jaeger restart: unless-stopped ports: - "${JAEGER_UI_PORT}:16686" - "${JAEGER_COLLECTOR_PORT}:14268" - "${JAEGER_OTLP_GRPC_PORT}:4317" - "${JAEGER_OTLP_HTTP_PORT}:4318" - "${JAEGER_AGENT_PORT}:6831/udp" environment: COLLECTOR_ZIPKIN_HOST_PORT: ":9411" networks: - backend volumes: postgres_data: redis_data: prometheus_data: grafana_data: networks: public: driver: bridge backend: driver: bridge