Files
AI-Testing/docker-compose.yml
2026-04-18 20:20:38 +08:00

94 lines
3.1 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 构建参数默认走国内源;可在项目根 .env 中覆盖Compose 会自动加载 .env
# 基础镜像 postgres/nginx/python/node 仍从 Docker Hub 拉取,请在 Docker Desktop 配置 registry-mirrors见 scripts/configure-mirrors.sh
#
# backend 已默认清空 HTTP(S)_PROXY避免宿主机/IDE 代理注入容器导致访问 dashscope 失败;若必须走代理访问外网,请用
# docker-compose.override.yml 覆盖 HTTPX_TRUST_ENV=1 并设置代理变量(见 .env.example 说明)
services:
db:
image: postgres:16-alpine
container_name: exam-helper-db
restart: unless-stopped
environment:
POSTGRES_DB: exam_helper
POSTGRES_USER: exam_user
POSTGRES_PASSWORD: exam_pass
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U exam_user -d exam_helper"]
interval: 5s
timeout: 5s
retries: 10
backend:
build:
context: ./backend
args:
PIP_INDEX_URL: ${PIP_INDEX_URL:-https://mirrors.aliyun.com/pypi/simple/}
PIP_TRUSTED_HOST: ${PIP_TRUSTED_HOST:-mirrors.aliyun.com}
DEBIAN_MIRROR_HOST: ${DEBIAN_MIRROR_HOST:-mirrors.aliyun.com}
container_name: exam-helper-backend
restart: unless-stopped
# 改善容器内解析 dashscope.aliyuncs.com若仍 ConnectError再检查宿主机网络/代理)
dns:
- 223.5.5.5
- 223.6.6.6
healthcheck:
test:
[
"CMD",
"python",
"-c",
"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=3).read()",
]
interval: 5s
timeout: 5s
retries: 12
start_period: 25s
# 先加载 .env.example若存在 .env 则合并覆盖(推荐用 start.sh 或 scripts/bootstrap-env.sh 生成 .env
env_file:
- .env.example
- path: .env
required: false
environment:
DATABASE_URL: postgresql+psycopg://exam_user:exam_pass@db:5432/exam_helper
# 本地开发 Vite + Docker 前端均需允许
CORS_ORIGINS: http://localhost:5173,http://localhost:8173
UPLOAD_DIR: /app/uploads
# 覆盖 .env 中可能误带的代理,保证访问千问与 pip 行为解耦(千问用 httpx trust_env=false + 此处清空)
HTTPX_TRUST_ENV: "0"
HTTP_PROXY: ""
HTTPS_PROXY: ""
ALL_PROXY: ""
http_proxy: ""
https_proxy: ""
all_proxy: ""
NO_PROXY: "*"
volumes:
- uploads_data:/app/uploads
depends_on:
db:
condition: service_healthy
# 仅绑定本机回环;需手机/局域网访问可改为 "8866:8000"
ports:
- "127.0.0.1:8866:8000"
frontend:
build:
context: ./frontend
args:
NPM_REGISTRY: ${NPM_REGISTRY:-https://registry.npmmirror.com}
DEBIAN_MIRROR_HOST: ${DEBIAN_MIRROR_HOST:-mirrors.aliyun.com}
ALPINE_MIRROR_HOST: ${ALPINE_MIRROR_HOST:-mirrors.aliyun.com}
container_name: exam-helper-frontend
restart: unless-stopped
depends_on:
backend:
condition: service_healthy
ports:
- "127.0.0.1:8173:80"
volumes:
postgres_data:
uploads_data: