Files
photography/backend/docker-compose.yml
xujiang c10abdab19
Some checks failed
部署后端服务 / 🚀 构建并部署后端 (push) Has been cancelled
fix
2025-07-15 15:46:17 +08:00

79 lines
2.2 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 字段已废弃,不再需要使用
# 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"
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