Files
gochat/deploy/docker/docker-compose.prod.yml
T
Rogee 92f0d51375 refactor: 统一 DB/Redis 配置为 DSN 模式 + 移除 Helm/K8s 部署
- DatabaseConfig: Host/Port/User/Password/Name/DBName/SSLMode → 单个 DSN 字段
- RedisConfig: Host/Port/Password/DB/URL → 单个 DSN 字段
- 环境变量: GOCHAT_DATABASE_* (7个) → GOCHAT_DATABASE_DSN, GOCHAT_REDIS_* (5个) → GOCHAT_REDIS_DSN
- validator.go: DSN URL 解析校验 (scheme + host)
- redis.go: redis.ParseURL(cfg.DSN) 直连
- 所有 docker-compose / CI / shell 脚本 / .env 同步更新
- 删除 deploy/helm/ 整个目录 (20个文件)
- CI 删除 helm-validate / deploy-staging / deploy-production 三个 job
- 文档同步更新 (README, 架构设计, PRD, 滚动升级)
2026-07-29 20:58:10 +08:00

104 lines
2.9 KiB
YAML

# 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
- GOCHAT_DATABASE_DSN=postgres://${POSTGRES_USER:-gochat}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-gochat_production}?sslmode=disable
- GOCHAT_REDIS_DSN=redis://:${REDIS_PASSWORD}@redis: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
- GOCHAT_DATABASE_DSN=postgres://${POSTGRES_USER:-gochat}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-gochat_production}?sslmode=disable
- GOCHAT_REDIS_DSN=redis://:${REDIS_PASSWORD}@redis:6379
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
volumes:
postgres_data:
redis_data: