# GoChat Production Environment # Reference: Chatwoot docker-compose.production.yaml — rails + sidekiq + postgres + redis, restart policies # Enhanced with pgvector, resource limits, non-root user, health checks version: '3.8' services: postgres: image: pgvector/pgvector:pg16 container_name: gochat-postgres restart: always environment: POSTGRES_DB: ${POSTGRES_DB:-gochat_production} POSTGRES_USER: ${POSTGRES_USER:-gochat} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} # MUST be set in .env ports: - "127.0.0.1:5432:5432" # Only localhost access volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-gochat}"] interval: 10s timeout: 5s retries: 5 deploy: resources: limits: memory: 1G redis: image: redis:7-alpine container_name: gochat-redis restart: always command: redis-server --requirepass "${REDIS_PASSWORD}" --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru ports: - "127.0.0.1:6379:6379" # Only localhost access volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"] interval: 10s timeout: 5s retries: 5 deploy: resources: limits: memory: 512M gochat: image: gochat/gochat:${GOCHAT_VERSION:-latest} container_name: gochat-app restart: always depends_on: postgres: condition: service_healthy redis: condition: service_healthy ports: - "127.0.0.1:3000:3000" # Reverse proxy should handle external access env_file: .env environment: - GOCHAT_ENV=production - POSTGRES_HOST=postgres - POSTGRES_PORT=5432 - REDIS_HOST=redis - REDIS_PORT=6379 healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3000/health"] interval: 30s timeout: 5s start_period: 15s retries: 3 deploy: resources: limits: memory: 512M cpus: '1.0' reservations: memory: 256M cpus: '0.5' worker: image: gochat/gochat:${GOCHAT_VERSION:-latest} container_name: gochat-worker restart: always depends_on: postgres: condition: service_healthy redis: condition: service_healthy command: ["serve", "--worker-only"] env_file: .env environment: - GOCHAT_ENV=production - POSTGRES_HOST=postgres - POSTGRES_PORT=5432 - REDIS_HOST=redis - REDIS_PORT=6379 deploy: resources: limits: memory: 512M cpus: '1.0' volumes: postgres_data: redis_data: