feat: rebuild xiteng.site homelab platform

This commit is contained in:
2026-08-12 09:48:25 +08:00
parent 557b0eca33
commit 5b84988789
128 changed files with 14979 additions and 292 deletions
+14
View File
@@ -0,0 +1,14 @@
FROM ghcr.nju.edu.cn/lecode-official/comfyui-docker:0.6.3-comfyui-0.8.2-comfyui-manager-4.0.5-pytorch-2.9.1-cuda-12.8-cudnn-9
USER root
WORKDIR /
RUN rm -rf /opt/comfyui /opt/comfyui-manager \
&& git clone --depth 1 --branch v0.31.0 https://github.com/Comfy-Org/ComfyUI.git /opt/comfyui \
&& git clone --depth 1 --branch 4.2.2 https://github.com/Comfy-Org/ComfyUI-Manager.git /opt/comfyui-manager
RUN /opt/conda/bin/pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple --requirement /opt/comfyui/requirements.txt \
&& if [ -f /opt/comfyui-manager/requirements.txt ]; then /opt/conda/bin/pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple --requirement /opt/comfyui-manager/requirements.txt; fi
WORKDIR /opt/comfyui
+10
View File
@@ -0,0 +1,10 @@
services:
comfyui:
command: ["--enable-manager"]
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
+62
View File
@@ -0,0 +1,62 @@
services:
comfyui:
build:
context: .
image: xiteng-comfyui:0.31.0-manager-4.2.2
container_name: comfyui
restart: unless-stopped
entrypoint: ["/bin/bash", "/entrypoint-patched.sh"]
environment:
USER_ID: ${COMFYUI_USER_ID:-1000}
GROUP_ID: ${COMFYUI_GROUP_ID:-1000}
PYTHONPATH: /opt/comfyui-manager
command: ["--cpu", "--enable-manager"]
volumes:
- ./entrypoint.sh:/entrypoint-patched.sh:ro
- ./models:/opt/comfyui/models:rw
- ./custom_nodes:/opt/comfyui/custom_nodes:rw
- ./output:/opt/comfyui/output:rw
networks:
- homelab_net
labels:
# Traefik
- "traefik.enable=true"
- "traefik.http.routers.comfyui.rule=Host(`comfy.xiteng.site`)"
- "traefik.http.routers.comfyui.entrypoints=websecure"
- "traefik.http.routers.comfyui.tls=true"
- "traefik.http.routers.comfyui.tls.certresolver=cfresolver"
- "traefik.http.routers.comfyui.service=comfyui"
- "traefik.http.routers.comfyui.middlewares=comfyui-scheme,comfyui-auth"
- "traefik.http.services.comfyui.loadbalancer.server.port=8188"
- "traefik.http.routers.comfyui-http.rule=Host(`comfy.xiteng.site`)"
- "traefik.http.routers.comfyui-http.entrypoints=web"
- "traefik.http.routers.comfyui-http.service=comfyui"
- "traefik.http.routers.comfyui-http.middlewares=comfyui-scheme,comfyui-auth"
- "xiteng.site.cache.comfyui.enabled=true"
- "xiteng.site.cache.comfyui.routers=comfyui,comfyui-http"
- "xiteng.site.cache.comfyui.paths=/assets/,/static/"
- "xiteng.site.cache.comfyui.edge-ttl=604800"
- "xiteng.site.cache.comfyui.stale-while-revalidate=86400"
# Authentik ForwardAuth
- "traefik.http.middlewares.comfyui-scheme.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.middlewares.comfyui-auth.forwardauth.address=http://authentik-outpost:9000/outpost.goauthentik.io/auth/traefik"
- "traefik.http.middlewares.comfyui-auth.forwardauth.trustForwardHeader=true"
- "traefik.http.middlewares.comfyui-auth.forwardauth.authResponseHeaders=X-authentik-username,X-authentik-groups,X-authentik-email,X-authentik-name"
- "xiteng.site.component.comfyui.enabled=true"
- "xiteng.site.component.comfyui.name=ComfyUI"
- "xiteng.site.component.comfyui.description=节点式图像生成、模型与工作流实验环境。"
- "xiteng.site.component.comfyui.section=services"
- "xiteng.site.component.comfyui.category=AI"
- "xiteng.site.component.comfyui.url=https://comfy.xiteng.site"
- "xiteng.site.component.comfyui.access=sso"
- "xiteng.site.component.comfyui.access-label=需要 Authentik"
- "xiteng.site.component.comfyui.icon=CU"
- "xiteng.site.component.comfyui.icon-url=https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/comfyui.svg"
- "xiteng.site.component.comfyui.accent=red"
- "xiteng.site.component.comfyui.order=210"
- "xiteng.site.component.comfyui.monitor.enabled=true"
- "xiteng.site.component.comfyui.monitor.url=http://comfyui:8188"
networks:
homelab_net:
external: true
+103
View File
@@ -0,0 +1,103 @@
#!/bin/bash
set -e
echo "Creating directories for models..."
MODEL_DIRECTORIES=(
"checkpoints"
"clip"
"clip_vision"
"configs"
"controlnet"
"diffusers"
"diffusion_models"
"embeddings"
"gligen"
"hypernetworks"
"loras"
"photomaker"
"style_models"
"text_encoders"
"unet"
"upscale_models"
"vae"
"vae_approx"
)
for MODEL_DIRECTORY in "${MODEL_DIRECTORIES[@]}"; do
mkdir -p "/opt/comfyui/models/$MODEL_DIRECTORY"
done
echo "Preparing ComfyUI Manager..."
export PYTHONPATH="/opt/comfyui-manager${PYTHONPATH:+:$PYTHONPATH}"
rm --force /opt/comfyui/custom_nodes/ComfyUI-Manager
ln -s /opt/comfyui-manager /opt/comfyui/custom_nodes/ComfyUI-Manager
mkdir -p /opt/comfyui/user/__manager
python - <<'PY'
from configparser import ConfigParser
from pathlib import Path
config_path = Path("/opt/comfyui/user/__manager/config.ini")
config = ConfigParser(strict=False)
config.read(config_path)
if "default" not in config:
config["default"] = {}
defaults = {
"git_exe": "",
"use_uv": "True",
"channel_url": "https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main",
"share_option": "all",
"bypass_ssl": "False",
"file_logging": "True",
"update_policy": "stable-comfyui",
"windows_selector_event_loop_policy": "False",
"model_download_by_agent": "False",
"downgrade_blacklist": "",
"security_level": "normal",
"always_lazy_install": "False",
"verbose": "False",
}
for key, value in defaults.items():
config["default"].setdefault(key, value)
config["default"]["network_mode"] = "offline"
config["default"]["db_mode"] = "local"
with config_path.open("w", encoding="utf-8") as handle:
config.write(handle)
PY
echo "Installing requirements for custom nodes..."
for CUSTOM_NODE_DIRECTORY in /opt/comfyui/custom_nodes/*; do
if [ "$CUSTOM_NODE_DIRECTORY" != "/opt/comfyui/custom_nodes/ComfyUI-Manager" ]; then
if [ -f "$CUSTOM_NODE_DIRECTORY/requirements.txt" ]; then
CUSTOM_NODE_NAME=${CUSTOM_NODE_DIRECTORY##*/}
CUSTOM_NODE_NAME=${CUSTOM_NODE_NAME//[-_]/ }
echo "Installing requirements for $CUSTOM_NODE_NAME..."
pip install --requirement "$CUSTOM_NODE_DIRECTORY/requirements.txt"
fi
fi
done
if [ -z "$USER_ID" ] || [ -z "$GROUP_ID" ]; then
echo "Running container as $USER..."
exec /opt/conda/bin/python main.py \
--port 8188 \
--listen 0.0.0.0 \
--disable-auto-launch \
"$@"
else
echo "Creating non-root user..."
getent group "$GROUP_ID" > /dev/null 2>&1 || groupadd --gid "$GROUP_ID" comfyui-user
id -u "$USER_ID" > /dev/null 2>&1 || useradd --uid "$USER_ID" --gid "$GROUP_ID" --create-home comfyui-user
chown --recursive "$USER_ID:$GROUP_ID" /opt/comfyui
chown --recursive "$USER_ID:$GROUP_ID" /opt/comfyui-manager
export PATH=$PATH:/home/comfyui-user/.local/bin
echo "Running container as comfyui-user ($USER_ID:$GROUP_ID)..."
sudo --set-home --preserve-env=PATH,PYTHONPATH --user "#$USER_ID" \
/opt/conda/bin/python main.py \
--port 8188 \
--listen 0.0.0.0 \
--disable-auto-launch \
"$@"
fi