nex_buddy/docker-compose.yml

58 lines
2.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

name: nex-buddy
services:
api:
# 构建源与基础镜像默认值都在这里;服务器有差异时直接改本文件。
build:
context: .
dockerfile: docker/Dockerfile.api
args:
APT_MIRROR: "${APT_MIRROR:-mirrors.tuna.tsinghua.edu.cn}"
PIP_INDEX_URL: "${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple}"
PYTHON_IMAGE: "${PYTHON_IMAGE:-python:3.12-slim}"
image: nex-buddy-api:latest
init: true
# 让容器通过 host.docker.internal 访问宿主机上的 PostgreSQL/Redis。
# 数据库在别的机器时,这条配置不会产生影响。
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- .env
environment:
# 容器内固定使用 /app/data,宿主机路径由下面的 volumes 决定
DATA_DIR: /app/data
# 容器内端口固定;宿主机映射端口由 .env 的 BACKEND_PORT 决定
BACKEND_PORT: "8000"
FORWARDED_ALLOW_IPS: "*"
WEB_CONCURRENCY: "${WEB_CONCURRENCY:-2}"
volumes:
# 默认挂载项目根 data/;要换宿主机磁盘就改这里,或用 NEX_BUDDY_DATA_DIR 指定
- "${NEX_BUDDY_DATA_DIR:-./data}:/app/data"
ports:
# 宿主机端口由 .env 的 BACKEND_PORT 决定;容器内始终是 8000
- "${BACKEND_PORT:-8000}:8000"
restart: unless-stopped
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=3)"]
interval: 10s
timeout: 5s
retries: 20
start_period: 30s
web:
build:
context: .
dockerfile: docker/Dockerfile.web
args:
NPM_REGISTRY: "${NPM_REGISTRY:-https://registry.npmmirror.com}"
NODE_IMAGE: "${NODE_IMAGE:-node:22-alpine}"
NGINX_IMAGE: "${NGINX_IMAGE:-nginx:latest}"
image: nex-buddy-web:latest
ports:
# 宿主机端口由 .env 的 FRONTEND_PORT 决定;容器内 Nginx 始终是 80
- "${FRONTEND_PORT:-5173}:80"
depends_on:
api:
condition: service_healthy
restart: unless-stopped