final version

This commit is contained in:
2026-02-18 23:39:39 +08:00
parent 72ab0c0b56
commit 32d0bca5f9
3975 changed files with 781 additions and 1106509 deletions

View File

@@ -1,120 +0,0 @@
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:
image: python:3.9-slim
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:-your_openai_api_key_here}
- SECRET_KEY=${SECRET_KEY:-your-secret-key-here}
- ALGORITHM=HS256
- ACCESS_TOKEN_EXPIRE_MINUTES=30
volumes:
- ../backend:/app
working_dir: /app
command: >
sh -c "pip install --no-cache-dir -r requirements.txt &&
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
# 前端服务 (使用预构建镜像)
frontend:
image: node:18-alpine
container_name: algorithm-showcase-frontend
ports:
- "3000:3000"
depends_on:
- backend
volumes:
- ../frontend:/app
working_dir: /app
command: >
sh -c "npm install &&
npm run dev -- --host 0.0.0.0 --port 3000"
environment:
- NODE_ENV=development
- VITE_API_BASE_URL=http://localhost:8000/api
restart: unless-stopped
volumes:
postgres_data:
redis_data:
minio_data:
networks:
default:
driver: bridge
name: algorithm-showcase-network

View File

@@ -1,115 +0,0 @@
version: '3.8'
services:
# PostgreSQL数据库
postgres:
image: postgres:16-alpine
container_name: algorithm-showcase-postgres
environment:
POSTGRES_DB: algorithm_db
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
ports:
- "5433: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: crpi-x2l5uviq1k8hji3c.ap-northeast-1.personal.cr.aliyuncs.com/yipaidocker-images/linux_amd64_redis:latest
platform: linux/amd64
container_name: algorithm-showcase-redis
ports:
- "6381:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# MinIO对象存储 (S3兼容)
minio:
image: crpi-x2l5uviq1k8hji3c.ap-northeast-1.personal.cr.aliyuncs.com/yipaidocker-images/linux_amd64_minio:latest
platform: linux/amd64
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.custom
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.simple
container_name: algorithm-showcase-frontend
ports:
- "3000:80"
depends_on:
- backend
environment:
- VITE_API_BASE_URL=http://localhost:8000/api
restart: unless-stopped
volumes:
postgres_data:
redis_data:
minio_data:
networks:
default:
driver: bridge
name: algorithm-showcase-network

View File

@@ -72,7 +72,7 @@ echo "部署完成!"
echo ""
echo "服务地址:"
echo "- 前端: http://localhost:3000"
echo "- 后端API: http://localhost:8000"
echo "- 后端API: http://localhost:8001"
echo "- MinIO控制台: http://localhost:9001 (admin/minioadmin)"
echo ""
echo "要查看日志,请运行: docker-compose -f docker-compose-full.yml logs -f"
@@ -81,5 +81,5 @@ echo "要查看日志,请运行: docker-compose -f docker-compose-full.yml log
echo ""
echo "如遇问题,可尝试以下操作:"
echo "1. 检查Docker是否正常运行"
echo "2. 检查端口8000, 3000, 5432, 6379, 9000, 9001是否已被占用"
echo "2. 检查端口8001, 3000, 5432, 6379, 9000, 9001是否已被占用"
echo "3. 运行 'docker-compose -f docker-compose-full.yml logs' 查看详细日志"

View File

@@ -59,7 +59,7 @@ services:
dockerfile: Dockerfile
container_name: algorithm-showcase-backend
ports:
- "8000:8000"
- "8001:8000"
depends_on:
postgres:
condition: service_healthy
@@ -99,7 +99,7 @@ services:
depends_on:
- backend
environment:
- VITE_API_BASE_URL=http://localhost:8000/api
- VITE_API_BASE_URL=http://localhost:8001/api
restart: unless-stopped
# Nginx反向代理 (可选)