version: '3.8' services: # PostgreSQL 数据库 postgres: image: postgres:16-alpine container_name: xiaoxia-postgres environment: POSTGRES_DB: xiaoxia_saas POSTGRES_USER: xiaoxia_user POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme} volumes: - postgres_data:/var/lib/postgresql/data - ./migrations:/docker-entrypoint-initdb.d:ro ports: - "5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U xiaoxia_user"] interval: 10s timeout: 5s retries: 5 restart: unless-stopped # Redis 缓存 redis: image: redis:7-alpine container_name: xiaoxia-redis ports: - "6379:6379" volumes: - redis_data:/data command: redis-server --appendonly yes healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 3s retries: 5 restart: unless-stopped # 小虾 SaaS API api: build: . container_name: xiaoxia-api environment: DATABASE_URL: postgresql://xiaoxia_user:${POSTGRES_PASSWORD:-changeme}@postgres:5432/xiaoxia_saas REDIS_URL: redis://redis:6379/0 JWT_SECRET_KEY: ${JWT_SECRET_KEY:-your-secret-key-change-in-production} SMTP_HOST: ${SMTP_HOST:-smtp.gmail.com} SMTP_PORT: ${SMTP_PORT:-587} SMTP_USER: ${SMTP_USER} SMTP_PASSWORD: ${SMTP_PASSWORD} BASE_URL: ${BASE_URL:-http://localhost:3000} ENVIRONMENT: ${ENVIRONMENT:-production} ports: - "8000:8000" depends_on: postgres: condition: service_healthy redis: condition: service_healthy volumes: - ./logs:/app/logs restart: unless-stopped volumes: postgres_data: driver: local redis_data: driver: local networks: default: name: xiaoxia-network