Files
photography/backend/docker-compose.prod.yml
xujiang b35ee56848
Some checks failed
部署后端服务 / 🚀 构建并部署 (push) Failing after 41s
部署前端网站 / 🧪 测试和构建 (push) Successful in 2m58s
部署后端服务 / 🔄 回滚部署 (push) Failing after 2s
部署前端网站 / 🚀 部署到生产环境 (push) Failing after 4m13s
feat: 优化后端CI/CD配置,使用生产环境PostgreSQL凭据
- 添加生产环境docker-compose.prod.yml,移除PostgreSQL和Redis容器
- 更新CI/CD工作流使用secrets.POSTGRES_PHOTO_USER和secrets.POSTGRES_PHOTO_PWD
- 修复服务名称从backend改为api以匹配配置
- 自动创建生产环境.env文件并注入正确的数据库凭据

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-14 18:08:52 +08:00

80 lines
2.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Photography Portfolio Backend - Production Docker Compose
# 生产环境配置 - 使用现有 PostgreSQL 和 Redis 服务
version: '3.8'
services:
# 后端API服务 (仅API服务无数据库)
api:
build:
context: .
dockerfile: Dockerfile
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"
volumes:
- uploads_data:/app/uploads
- logs_data:/app/logs
restart: unless-stopped
healthcheck:
test: ["CMD", "/photography-api", "--health-check"]
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