Spaces:
Running
Running
Upload 2 files
Browse files- Dockerfile +189 -0
- README.md +224 -5
Dockerfile
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM node:lts-alpine3.19
|
2 |
+
|
3 |
+
# Arguments
|
4 |
+
ARG APP_HOME=/home/node/app
|
5 |
+
ARG PLUGINS="" # Comma-separated list of plugin git URLs
|
6 |
+
|
7 |
+
# Install system dependencies
|
8 |
+
# Add unzip for extracting the application code
|
9 |
+
# Keep git for potential use by scripts or future plugin updates
|
10 |
+
# Add wget to download the zip file
|
11 |
+
RUN apk add --no-cache gcompat tini git unzip wget
|
12 |
+
|
13 |
+
# Create app directory
|
14 |
+
WORKDIR ${APP_HOME}
|
15 |
+
|
16 |
+
# Set NODE_ENV to production
|
17 |
+
ENV NODE_ENV=production
|
18 |
+
|
19 |
+
# --- BEGIN: Clone SillyTavern Core from GitHub (staging branch) ---
|
20 |
+
RUN \
|
21 |
+
echo "*** Cloning SillyTavern Core from GitHub (staging branch) ***" && \
|
22 |
+
# Clone the specific branch into the current directory
|
23 |
+
git clone -b staging --depth 1 https://github.com/SillyTavern/SillyTavern.git . && \
|
24 |
+
echo "*** Cloning complete. ***"
|
25 |
+
# --- END: Clone SillyTavern Core ---
|
26 |
+
|
27 |
+
# --- BEGIN: Remove root .gitignore if exists ---
|
28 |
+
RUN \
|
29 |
+
echo "*** Attempting to remove root .gitignore if it exists ***" && \
|
30 |
+
rm -f .gitignore && \
|
31 |
+
echo "*** Root .gitignore removed (if it existed). ***"
|
32 |
+
# --- END: Remove root .gitignore ---
|
33 |
+
|
34 |
+
# Install base SillyTavern dependencies (package*.json should be in the cloned root)
|
35 |
+
RUN \
|
36 |
+
echo "*** Install Base npm packages ***" && \
|
37 |
+
if [ -f package.json ]; then \
|
38 |
+
# Added --force to potentially overcome file system issues in docker/overlayfs
|
39 |
+
npm i --no-audit --no-fund --loglevel=error --no-progress --omit=dev --force && npm cache clean --force; \
|
40 |
+
else \
|
41 |
+
echo "No package.json found in root, skipping base npm install."; \
|
42 |
+
fi
|
43 |
+
|
44 |
+
# Go back to the main app directory (redundant but safe)
|
45 |
+
WORKDIR ${APP_HOME}
|
46 |
+
|
47 |
+
# Create config directory. config.yaml will be handled at runtime by ENTRYPOINT
|
48 |
+
RUN mkdir -p config
|
49 |
+
|
50 |
+
# Pre-compile public libraries (build-lib.js should be in the unzipped structure)
|
51 |
+
RUN \
|
52 |
+
echo "*** Run Webpack ***" && \
|
53 |
+
# Check if build-lib.js exists before running
|
54 |
+
if [ -f "./docker/build-lib.js" ]; then \
|
55 |
+
node "./docker/build-lib.js"; \
|
56 |
+
elif [ -f "./build-lib.js" ]; then \
|
57 |
+
node "./build-lib.js"; \
|
58 |
+
else \
|
59 |
+
echo "build-lib.js not found, skipping Webpack build."; \
|
60 |
+
fi
|
61 |
+
|
62 |
+
# Cleanup unnecessary files (like the docker dir if it exists in the zip) and make entrypoint executable
|
63 |
+
# This block is removed as we no longer use docker-entrypoint.sh
|
64 |
+
# RUN \
|
65 |
+
# echo "*** Cleanup and Permissions ***" && \
|
66 |
+
# ...
|
67 |
+
|
68 |
+
# Fix potential git safe.directory issues if git commands are run later by scripts
|
69 |
+
RUN git config --global --add safe.directory "${APP_HOME}"
|
70 |
+
|
71 |
+
# Ensure the node user owns the application directory and its contents
|
72 |
+
RUN chown -R node:node ${APP_HOME}
|
73 |
+
|
74 |
+
EXPOSE 8000
|
75 |
+
|
76 |
+
# Entrypoint: Read config from environment variable CONFIG_YAML if set, copy default if not, configure git, then run node server.js directly
|
77 |
+
ENTRYPOINT ["tini", "--", "sh", "-c", " \
|
78 |
+
# --- BEGIN: Update SillyTavern Core at Runtime --- \
|
79 |
+
echo '--- Attempting to update SillyTavern Core from GitHub (staging branch) ---'; \
|
80 |
+
if [ -d \".git\" ] && [ \"$(git rev-parse --abbrev-ref HEAD)\" = \"staging\" ]; then \
|
81 |
+
echo 'Existing staging branch found. Resetting and pulling latest changes...'; \
|
82 |
+
git reset --hard HEAD && \
|
83 |
+
git pull origin staging || echo 'WARN: git pull failed, continuing with code from build time.'; \
|
84 |
+
echo '--- SillyTavern Core update check finished. ---'; \
|
85 |
+
else \
|
86 |
+
echo 'WARN: .git directory not found or not on staging branch. Skipping runtime update. Code from build time will be used.'; \
|
87 |
+
fi; \
|
88 |
+
# --- END: Update SillyTavern Core at Runtime --- \
|
89 |
+
|
90 |
+
echo '--- Checking for CONFIG_YAML environment variable ---'; \
|
91 |
+
# Ensure the CWD has correct permissions for writing config.yaml
|
92 |
+
# mkdir -p ./config && chown node:node ./config; # Removed mkdir
|
93 |
+
if [ -n \"$CONFIG_YAML\" ]; then \
|
94 |
+
echo 'Environment variable CONFIG_YAML found. Writing to ./config.yaml (root directory)...'; \
|
95 |
+
# Write directly to ./config.yaml in the CWD
|
96 |
+
printf '%s\n' \"$CONFIG_YAML\" > ./config.yaml && \
|
97 |
+
chown node:node ./config.yaml && \
|
98 |
+
echo 'Config written to ./config.yaml and permissions set successfully.'; \
|
99 |
+
# --- BEGIN DEBUG: Print the written config file ---
|
100 |
+
echo '--- Verifying written ./config.yaml ---'; \
|
101 |
+
cat ./config.yaml; \
|
102 |
+
echo '--- End of ./config.yaml ---'; \
|
103 |
+
# --- END DEBUG ---
|
104 |
+
else \
|
105 |
+
echo 'Warning: Environment variable CONFIG_YAML is not set or empty. Attempting to copy default config...'; \
|
106 |
+
# Copy default if ENV VAR is missing and the example exists
|
107 |
+
if [ -f \"./public/config.yaml.example\" ]; then \
|
108 |
+
# Copy default to ./config.yaml in the CWD
|
109 |
+
cp \"./public/config.yaml.example\" \"./config.yaml\" && \
|
110 |
+
chown node:node ./config.yaml && \
|
111 |
+
echo 'Copied default config to ./config.yaml'; \
|
112 |
+
else \
|
113 |
+
echo 'Warning: Default config ./public/config.yaml.example not found.'; \
|
114 |
+
fi; \
|
115 |
+
fi; \
|
116 |
+
|
117 |
+
# --- BEGIN: Configure Git default identity at Runtime --- \
|
118 |
+
echo '--- Configuring Git default user identity at runtime ---'; \
|
119 |
+
git config --global user.name \"SillyTavern Sync\" && \
|
120 |
+
git config --global user.email \"[email protected]\"; \
|
121 |
+
echo '--- Git identity configured for runtime user. ---'; \
|
122 |
+
# --- END: Configure Git default identity at Runtime --- \
|
123 |
+
|
124 |
+
# --- BEGIN: Dynamically Install Plugins at Runtime --- \
|
125 |
+
echo '--- Checking for PLUGINS environment variable ---'; \
|
126 |
+
if [ -n \"$PLUGINS\" ]; then \
|
127 |
+
echo \"*** Installing Plugins specified in PLUGINS environment variable: $PLUGINS ***\" && \
|
128 |
+
# Ensure plugins directory exists
|
129 |
+
mkdir -p ./plugins && chown node:node ./plugins && \
|
130 |
+
# Set comma as delimiter
|
131 |
+
IFS=',' && \
|
132 |
+
# Loop through each plugin URL
|
133 |
+
for plugin_url in $PLUGINS; do \
|
134 |
+
# Trim leading/trailing whitespace
|
135 |
+
plugin_url=$(echo \"$plugin_url\" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') && \
|
136 |
+
if [ -z \"$plugin_url\" ]; then continue; fi && \
|
137 |
+
# Extract plugin name
|
138 |
+
plugin_name_git=$(basename \"$plugin_url\") && \
|
139 |
+
plugin_name=${plugin_name_git%.git} && \
|
140 |
+
plugin_dir=\"./plugins/$plugin_name\" && \
|
141 |
+
echo \"--- Installing plugin: $plugin_name from $plugin_url into $plugin_dir ---\" && \
|
142 |
+
# Remove existing dir if it exists
|
143 |
+
rm -rf \"$plugin_dir\" && \
|
144 |
+
# Clone the plugin (run as root, fix perms later)
|
145 |
+
git clone --depth 1 \"$plugin_url\" \"$plugin_dir\" && \
|
146 |
+
if [ -f \"$plugin_dir/package.json\" ]; then \
|
147 |
+
echo \"--- Installing dependencies for $plugin_name ---\" && \
|
148 |
+
(cd \"$plugin_dir\" && npm install --no-audit --no-fund --loglevel=error --no-progress --omit=dev --force && npm cache clean --force) || echo \"WARN: Failed to install dependencies for $plugin_name\"; \
|
149 |
+
else \
|
150 |
+
echo \"--- No package.json found for $plugin_name, skipping dependency install. ---\"; \
|
151 |
+
fi || echo \"WARN: Failed to clone $plugin_name from $plugin_url, skipping...\"; \
|
152 |
+
done && \
|
153 |
+
# Reset IFS
|
154 |
+
unset IFS && \
|
155 |
+
# Fix permissions for plugins directory after installation
|
156 |
+
echo \"--- Setting permissions for plugins directory ---\" && \
|
157 |
+
chown -R node:node ./plugins && \
|
158 |
+
echo \"*** Plugin installation finished. ***\"; \
|
159 |
+
else \
|
160 |
+
echo 'PLUGINS environment variable is not set or empty, skipping runtime plugin installation.'; \
|
161 |
+
fi; \
|
162 |
+
# --- END: Dynamically Install Plugins at Runtime --- \
|
163 |
+
|
164 |
+
echo 'Starting SillyTavern server directly...'; \
|
165 |
+
|
166 |
+
# --- BEGIN: Cleanup before start --- \
|
167 |
+
# Remove .gitignore
|
168 |
+
echo 'Attempting final removal of .gitignore...' && \
|
169 |
+
rm -f .gitignore && \
|
170 |
+
if [ ! -e .gitignore ]; then \
|
171 |
+
echo '.gitignore successfully removed.'; \
|
172 |
+
else \
|
173 |
+
# This case is unlikely with rm -f unless permissions prevent removal
|
174 |
+
echo 'WARN: .gitignore could not be removed or reappeared.'; \
|
175 |
+
fi; \
|
176 |
+
# Remove .git directory
|
177 |
+
echo 'Attempting final removal of .git directory...' && \
|
178 |
+
rm -rf .git && \
|
179 |
+
if [ ! -d .git ]; then \
|
180 |
+
echo '.git directory successfully removed.'; \
|
181 |
+
else \
|
182 |
+
# This case usually indicates a permission issue
|
183 |
+
echo 'WARN: .git directory could not be removed.'; \
|
184 |
+
fi; \
|
185 |
+
# --- END: Cleanup before start --- \
|
186 |
+
|
187 |
+
# Execute node server directly, bypassing docker-entrypoint.sh
|
188 |
+
exec node server.js; \
|
189 |
+
"]
|
README.md
CHANGED
@@ -1,11 +1,230 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
colorFrom: pink
|
5 |
-
colorTo:
|
6 |
sdk: docker
|
7 |
pinned: false
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
---
|
10 |
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: SillyTavern Docker & HF部署
|
3 |
+
emoji: 🥂
|
4 |
colorFrom: pink
|
5 |
+
colorTo: blue
|
6 |
sdk: docker
|
7 |
pinned: false
|
8 |
+
app_port: 8000 # SillyTavern 默认端口
|
9 |
+
# 定义所需的 Hugging Face Secrets
|
10 |
+
secrets:
|
11 |
+
- name: CONFIG_YAML
|
12 |
+
description: "你的 config.yaml 文件内容(无注释)"
|
13 |
+
required: true # 配置是必需的
|
14 |
+
- name: PLUGINS
|
15 |
+
description: "要安装的插件Git URL列表(逗号分隔)"
|
16 |
+
required: false # 插件是可选的
|
17 |
---
|
18 |
|
19 |
+
# SillyTavern Docker 与 Hugging Face 部署指南
|
20 |
+
|
21 |
+
本指南说明了如何使用提供的 `Dockerfile` 来构建和运行 SillyTavern,以及如何在 Hugging Face Spaces 上进行部署。部署的核心思想是通过环境变量在容器启动时动态配置 SillyTavern 和安装插件。
|
22 |
+
|
23 |
+
## 关键文件
|
24 |
+
|
25 |
+
* `Dockerfile`: 用于构建 SillyTavern 运行环境的 Docker 镜像。它会:
|
26 |
+
* 基于官方 Node.js Alpine 镜像。
|
27 |
+
* 安装必要的系统依赖(如 `git`)。
|
28 |
+
* 从 GitHub 克隆 SillyTavern 的 `staging` 分支代码。
|
29 |
+
* 设置工作目录和用户权限。
|
30 |
+
* 定义容器启动时的 `ENTRYPOINT` 脚本,该脚本负责:
|
31 |
+
* 读取 `CONFIG_YAML` 环境变量并写入 `./config.yaml` 文件。
|
32 |
+
* 读取 `PLUGINS` 环境变量,并克隆、安装指定的插件。
|
33 |
+
* 启动 SillyTavern 服务器 (`node server.js`)。
|
34 |
+
* `README.md`: 本说明文件。
|
35 |
+
|
36 |
+
## 配置方式:环境变量
|
37 |
+
|
38 |
+
我们通过两个主要的环境变量来配置容器:
|
39 |
+
|
40 |
+
1. `CONFIG_YAML`: **必需**。
|
41 |
+
* **作用**: 定义 SillyTavern 的运行配置。
|
42 |
+
* **内容**: 下面是推荐的默认配置内容。你可以直接复制粘贴使用,但**强烈建议你修改其中的认证信息**。
|
43 |
+
* **推荐配置内容**:
|
44 |
+
```yaml
|
45 |
+
dataRoot: ./data
|
46 |
+
listen: true
|
47 |
+
listenAddress:
|
48 |
+
ipv4: 0.0.0.0
|
49 |
+
ipv6: '[::]'
|
50 |
+
protocol:
|
51 |
+
ipv4: true
|
52 |
+
ipv6: false
|
53 |
+
dnsPreferIPv6: false
|
54 |
+
autorunHostname: "auto"
|
55 |
+
port: 8000
|
56 |
+
autorunPortOverride: -1
|
57 |
+
ssl:
|
58 |
+
enabled: false
|
59 |
+
certPath: "./certs/cert.pem"
|
60 |
+
keyPath: "./certs/privkey.pem"
|
61 |
+
whitelistMode: false
|
62 |
+
enableForwardedWhitelist: false
|
63 |
+
whitelist:
|
64 |
+
- ::1
|
65 |
+
- 127.0.0.1
|
66 |
+
whitelistDockerHosts: true
|
67 |
+
basicAuthMode: true
|
68 |
+
basicAuthUser:
|
69 |
+
username: "用户名" # 请务必修改为你自己的用户名
|
70 |
+
password: "密码" # 请务必修改为你自己的密码
|
71 |
+
enableCorsProxy: false
|
72 |
+
requestProxy:
|
73 |
+
enabled: false
|
74 |
+
url: "socks5://username:[email protected]:1080"
|
75 |
+
bypass:
|
76 |
+
- localhost
|
77 |
+
- 127.0.0.1
|
78 |
+
enableUserAccounts: false
|
79 |
+
enableDiscreetLogin: false
|
80 |
+
autheliaAuth: false
|
81 |
+
perUserBasicAuth: false
|
82 |
+
sessionTimeout: -1
|
83 |
+
disableCsrfProtection: false
|
84 |
+
securityOverride: false
|
85 |
+
logging:
|
86 |
+
enableAccessLog: true
|
87 |
+
minLogLevel: 0
|
88 |
+
rateLimiting:
|
89 |
+
preferRealIpHeader: false
|
90 |
+
autorun: false
|
91 |
+
avoidLocalhost: false
|
92 |
+
backups:
|
93 |
+
common:
|
94 |
+
numberOfBackups: 50
|
95 |
+
chat:
|
96 |
+
enabled: true
|
97 |
+
checkIntegrity: true
|
98 |
+
maxTotalBackups: -1
|
99 |
+
throttleInterval: 10000
|
100 |
+
thumbnails:
|
101 |
+
enabled: true
|
102 |
+
format: "jpg"
|
103 |
+
quality: 95
|
104 |
+
dimensions: { 'bg': [160, 90], 'avatar': [96, 144] }
|
105 |
+
performance:
|
106 |
+
lazyLoadCharacters: false
|
107 |
+
memoryCacheCapacity: '100mb'
|
108 |
+
useDiskCache: true
|
109 |
+
allowKeysExposure: false
|
110 |
+
skipContentCheck: false
|
111 |
+
whitelistImportDomains:
|
112 |
+
- localhost
|
113 |
+
- cdn.discordapp.com
|
114 |
+
- files.catbox.moe
|
115 |
+
- raw.githubusercontent.com
|
116 |
+
requestOverrides: []
|
117 |
+
extensions:
|
118 |
+
enabled: true
|
119 |
+
autoUpdate: true
|
120 |
+
models:
|
121 |
+
autoDownload: true
|
122 |
+
classification: Cohee/distilbert-base-uncased-go-emotions-onnx
|
123 |
+
captioning: Xenova/vit-gpt2-image-captioning
|
124 |
+
embedding: Cohee/jina-embeddings-v2-base-en
|
125 |
+
speechToText: Xenova/whisper-small
|
126 |
+
textToSpeech: Xenova/speecht5_tts
|
127 |
+
enableDownloadableTokenizers: true
|
128 |
+
promptPlaceholder: "[Start a new chat]"
|
129 |
+
openai:
|
130 |
+
randomizeUserId: false
|
131 |
+
captionSystemPrompt: ""
|
132 |
+
deepl:
|
133 |
+
formality: default
|
134 |
+
mistral:
|
135 |
+
enablePrefix: false
|
136 |
+
ollama:
|
137 |
+
keepAlive: -1
|
138 |
+
batchSize: -1
|
139 |
+
claude:
|
140 |
+
enableSystemPromptCache: false
|
141 |
+
cachingAtDepth: -1
|
142 |
+
enableServerPlugins: true
|
143 |
+
enableServerPluginsAutoUpdate: false
|
144 |
+
```
|
145 |
+
* **⚠️ 重要警告**: 请务必修改上方配置中 `basicAuthUser` 下的 `username` 和 `password` 为你自己的凭据,以确保安全!**不要使用默认的 "用户名" 和 "密码"!**
|
146 |
+
* **注意**: 必须是有效的 YAML 格式,且**不应包含任何 `#` 开头的注释行**。
|
147 |
+
|
148 |
+
2. `PLUGINS`: **可选**。
|
149 |
+
* **作用**: 指定需要在容器启动时自动安装的 SillyTavern 插件。
|
150 |
+
* **内容**: 一个**逗号分隔**的插件 Git 仓库 URL 列表。
|
151 |
+
* **推荐安装**: 强烈建议安装 `cloud-saves` 插件,以便在不同部署环境(如本地和 Hugging Face)之间同步数据。
|
152 |
+
* **插件地址**: `https://github.com/fuwei99/cloud-saves.git`
|
153 |
+
* **重要前置条件**: 为了让容器/Hugging Face Space 能够拉取你的存档,你**必须**先在你本地的 SillyTavern 中安装好 `cloud-saves` 插件,并**至少进行一次数据存档操作**。这样,远程部署的环境才能通过该插件下载你的存档。
|
154 |
+
* **格式示例**: `https://github.com/fuwei99/cloud-saves.git` (注意包含推荐的 cloud-saves 插件)
|
155 |
+
* **注意**: URL 之间**只能用英文逗号 `,` 分隔**,且逗号前后**不能有空格**。如果留空或不提供此变量,则不会安装额外插件。
|
156 |
+
|
157 |
+
## 方法一:本地 Docker 部署
|
158 |
+
|
159 |
+
你可以在本地使用 Docker 来构建和运行 SillyTavern。
|
160 |
+
|
161 |
+
1. **构建镜像**: 在包含 `Dockerfile` 的目录下,运行:
|
162 |
+
```bash
|
163 |
+
docker build -t sillytavern-local .
|
164 |
+
```
|
165 |
+
将 `sillytavern-local` 替换为你想要的镜像名称。
|
166 |
+
|
167 |
+
2. **准备配置**: 将你的 `config.yaml` 内容(无注释)准备好。
|
168 |
+
|
169 |
+
3. **运行容器**: 使用 `docker run` 命令,并通过 `-e` 参数传递环境变量。
|
170 |
+
* 将上方提供的**推荐配置内容**复制,并作为 `CONFIG_YAML` 环境变量的值。**确保你已经修改了其中的用户名和密码!**
|
171 |
+
* 如果你需要安装插件(**推荐安装 `cloud-saves`**),请准备好插件 URL 列表。
|
172 |
+
|
173 |
+
```bash
|
174 |
+
# 示例:使用推荐配置并安装 cloud-saves 插件
|
175 |
+
# 1. 将推荐配置(修改密码后)保存到名为 config_no_comments.yaml 的文件中
|
176 |
+
# 2. 运行以下命令
|
177 |
+
|
178 |
+
docker run -p 8000:8000 --name my-sillytavern \\
|
179 |
+
-e CONFIG_YAML="$(cat config_no_comments.yaml)" \\
|
180 |
+
-e PLUGINS='https://github.com/fuwei99/cloud-saves.git' \\
|
181 |
+
sillytavern-local
|
182 |
+
|
183 |
+
# 如果你需要安装更多插件,用逗号隔开添加到 PLUGINS 变量中
|
184 |
+
# 例如:
|
185 |
+
# docker run -p 8000:8000 --name my-sillytavern \
|
186 |
+
# -e CONFIG_YAML="$(cat config_no_comments.yaml)" \
|
187 |
+
# -e PLUGINS='https://github.com/fuwei99/cloud-saves.git,https://github.com/user/other-plugin.git' \
|
188 |
+
# sillytavern-local
|
189 |
+
```
|
190 |
+
* `-p 8000:8000`: 将容器的 8000 端口映射到宿主机的 8000 端口。
|
191 |
+
* `--name my-sillytavern`: 为容器命名,方便管理。
|
192 |
+
* `-e CONFIG_YAML="$(cat config_no_comments.yaml)"`: 从文件读取配置内容并传递。这是处理多行 YAML 最可靠的方式。**再次确认:运行前务必修改 `config_no_comments.yaml` 文件中的用户名和密码!**
|
193 |
+
* `-e PLUGINS='...'`: 传递插件列表,这里以安装 `cloud-saves` 为例。
|
194 |
+
|
195 |
+
4. **访问**: 打开浏览器访问 `http://localhost:8000`。
|
196 |
+
|
197 |
+
## 方法二:Hugging Face Spaces 部署
|
198 |
+
|
199 |
+
这是推荐的在线部署方式,利用 Hugging Face 的免费计算资源和 Secrets 管理功能。
|
200 |
+
|
201 |
+
1. **创建 Space**: 在 Hugging Face 上创建一个新的 Space,选择 **Docker** SDK。
|
202 |
+
|
203 |
+
2. **上传文件**: 将本项目中的 `Dockerfile` 和 `README.md` 文件上传到你的 Space 仓库根目录。
|
204 |
+
|
205 |
+
3. **配置 Secrets**: 进入你的 Space 页面的 **Settings -> Secrets** 部分。
|
206 |
+
* **添加 `CONFIG_YAML` Secret**:
|
207 |
+
* 点击 "New secret"。
|
208 |
+
* 名称 (Name) 输入: `CONFIG_YAML`
|
209 |
+
* 值 (Value) 粘贴: **复制上方提供的推荐配置内容**。**再次强调:粘贴前请务必修改 `basicAuthUser` 下的 `username` 和 `password` 为你自己的安全凭据!**
|
210 |
+
* 点击 "Add secret"。
|
211 |
+
* **(推荐) 添加 `PLUGINS` Secret**:
|
212 |
+
* 再次点击 "New secret"。
|
213 |
+
* 名称 (Name) 输入: `PLUGINS`
|
214 |
+
* 值 (Value) 粘贴: 推荐至少包含 `cloud-saves` 插件。例如:`https://github.com/fuwei99/cloud-saves.git`。如果你需要其他插件,用逗号隔开添加,例如:`https://github.com/fuwei99/cloud-saves.git,https://github.com/user/other-plugin.git`。
|
215 |
+
* **重要提醒**: 请确保你已经在本地 SillyTavern 安装了 `cloud-saves` 并至少进行了一次存档。
|
216 |
+
* 点击 "Add secret"。如果你确实不需要任何额外插件,可以跳过这一步。
|
217 |
+
|
218 |
+
4. **构建与启动**: Hugging Face 会自动检测到 `Dockerfile` 和 Secrets,并开始构建镜像、启动容器。你可以在 Space 的 **Logs** 标签页查看构建和启动过程。
|
219 |
+
|
220 |
+
5. **访问**: 构建成功并启动后,通过 Space 提供的公共 URL 访问 SillyTavern 界面。
|
221 |
+
|
222 |
+
## 插件访问
|
223 |
+
|
224 |
+
如果通过 `PLUGINS` 环境变量安装了插件,你需要根据各个插件的说明文档找到访问其界面的路径。
|
225 |
+
|
226 |
+
* 对于推荐安装的 `cloud-saves` 插件,其管理界面通常位于:
|
227 |
+
`http://<你的SillyTavern访问地址>/api/plugins/cloud-saves/ui`
|
228 |
+
例如,如果是本地部署,则为 `http://127.0.0.1:8000/api/plugins/cloud-saves/ui`。如果是 Hugging Face Space,则将 `<你的SillyTavern访问地址>` 替换为你的 Space 公共 URL。
|
229 |
+
|
230 |
+
其他插件的访问路径请参考其各自的文档。
|