fix
Some checks failed
部署后端服务 / 🧪 测试后端 (push) Failing after 5m8s
部署后端服务 / 🚀 构建并部署 (push) Has been skipped
部署后端服务 / 🔄 回滚部署 (push) Has been skipped

This commit is contained in:
xujiang
2025-07-10 18:09:11 +08:00
parent 35004f224e
commit 010fe2a8c7
96 changed files with 23709 additions and 19 deletions

View File

@ -0,0 +1,71 @@
version: '3.8'
services:
# 后端 API 服务
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: photography_backend
restart: unless-stopped
environment:
# 数据库配置 (连接到现有的 PostgreSQL)
DB_HOST: ${DB_HOST:-localhost}
DB_PORT: ${DB_PORT:-5432}
DB_NAME: ${DB_NAME:-photography}
DB_USER: ${DB_USER:-postgres}
DB_PASSWORD: ${DB_PASSWORD}
# Redis 配置 (连接到现有的 Redis)
REDIS_HOST: ${REDIS_HOST:-localhost}
REDIS_PORT: ${REDIS_PORT:-6379}
REDIS_PASSWORD: ${REDIS_PASSWORD}
# JWT 配置
JWT_SECRET: ${JWT_SECRET}
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-24h}
# 服务器配置
PORT: 8080
GIN_MODE: release
# 文件存储配置
STORAGE_TYPE: ${STORAGE_TYPE:-local}
STORAGE_PATH: /app/uploads
MAX_UPLOAD_SIZE: ${MAX_UPLOAD_SIZE:-10MB}
# 日志配置
LOG_LEVEL: ${LOG_LEVEL:-info}
LOG_FORMAT: json
volumes:
- ./backend/uploads:/app/uploads
- ./backend/logs:/app/logs
- ./backend/configs:/app/configs
ports:
- "127.0.0.1:8080:8080"
# 使用 host 网络模式以便访问宿主机的服务
network_mode: host
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
# 数据库备份服务 (可选,如果你想使用容器化备份)
backup:
image: postgres:16-alpine
container_name: photography_backup
restart: "no"
environment:
PGPASSWORD: ${DB_PASSWORD}
DB_HOST: ${DB_HOST:-localhost}
DB_USER: ${DB_USER:-postgres}
DB_NAME: ${DB_NAME:-photography}
volumes:
- ./backups:/backups
- ./scripts/backup.sh:/backup.sh
network_mode: host
entrypoint: ["/backup.sh"]
profiles:
- backup # 使用 profile 使这个服务可选