# 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/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