# Photography Portfolio Backend - Production Docker Compose # 生产环境配置 - 使用现有 PostgreSQL 和 Redis 服务 # version 字段已废弃,不再需要使用 # version: '3.8' services: # 后端API服务 (仅API服务,无数据库) api: image: crpi-b4fqtfbvv583enk2.cn-shanghai.personal.cr.aliyuncs.com/photography-backend/photography:latest container_name: photography-api environment: # 数据库配置 (连接现有服务) DB_HOST: ${DB_HOST:-redis_cache} DB_PORT: ${DB_PORT:-5432} DB_NAME: ${DB_NAME:-photography} DB_USER: ${DB_USER:-postgres} DB_PASSWORD: ${DB_PASSWORD} DB_SSL_MODE: ${DB_SSL_MODE:-disable} # Redis配置 (连接现有服务) REDIS_HOST: ${REDIS_HOST:-localhost} REDIS_PORT: ${REDIS_PORT:-6379} REDIS_PASSWORD: ${REDIS_PASSWORD:-} REDIS_DB: ${REDIS_DB:-0} # JWT配置 JWT_SECRET: ${JWT_SECRET} JWT_EXPIRE: ${JWT_EXPIRE:-24h} # 服务配置 APP_ENV: ${APP_ENV:-production} APP_PORT: ${APP_PORT:-8080} APP_HOST: ${APP_HOST:-0.0.0.0} # CORS配置 CORS_ORIGINS: ${CORS_ORIGINS:-https://photography.iriver.top} # 文件上传配置 UPLOAD_PATH: ${UPLOAD_PATH:-/app/uploads} UPLOAD_MAX_SIZE: ${UPLOAD_MAX_SIZE:-10485760} # 日志配置 LOG_LEVEL: ${LOG_LEVEL:-info} LOG_FORMAT: ${LOG_FORMAT:-json} ports: - "8080:8080" networks: - app_network volumes: - uploads_data:/app/uploads - logs_data:/app/logs restart: unless-stopped healthcheck: test: ["CMD", "/usr/local/bin/health-check.sh"] interval: 30s timeout: 10s retries: 3 start_period: 10s # 数据库迁移服务 (一次性运行) migrate: build: context: . dockerfile: Dockerfile container_name: photography-migrate environment: DB_HOST: ${DB_HOST:-localhost} DB_PORT: ${DB_PORT:-5432} DB_NAME: ${DB_NAME:-photography} DB_USER: ${DB_USER:-postgres} DB_PASSWORD: ${DB_PASSWORD} DB_SSL_MODE: ${DB_SSL_MODE:-disable} entrypoint: ["/migrate", "up"] restart: "no" volumes: uploads_data: driver: local logs_data: driver: local networks: app_network: external: true