services: # Redis Cache redis: image: redis:7-alpine container_name: hci-redis restart: unless-stopped expose: - "6379" networks: - hci-network command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 3s retries: 3 # Python FastAPI Backend backend: build: context: . dockerfile: Dockerfile.backend container_name: hci-backend # 不對外暴露端口,只在內網使用 expose: - "8000" environment: - GEMINI_API_KEY=${GEMINI_API_KEY} - REDIS_URL=redis://redis:6379 env_file: - ./backend/.env # Volume 掛載:確保生成的靜態文件持久化 volumes: - ./backend/static:/app/static restart: unless-stopped depends_on: - redis networks: - hci-network healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s timeout: 10s retries: 3 # Nuxt 3 Frontend frontend: build: context: . dockerfile: Dockerfile.frontend container_name: hci-frontend # 改用內部端口 3001,不直接對外 expose: - "3001" environment: - NODE_ENV=production - PORT=3001 depends_on: - backend restart: unless-stopped networks: - hci-network # Nginx 反向代理 nginx: build: context: . dockerfile: Dockerfile.nginx container_name: hci-nginx ports: - "80:3000" # 對外暴露 80 端口,轉發到內部 3000 depends_on: - frontend - backend restart: unless-stopped networks: - hci-network networks: hci-network: driver: bridge