You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.9 KiB
106 lines
2.9 KiB
# 开发环境配置文件
|
|
# 使用方式: docker compose -f docker-compose.yml up --build -d
|
|
#
|
|
# 特点:
|
|
# - 前端使用 Vite 开发服务器,支持热更新 (HMR)
|
|
# - 代码修改后自动刷新浏览器
|
|
# - Nginx 代理 WebSocket 连接用于 HMR
|
|
# - 挂载本地代码目录到容器
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
container_name: ent-postgres
|
|
restart: always
|
|
entrypoint: >
|
|
sh -c '
|
|
if [ ! -f /usr/local/share/postgresql/extension/vector.control ]; then
|
|
echo ">>> pgvector 未安装,正在编译安装(仅首次约 30 秒)..."
|
|
apk add --no-cache --virtual .pg_build git build-base postgresql16-dev clang llvm-dev > /dev/null 2>&1
|
|
wget -qO- https://github.com/pgvector/pgvector/archive/refs/tags/v0.7.4.tar.gz | tar xz -C /tmp
|
|
cd /tmp/pgvector-0.7.4 && make -j2 > /dev/null 2>&1 && make install > /dev/null 2>&1
|
|
cd / && rm -rf /tmp/pgvector-0.7.4
|
|
apk del .pg_build > /dev/null 2>&1
|
|
echo ">>> pgvector 安装完成"
|
|
fi
|
|
exec docker-entrypoint.sh postgres
|
|
'
|
|
environment:
|
|
POSTGRES_USER: enterprise
|
|
POSTGRES_PASSWORD: enterprise123
|
|
POSTGRES_DB: enterprise_ai
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./init-db:/docker-entrypoint-initdb.d
|
|
ports:
|
|
- "5431:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U enterprise"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: ent-redis
|
|
restart: always
|
|
command: redis-server --appendonly yes --requirepass redis123
|
|
volumes:
|
|
- redis_data:/data
|
|
ports:
|
|
- "6378:6379"
|
|
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: ent-backend
|
|
restart: always
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_started
|
|
environment:
|
|
DATABASE_URL: postgresql+asyncpg://enterprise:enterprise123@postgres:5432/enterprise_ai
|
|
REDIS_URL: redis://:redis123@redis:6379/0
|
|
JWT_SECRET: dev-secret-key-change-in-production-32chars
|
|
LLM_API_KEY: ${LLM_API_KEY:-sk-placeholder}
|
|
LLM_API_BASE: ${LLM_API_BASE:-https://api.openai.com/v1}
|
|
LLM_MODEL: ${LLM_MODEL:-gpt-4o-mini}
|
|
ports:
|
|
- "8100:8000"
|
|
volumes:
|
|
- ./backend:/app
|
|
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile.dev
|
|
container_name: ent-frontend
|
|
restart: always
|
|
depends_on:
|
|
- backend
|
|
ports:
|
|
- "3000:80"
|
|
volumes:
|
|
- ./frontend:/app
|
|
- /app/node_modules
|
|
environment:
|
|
- CHOKIDAR_USEPOLLING=true
|
|
|
|
nginx:
|
|
image: nginx:alpine
|
|
container_name: ent-nginx
|
|
restart: always
|
|
depends_on:
|
|
- frontend
|
|
- backend
|
|
volumes:
|
|
- ./nginx/nginx.dev.conf:/etc/nginx/nginx.conf:ro
|
|
ports:
|
|
- "80:80"
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
|