version: '3.8' services: postgres: image: postgres:16-alpine container_name: askbox-postgres restart: always environment: POSTGRES_USER: ${POSTGRES_USER:-askbox} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required} POSTGRES_DB: ${POSTGRES_DB:-askbox} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-askbox}"] interval: 10s timeout: 5s retries: 5 networks: - askbox-network redis: image: redis:7-alpine container_name: askbox-redis restart: always volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 command: redis-server --appendonly yes networks: - askbox-network api: build: context: . dockerfile: apps/api/Dockerfile container_name: askbox-api restart: always ports: - "${API_PORT:-3030}:3030" environment: NODE_ENV: production DATABASE_URL: postgresql://${POSTGRES_USER:-askbox}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-askbox} REDIS_URL: redis://redis:6379 JWT_SECRET: ${JWT_SECRET:?JWT_SECRET is required} CORS_ORIGIN: ${CORS_ORIGIN:-https://askbox.w33d.xyz} PORT: 3030 HOST: 0.0.0.0 depends_on: postgres: condition: service_healthy redis: condition: service_healthy healthcheck: test: ["CMD", "wget", "-q", "--spider", "http://localhost:3030/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - askbox-network web: build: context: . dockerfile: apps/web/Dockerfile args: NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-https://askbox.w33d.xyz/api} container_name: askbox-web restart: always ports: - "${WEB_PORT:-3031}:3031" environment: NODE_ENV: production NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-https://askbox.w33d.xyz/api} depends_on: - api healthcheck: test: ["CMD", "wget", "-q", "--spider", "http://localhost:3031"] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - askbox-network volumes: postgres_data: redis_data: networks: askbox-network: driver: bridge