Files
photography/frontend/docker-compose.yml
xujiang c18973e528
Some checks failed
部署后端服务 / 🚀 构建并部署 (push) Failing after 7m56s
部署前端网站 / 🧪 测试和构建 (push) Successful in 5m26s
部署前端网站 / 🚀 部署到生产环境 (push) Failing after 3m43s
fix: 更新健康检查URL路径
- 将docker-compose.yml和docker-compose.prod.yml中的健康检查URL从`/health`更新为`/api/v1/health`
- 确保前端和后端服务的健康检查一致性

此更改确保服务健康检查指向正确的API路径。
2025-07-16 14:23:53 +08:00

115 lines
2.8 KiB
YAML

# Photography Portfolio Frontend - Docker Compose
# 本地开发和测试环境配置
version: '3.8'
services:
# 前端应用服务
frontend:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: photography-frontend
ports:
- "3000:80"
environment:
# API配置
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:8080}
NEXT_PUBLIC_API_TIMEOUT: ${NEXT_PUBLIC_API_TIMEOUT:-10000}
# 应用配置
NODE_ENV: production
NEXT_PUBLIC_APP_NAME: "Photography Portfolio"
NEXT_PUBLIC_APP_VERSION: "1.0.0"
# 功能开关
NEXT_PUBLIC_ENABLE_ANALYTICS: ${NEXT_PUBLIC_ENABLE_ANALYTICS:-false}
NEXT_PUBLIC_ENABLE_PWA: ${NEXT_PUBLIC_ENABLE_PWA:-true}
# 上传配置
NEXT_PUBLIC_MAX_FILE_SIZE: ${NEXT_PUBLIC_MAX_FILE_SIZE:-10485760}
NEXT_PUBLIC_ALLOWED_FILE_TYPES: ${NEXT_PUBLIC_ALLOWED_FILE_TYPES:-image/jpeg,image/png,image/gif,image/webp}
networks:
- photography-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/api/v1/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
depends_on:
- api
labels:
- "com.photography.service=frontend"
- "com.photography.version=1.0.0"
# 后端API服务 (用于本地开发)
api:
image: photography-api:latest
container_name: photography-api-dev
ports:
- "8080:8080"
environment:
APP_ENV: development
CORS_ORIGINS: "http://localhost:3000"
networks:
- photography-network
restart: unless-stopped
profiles:
- dev
# 开发环境服务 (热重载)
dev:
build:
context: .
dockerfile: Dockerfile
target: builder
container_name: photography-frontend-dev
ports:
- "3000:3000"
- "3001:3001" # 热重载端口
environment:
NODE_ENV: development
NEXT_PUBLIC_API_URL: http://localhost:8080
WATCHPACK_POLLING: true
volumes:
- .:/app
- node_modules:/app/node_modules
networks:
- photography-network
command: bun run dev
restart: unless-stopped
profiles:
- dev
# Nginx 代理服务 (可选)
nginx:
image: nginx:1.25-alpine
container_name: photography-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./default.conf:/etc/nginx/conf.d/default.conf:ro
- ssl_certs:/etc/nginx/ssl:ro
networks:
- photography-network
depends_on:
- frontend
restart: unless-stopped
profiles:
- proxy
volumes:
node_modules:
driver: local
ssl_certs:
driver: local
networks:
photography-network:
driver: bridge
external: true