nex_animation/docker-compose.yml

80 lines
3.8 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.

# =============================================================================
# Nex Animation Studio · 单容器部署(后端 + 前端产物 + ffmpeg 在同一个镜像里)
#
# 常用命令:
# docker compose up -d --build 首次部署(构建 + 后台启动)
# docker compose logs -f app 看日志(首启会打印导入数据包那一行)
# docker compose ps 状态(healthy 才算起来,探的是 /health)
# docker compose up -d 改了 .env 之后重跑这条:restart 沿用旧容器配置,不换端口映射
# docker compose down 停止并删除容器,数据留在 ./data 与 ./media
#
# 配置来源:同目录 .env(compose 既用它做变量插值,也整份注入容器)。
# 对外端口 = .env 的 HOST_PORT;容器内固定监听 8000(与 EXPOSE / HEALTHCHECK 对齐)。
# 下面 environment 点名的键是例外,容器内的路径与宿主不是一回事,必须覆盖。
# 数据四个 bind mount:./data 库、./media 产物、./scripts/seed 模型配置与主密钥、./models 权重。
# 为什么只要一个容器、模型配置为什么不在这份文件里、扩容层怎么叠:README §3.2 与 §4.0。
# 需要 Docker Compose ≥ v2.24(env_file 的 required: false 写法)。
# =============================================================================
name: nex-animation
services:
app:
build:
context: .
args:
# 构建期只有 npm / apt / pip 三个下载点(**没有 huggingface**:听写权重不进镜像),
# 默认值全按国内直连能通的配,运维零配置;境外构建显式传回官方源。
# 基础镜像本机已有就别加 --pull,否则每次都会去 registry 校验一次。
BASE_IMAGE: "${BASE_IMAGE:-python:3.12-slim}"
NODE_IMAGE: "${NODE_IMAGE:-node:22-alpine}"
PIP_INDEX_URL: "${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple}"
NPM_REGISTRY: "${NPM_REGISTRY:-https://registry.npmmirror.com}"
APT_MIRROR: "${APT_MIRROR:-mirrors.tuna.tsinghua.edu.cn}"
image: nex-animation:latest
container_name: nex-animation
restart: unless-stopped
env_file:
- path: .env
required: false # 空机器上先起来再配,别让缺 .env 变成起不来
environment:
DATABASE_URL: "${APP_DATABASE_URL:-sqlite:////app/data/nex_animation.db}"
MEDIA_ROOT: "${APP_MEDIA_ROOT:-/app/media}"
SERVE_FRONTEND: "on" # 后端托管 frontend/dist,对外只有一个端口
TASK_EXECUTOR: "inline" # 进程内线程池 + 派发守护线程,不需要 Redis 与独立 worker
INLINE_WORKERS: "${INLINE_WORKERS:-2}"
AUTH_ENABLED: "${AUTH_ENABLED:-true}"
BOOTSTRAP_USERNAME: "${BOOTSTRAP_USERNAME:-admin}"
BOOTSTRAP_PASSWORD: "${BOOTSTRAP_PASSWORD:-admin1234}"
AUTO_SEED: "${AUTO_SEED:-only-missing}" # 首启用 scripts/seed 灌模型配置:only-missing|force|off
TZ: "${TZ:-Asia/Shanghai}"
ports:
- "${HOST_PORT:-8000}:8000"
volumes:
- ./data:/app/data
- ./media:/app/media
- ./scripts/seed:/app/scripts/seed:ro
- ./models:/app/models:ro
extra_hosts:
- "host.docker.internal:host-gateway" # 自建 ComfyUI 装宿主机时用它指回宿主
# 可选:在本机用容器起一份 ComfyUI。默认不参与(--profile comfy 才起),算力在远端时不用管。
comfyui:
profiles: ["comfy"]
image: comfyanonymous/comfyui:latest
ports: ["9200:8188"]
volumes:
- comfy_models:/root/comfy-ui/models
- comfy_input:/root/comfy-ui/user/default
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
restart: unless-stopped
volumes:
comfy_models:
comfy_input: