version: '3.8' services: # PostgreSQL数据库 postgres: image: postgres:14-alpine container_name: algorithm-showcase-postgres environment: POSTGRES_DB: algorithm_db POSTGRES_USER: admin POSTGRES_PASSWORD: password ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U admin -d algorithm_db"] interval: 10s timeout: 5s retries: 5 # Redis缓存 redis: image: redis:7-alpine container_name: algorithm-showcase-redis ports: - "6379:6379" volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 # MinIO对象存储 (S3兼容) minio: image: minio/minio:latest container_name: algorithm-showcase-minio ports: - "9000:9000" - "9001:9001" environment: MINIO_ROOT_USER: minioadmin MINIO_ROOT_PASSWORD: minioadmin volumes: - minio_data:/data command: server /data --console-address ":9001" healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 30s timeout: 20s retries: 3 # 后端API服务 backend: build: context: ../backend dockerfile: Dockerfile container_name: algorithm-showcase-backend ports: - "8000:8000" depends_on: postgres: condition: service_healthy redis: condition: service_healthy minio: condition: service_started environment: - DATABASE_URL=postgresql://admin:password@postgres:5432/algorithm_db - REDIS_URL=redis://redis:6379/0 - MINIO_ENDPOINT=minio:9000 - MINIO_ACCESS_KEY=minioadmin - MINIO_SECRET_KEY=minioadmin - MINIO_BUCKET_NAME=algorithm-data - MINIO_SECURE=false - OPENAI_API_KEY=${OPENAI_API_KEY} - SECRET_KEY=${SECRET_KEY:-your-secret-key-here} - ALGORITHM=HS256 - ACCESS_TOKEN_EXPIRE_MINUTES=30 volumes: - ../backend:/app restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s timeout: 10s retries: 3 # 前端服务 frontend: build: context: ../frontend dockerfile: Dockerfile.prod container_name: algorithm-showcase-frontend ports: - "3000:80" depends_on: - backend environment: - VITE_API_BASE_URL=http://localhost:8000/api restart: unless-stopped # Nginx反向代理 (可选) nginx: image: nginx:alpine container_name: algorithm-showcase-nginx ports: - "80:80" - "443:443" volumes: - ./nginx.conf:/etc/nginx/nginx.conf - ./ssl:/etc/nginx/ssl depends_on: - frontend - backend restart: unless-stopped volumes: postgres_data: redis_data: minio_data: networks: default: driver: bridge name: algorithm-showcase-network