Spaces:
Paused
Paused
Upload 3 files
Browse files- Dockerfile +25 -116
- README.md +390 -230
- entrypoint.sh +336 -0
Dockerfile
CHANGED
|
@@ -3,18 +3,25 @@ FROM node:lts-alpine3.19
|
|
| 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 |
-
|
|
|
|
|
|
|
| 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 \
|
|
@@ -71,119 +78,21 @@ RUN git config --global --add safe.directory "${APP_HOME}"
|
|
| 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:
|
| 77 |
-
ENTRYPOINT ["tini", "--", "sh"
|
| 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 \"sillytavern-sync@example.com\"; \
|
| 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 |
-
"]
|
|
|
|
| 3 |
# Arguments
|
| 4 |
ARG APP_HOME=/home/node/app
|
| 5 |
ARG PLUGINS="" # Comma-separated list of plugin git URLs
|
| 6 |
+
ARG USERNAME=""
|
| 7 |
+
ARG PASSWORD=""
|
| 8 |
|
| 9 |
# Install system dependencies
|
| 10 |
# Add unzip for extracting the application code
|
| 11 |
# Keep git for potential use by scripts or future plugin updates
|
| 12 |
# Add wget to download the zip file
|
| 13 |
+
# Add curl for health checks and keep-alive
|
| 14 |
+
# Add dos2unix to fix CRLF issues
|
| 15 |
+
RUN apk add --no-cache gcompat tini git unzip wget curl dos2unix
|
| 16 |
|
| 17 |
# Create app directory
|
| 18 |
WORKDIR ${APP_HOME}
|
| 19 |
|
| 20 |
+
# Set NODE_ENV to production and set credentials from ARGs
|
| 21 |
ENV NODE_ENV=production
|
| 22 |
+
ENV APP_HOME=${APP_HOME}
|
| 23 |
+
ENV USERNAME=${USERNAME}
|
| 24 |
+
ENV PASSWORD=${PASSWORD}
|
| 25 |
|
| 26 |
# --- BEGIN: Clone SillyTavern Core from GitHub (staging branch) ---
|
| 27 |
RUN \
|
|
|
|
| 78 |
# Ensure the node user owns the application directory and its contents
|
| 79 |
RUN chown -R node:node ${APP_HOME}
|
| 80 |
|
| 81 |
+
# No longer download external health.sh
|
| 82 |
+
# RUN git clone --depth 1 https://github.com/fuwei99/docker-health.sh.git /tmp/health_repo && \
|
| 83 |
+
# cp /tmp/health_repo/health.sh ${APP_HOME}/health.sh && \
|
| 84 |
+
# rm -rf /tmp/health_repo
|
| 85 |
+
|
| 86 |
+
# Make the downloaded script executable
|
| 87 |
+
# RUN chmod +x ${APP_HOME}/health.sh
|
| 88 |
+
|
| 89 |
+
# Copy the entrypoint script from the repository
|
| 90 |
+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
| 91 |
+
|
| 92 |
+
# Make the new entrypoint executable
|
| 93 |
+
RUN chmod +x /usr/local/bin/entrypoint.sh
|
| 94 |
+
|
| 95 |
EXPOSE 8000
|
| 96 |
|
| 97 |
+
# Entrypoint: Execute the self-contained startup script
|
| 98 |
+
ENTRYPOINT ["tini", "--", "/usr/local/bin/entrypoint.sh"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
|
@@ -1,230 +1,390 @@
|
|
| 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 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
*
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
*
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
- name: EXTENSIONS
|
| 18 |
+
description: "要安装的扩展Git URL列表(逗号分隔)"
|
| 19 |
+
required: false # 扩展是可选的
|
| 20 |
+
- name: INSTALL_FOR_ALL_USERS
|
| 21 |
+
description: "扩展安装模式:true为系统级安装,false或其他值为用户级安装"
|
| 22 |
+
required: false # 扩展安装模式是可选的
|
| 23 |
+
- name: REPO_URL
|
| 24 |
+
description: "cloud-saves插件的GitHub仓库URL(用于自动配置)"
|
| 25 |
+
required: false # cloud-saves自动配置是可选的
|
| 26 |
+
- name: GITHUB_TOKEN
|
| 27 |
+
description: "GitHub访问令牌(用于cloud-saves插件自动配置)"
|
| 28 |
+
required: false # cloud-saves自动配置是可选的
|
| 29 |
+
- name: AUTOSAVE_INTERVAL
|
| 30 |
+
description: "cloud-saves插件自动保存间隔(秒)"
|
| 31 |
+
required: false # cloud-saves自动保存配置是可选的
|
| 32 |
+
- name: AUTOSAVE_TARGET_TAG
|
| 33 |
+
description: "cloud-saves插件自动保存目标标签"
|
| 34 |
+
required: false # cloud-saves自动保存配置是可选的
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
# 最简单的方法:一键部署
|
| 38 |
+
## 注意部署界面那个visibility一定要改为public,不然没办法用
|
| 39 |
+
|
| 40 |
+
如果你不想手动配置,可以直接点击下方按钮,一键将 SillyTavern Docker 部署到你自己的 Hugging Face Space 中(需要先注册 Hugging Face 账号):
|
| 41 |
+
|
| 42 |
+
[](https://huggingface.co/spaces/malt666/Tavern-Docker?duplicate=true)
|
| 43 |
+
|
| 44 |
+
点击按钮后,按照下面的格式配置环境变量即可:
|
| 45 |
+
|
| 46 |
+
PLUGINS:https://github.com/fuwei99/cloud-saves.git
|
| 47 |
+
(填写云备份插件链接)
|
| 48 |
+
|
| 49 |
+
CONFIG_YAML:见下方命令行复制,记得改用户名和密码,另外由于hugging face的duplicate(部署)界面有bug,复制下来的也会变成一行,所以只能进入界面之后,在setting下面找到secrets,点击CONFIG_YAML旁边的replace,重新复制粘贴一遍到value那里,这样应该就可以了。
|
| 50 |
+
|
| 51 |
+
EXTENSIONS:https://github.com/N0VI028/JS-Slash-Runner,https://gitee.com/muyoou/st-memory-enhancement
|
| 52 |
+
(填写扩展链接,比如酒馆助手,增强记忆插件,用英语逗号隔开)
|
| 53 |
+
|
| 54 |
+
INSTALL_FOR_ALL_USERS:true
|
| 55 |
+
(设置为false会安装到default-user,设置为true会安装到全局,不填写默认安装到default-user,推荐设置为true)
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
以下是可选secret:
|
| 60 |
+
|
| 61 |
+
REPO_URL:https://github.com/yourusername/yourrepo(填写你的 GitHub 仓库地址,用于 cloud-saves 插件自动配置)
|
| 62 |
+
|
| 63 |
+
GITHUB_TOKEN:ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(填写你的 GitHub 访问令牌,用于 cloud-saves 插件自动配置)
|
| 64 |
+
|
| 65 |
+
AUTOSAVE_INTERVAL:30(填写自动保存间隔分钟,不填写默认为30分)
|
| 66 |
+
|
| 67 |
+
AUTOSAVE_TARGET_TAG:auto-backup(填写自动保存目标标签,不填写默认为空)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
## 如何读取或者保存存档
|
| 71 |
+
|
| 72 |
+
教程见: https://github.com/fuwei99/cloud-saves
|
| 73 |
+
|
| 74 |
+
* 对于推荐安装的 `cloud-saves` 插件,其管理界面通常位于:
|
| 75 |
+
`http://<你的SillyTavern访问地址>/api/plugins/cloud-saves/ui`
|
| 76 |
+
例如,如果是本地部署,则为 `http://127.0.0.1:8000/api/plugins/cloud-saves/ui`。如果是 Hugging Face Space,则将 `<你的SillyTavern访问地址>` 替换为你的 Space 公共 URL
|
| 77 |
+
|
| 78 |
+
其他插件的访问路径请参考其各自的文档。
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
---
|
| 82 |
+
|
| 83 |
+
# SillyTavern Docker 与 Hugging Face 部署指南
|
| 84 |
+
|
| 85 |
+
本指南说明了如何使用提供的 `Dockerfile` 来构建和运行 SillyTavern,以及如何在 Hugging Face Spaces 上进行部署。部署的核心思想是通过环境变量在容器启动时动态配置 SillyTavern 和安装插件。
|
| 86 |
+
|
| 87 |
+
## 关键文件
|
| 88 |
+
|
| 89 |
+
* `Dockerfile`: 用于构建 SillyTavern 运行环境的 Docker 镜像。它会:
|
| 90 |
+
* 基于官方 Node.js Alpine 镜像。
|
| 91 |
+
* 安装必要的系统依赖(如 `git`)。
|
| 92 |
+
* 从 GitHub 克隆 SillyTavern 的 `staging` 分支代码。
|
| 93 |
+
* 设置工作目录和用户权限。
|
| 94 |
+
* 定义容器启动时的 `ENTRYPOINT` 脚本,该脚本负责:
|
| 95 |
+
* 读取 `CONFIG_YAML` 环境变量并写入 `./config.yaml` 文件。
|
| 96 |
+
* 读取 `PLUGINS` 环境变量,并克隆、安装指定的插件。
|
| 97 |
+
* 启动 SillyTavern 服务器 (`node server.js`)。
|
| 98 |
+
* `README.md`: 本说明文件。
|
| 99 |
+
|
| 100 |
+
## 配置方式:环境变量
|
| 101 |
+
|
| 102 |
+
我们通过两个主要的环境变量来配置容器:
|
| 103 |
+
|
| 104 |
+
1. `CONFIG_YAML`: **必需**。
|
| 105 |
+
* **作用**: 定义 SillyTavern 的运行配置。
|
| 106 |
+
* **内容**: 下面是推荐的默认配置内容。你可以直接复制粘贴使用,但**强烈建议你修改其中的认证信息**。
|
| 107 |
+
* **推荐配置内容**:
|
| 108 |
+
```yaml
|
| 109 |
+
dataRoot: ./data
|
| 110 |
+
listen: true
|
| 111 |
+
listenAddress:
|
| 112 |
+
ipv4: 0.0.0.0
|
| 113 |
+
ipv6: '[::]'
|
| 114 |
+
protocol:
|
| 115 |
+
ipv4: true
|
| 116 |
+
ipv6: false
|
| 117 |
+
dnsPreferIPv6: false
|
| 118 |
+
autorunHostname: "auto"
|
| 119 |
+
port: 8000
|
| 120 |
+
autorunPortOverride: -1
|
| 121 |
+
ssl:
|
| 122 |
+
enabled: false
|
| 123 |
+
certPath: "./certs/cert.pem"
|
| 124 |
+
keyPath: "./certs/privkey.pem"
|
| 125 |
+
whitelistMode: false
|
| 126 |
+
enableForwardedWhitelist: false
|
| 127 |
+
whitelist:
|
| 128 |
+
- ::1
|
| 129 |
+
- 127.0.0.1
|
| 130 |
+
whitelistDockerHosts: true
|
| 131 |
+
basicAuthMode: true
|
| 132 |
+
basicAuthUser:
|
| 133 |
+
username: "用户名" # 请务必修改为你自己的用户名
|
| 134 |
+
password: "密码" # 请务必修改为你自己的密码
|
| 135 |
+
enableCorsProxy: false
|
| 136 |
+
requestProxy:
|
| 137 |
+
enabled: false
|
| 138 |
+
url: "socks5://username:password@example.com:1080"
|
| 139 |
+
bypass:
|
| 140 |
+
- localhost
|
| 141 |
+
- 127.0.0.1
|
| 142 |
+
enableUserAccounts: false
|
| 143 |
+
enableDiscreetLogin: false
|
| 144 |
+
autheliaAuth: false
|
| 145 |
+
perUserBasicAuth: false
|
| 146 |
+
sessionTimeout: -1
|
| 147 |
+
disableCsrfProtection: false
|
| 148 |
+
securityOverride: false
|
| 149 |
+
logging:
|
| 150 |
+
enableAccessLog: true
|
| 151 |
+
minLogLevel: 0
|
| 152 |
+
rateLimiting:
|
| 153 |
+
preferRealIpHeader: false
|
| 154 |
+
autorun: false
|
| 155 |
+
avoidLocalhost: false
|
| 156 |
+
backups:
|
| 157 |
+
common:
|
| 158 |
+
numberOfBackups: 50
|
| 159 |
+
chat:
|
| 160 |
+
enabled: true
|
| 161 |
+
checkIntegrity: true
|
| 162 |
+
maxTotalBackups: -1
|
| 163 |
+
throttleInterval: 10000
|
| 164 |
+
thumbnails:
|
| 165 |
+
enabled: true
|
| 166 |
+
format: "jpg"
|
| 167 |
+
quality: 95
|
| 168 |
+
dimensions: { 'bg': [160, 90], 'avatar': [96, 144] }
|
| 169 |
+
performance:
|
| 170 |
+
lazyLoadCharacters: false
|
| 171 |
+
memoryCacheCapacity: '100mb'
|
| 172 |
+
useDiskCache: true
|
| 173 |
+
allowKeysExposure: true
|
| 174 |
+
skipContentCheck: false
|
| 175 |
+
whitelistImportDomains:
|
| 176 |
+
- localhost
|
| 177 |
+
- cdn.discordapp.com
|
| 178 |
+
- files.catbox.moe
|
| 179 |
+
- raw.githubusercontent.com
|
| 180 |
+
requestOverrides: []
|
| 181 |
+
extensions:
|
| 182 |
+
enabled: true
|
| 183 |
+
autoUpdate: false
|
| 184 |
+
models:
|
| 185 |
+
autoDownload: true
|
| 186 |
+
classification: Cohee/distilbert-base-uncased-go-emotions-onnx
|
| 187 |
+
captioning: Xenova/vit-gpt2-image-captioning
|
| 188 |
+
embedding: Cohee/jina-embeddings-v2-base-en
|
| 189 |
+
speechToText: Xenova/whisper-small
|
| 190 |
+
textToSpeech: Xenova/speecht5_tts
|
| 191 |
+
enableDownloadableTokenizers: true
|
| 192 |
+
promptPlaceholder: "[Start a new chat]"
|
| 193 |
+
openai:
|
| 194 |
+
randomizeUserId: false
|
| 195 |
+
captionSystemPrompt: ""
|
| 196 |
+
deepl:
|
| 197 |
+
formality: default
|
| 198 |
+
mistral:
|
| 199 |
+
enablePrefix: false
|
| 200 |
+
ollama:
|
| 201 |
+
keepAlive: -1
|
| 202 |
+
batchSize: -1
|
| 203 |
+
claude:
|
| 204 |
+
enableSystemPromptCache: false
|
| 205 |
+
cachingAtDepth: -1
|
| 206 |
+
enableServerPlugins: true
|
| 207 |
+
enableServerPluginsAutoUpdate: false
|
| 208 |
+
```
|
| 209 |
+
* **⚠️ 重要警告**: 请务必修改上方配置中 `basicAuthUser` 下的 `username` 和 `password` 为你自己的凭据,以确保安全!**不要使用默认的 "用户名" 和 "密码"!**
|
| 210 |
+
* **注意**: 必须是有效的 YAML 格式,且**不应包含任何 `#` 开头的注释行**。
|
| 211 |
+
|
| 212 |
+
2. `PLUGINS`: **可选**。
|
| 213 |
+
* **作用**: 指定需要在容器启动时自动安装的 SillyTavern 插件。
|
| 214 |
+
* **内容**: 一个**逗号分隔**的插件 Git 仓库 URL 列表。
|
| 215 |
+
* **推荐安装**: 强烈建议安装 `cloud-saves` 插件,以便在不同部署环境(如本地和 Hugging Face)之间同步数据。
|
| 216 |
+
* **插件地址**: `https://github.com/fuwei99/cloud-saves.git`
|
| 217 |
+
* **重要前置条件**: 为了让容器/Hugging Face Space 能够拉取你的存档,你**必须**先在你本地的 SillyTavern 中安装好 `cloud-saves` 插件,并**至少进行一次数据存档操作**。这样,远程部署的环境才能通过该插件下载你的存档。
|
| 218 |
+
* **格式示例**: `https://github.com/fuwei99/cloud-saves.git` (注意包含推荐的 cloud-saves 插件)
|
| 219 |
+
* **注意**: URL 之间**只能用英文逗号 `,` 分隔**,且逗号前后**不能有空格**。如果留空或不提供此变量,则不会安装额外插件。
|
| 220 |
+
|
| 221 |
+
3. `EXTENSIONS`: **可选**。
|
| 222 |
+
* **作用**: 指定需要在容器启动时自动安装的 SillyTavern 扩展(Extensions)。
|
| 223 |
+
* **内容**: 一个**逗号分隔**的扩展 Git 仓库 URL 列表。
|
| 224 |
+
* **安装时机**: 扩展会在项目启动之后自动安装,确保 SillyTavern 目录结构已经准备完毕。
|
| 225 |
+
* **格式示例**: `https://github.com/user1/extension1.git,https://github.com/user2/extension2.git`
|
| 226 |
+
* **注意**: URL 之间**只能用英文逗号 `,` 分隔**,且逗号前后**不能有空格**。如果留空或不提供此变量,则不会安装额外扩展。
|
| 227 |
+
|
| 228 |
+
4. `INSTALL_FOR_ALL_USERS`: **可选**。
|
| 229 |
+
* **作用**: 控制扩展的安装位置模式。
|
| 230 |
+
* **可选值**:
|
| 231 |
+
* `true`: 扩展安装到 `public/scripts/extensions/third-party` 目录下,对**所有用户**生效(系统级安装)。
|
| 232 |
+
* `false` 或任何其他值,或变量不存在: 扩展安装到 `data/default-user/extensions` 目录下,仅对**默认用户**生效(用户级安装)。
|
| 233 |
+
* **默认行为**: 如果不设置此环境变量,默认安装到用户级目录。
|
| 234 |
+
* **格式示例**: `true` 或 `false`
|
| 235 |
+
|
| 236 |
+
5. `REPO_URL`: **可选**。
|
| 237 |
+
* **作用**: 为 cloud-saves 插件提供 GitHub 仓库 URL,用于自动配置插件。
|
| 238 |
+
* **前置条件**: 需要同时安装 cloud-saves 插件(通过 `PLUGINS` 环境变量)。
|
| 239 |
+
* **格式示例**: `https://github.com/yourusername/yourrepo`
|
| 240 |
+
* **说明**: 这是你用来存储 SillyTavern 数据备份的 GitHub 仓库地址。
|
| 241 |
+
|
| 242 |
+
6. `GITHUB_TOKEN`: **可选**。
|
| 243 |
+
* **作用**: 为 cloud-saves 插件提供 GitHub 访问令牌,用于自动配置插件。
|
| 244 |
+
* **前置条件**: 需要同时设置 `REPO_URL` 和安装 cloud-saves 插件。
|
| 245 |
+
* **格式示例**: `ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
|
| 246 |
+
* **获取方式**: 在 GitHub Settings -> Developer settings -> Personal access tokens -> Tokens (classic) 中创建,需要 `repo` 权限。
|
| 247 |
+
* **自动配置**: 如果同时提供了 `REPO_URL` 和 `GITHUB_TOKEN`,且安装了 cloud-saves 插件,系统会自动创建插件的配置文件。
|
| 248 |
+
|
| 249 |
+
7. `AUTOSAVE_INTERVAL`: **可选**。
|
| 250 |
+
* **作用**: 设置 cloud-saves 插件的自动保存间隔时间(秒)。
|
| 251 |
+
* **前置条件**: 需要同时设置 `REPO_URL` 和 `GITHUB_TOKEN`。
|
| 252 |
+
* **格式示例**: `30`(表示每30秒自动保存一次)
|
| 253 |
+
* **默认值**: 如果不设置,默认为 `30` 秒。
|
| 254 |
+
|
| 255 |
+
8. `AUTOSAVE_TARGET_TAG`: **可选**。
|
| 256 |
+
* **作用**: 设置 cloud-saves 插件的自动保存目标标签。
|
| 257 |
+
* **前置条件**: 需要同时设置 `REPO_URL` 和 `GITHUB_TOKEN`。
|
| 258 |
+
* **格式示例**: `auto-backup` 或 `daily-save`
|
| 259 |
+
* **默认值**: 如果不设置,默认为空字符串。
|
| 260 |
+
|
| 261 |
+
## 方法一:本地 Docker 部署
|
| 262 |
+
|
| 263 |
+
你可以在本地使用 Docker 来构建和运行 SillyTavern。
|
| 264 |
+
|
| 265 |
+
1. **构建镜像**: 在包含 `Dockerfile` 的目录下,运行:
|
| 266 |
+
```bash
|
| 267 |
+
docker build -t sillytavern-local .
|
| 268 |
+
```
|
| 269 |
+
将 `sillytavern-local` 替换为你想要的镜像名称。
|
| 270 |
+
|
| 271 |
+
2. **准备配置**: 将你的 `config.yaml` 内容(无注释)准备好。
|
| 272 |
+
|
| 273 |
+
3. **运行容器**: 使用 `docker run` 命令,并通过 `-e` 参数传递环境变量。
|
| 274 |
+
* 将上方提供的**推荐配置内容**复制,并作为 `CONFIG_YAML` 环境变量的值。**确保你已经修改了其中的用户名和密码!**
|
| 275 |
+
* 如果你需要安装插件(**推荐安装 `cloud-saves`**),请准备好插件 URL 列表。
|
| 276 |
+
|
| 277 |
+
```bash
|
| 278 |
+
# 示例:使用推荐配置并安装 cloud-saves 插件
|
| 279 |
+
# 1. 将推荐配置(修改密码后)保存到名为 config_no_comments.yaml 的文件中
|
| 280 |
+
# 2. 运行以下命令
|
| 281 |
+
|
| 282 |
+
docker run -p 8000:8000 --name my-sillytavern \\
|
| 283 |
+
-e CONFIG_YAML="$(cat config_no_comments.yaml)" \\
|
| 284 |
+
-e PLUGINS='https://github.com/fuwei99/cloud-saves.git' \\
|
| 285 |
+
-e EXTENSIONS='https://github.com/user1/extension1.git,https://github.com/user2/extension2.git' \\
|
| 286 |
+
-e INSTALL_FOR_ALL_USERS=false \\
|
| 287 |
+
-e REPO_URL='https://github.com/yourusername/yourrepo' \\
|
| 288 |
+
-e GITHUB_TOKEN='ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \\
|
| 289 |
+
-e AUTOSAVE_INTERVAL=30 \\
|
| 290 |
+
-e AUTOSAVE_TARGET_TAG=auto-backup \\
|
| 291 |
+
sillytavern-local
|
| 292 |
+
|
| 293 |
+
# 如果你需要安装更多插件,用逗号隔开添加到 PLUGINS 变量中
|
| 294 |
+
# 例如:
|
| 295 |
+
# docker run -p 8000:8000 --name my-sillytavern \
|
| 296 |
+
# -e CONFIG_YAML="$(cat config_no_comments.yaml)" \
|
| 297 |
+
# -e PLUGINS='https://github.com/fuwei99/cloud-saves.git,https://github.com/user/other-plugin.git' \
|
| 298 |
+
# -e EXTENSIONS='https://github.com/user1/extension1.git,https://github.com/user2/extension2.git' \
|
| 299 |
+
# -e INSTALL_FOR_ALL_USERS=false \
|
| 300 |
+
# -e REPO_URL='https://github.com/yourusername/yourrepo' \
|
| 301 |
+
# -e GITHUB_TOKEN='ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
|
| 302 |
+
# -e AUTOSAVE_INTERVAL=30 \
|
| 303 |
+
# -e AUTOSAVE_TARGET_TAG=auto-backup \
|
| 304 |
+
# sillytavern-local
|
| 305 |
+
```
|
| 306 |
+
* `-p 8000:8000`: 将容器的 8000 端口映射到宿主机的 8000 端口。
|
| 307 |
+
* `--name my-sillytavern`: 为容器命名,方便管理。
|
| 308 |
+
* `-e CONFIG_YAML="$(cat config_no_comments.yaml)"`: 从文件读取配置内容并传递。这是处理多行 YAML 最可靠的方式。**再次确认:运行前务必修改 `config_no_comments.yaml` 文件中的用户名和密码!**
|
| 309 |
+
* `-e PLUGINS='...'`: 传递插件列表,这里以安装 `cloud-saves` 为例。
|
| 310 |
+
* `-e EXTENSIONS='...'`: 传递扩展列表,这里以安装 `extension1` 和 `extension2` 为例。
|
| 311 |
+
* `-e INSTALL_FOR_ALL_USERS=false`: 设置扩展安装模式为用户级安装。
|
| 312 |
+
* `-e REPO_URL='...'`: 传递 REPO_URL 环境变量。
|
| 313 |
+
* `-e GITHUB_TOKEN='...'`: 传递 GITHUB_TOKEN 环境变量。
|
| 314 |
+
* `-e AUTOSAVE_INTERVAL=30`: 设置 AUTOSAVE_INTERVAL 环境变量。
|
| 315 |
+
* `-e AUTOSAVE_TARGET_TAG=auto-backup`: 设置 AUTOSAVE_TARGET_TAG 环境变量。
|
| 316 |
+
|
| 317 |
+
4. **访问**: 打开浏览器访问 `http://localhost:8000`。
|
| 318 |
+
|
| 319 |
+
## 方法二:Hugging Face Spaces 部署
|
| 320 |
+
|
| 321 |
+
这是推荐的在线部署方式,利用 Hugging Face 的免费计算资源和 Secrets 管理功能。
|
| 322 |
+
|
| 323 |
+
1. **创建 Space**: 在 Hugging Face 上创建一个新的 Space,选择 **Docker** SDK。
|
| 324 |
+
|
| 325 |
+
2. **上传文件**: 将本项目中的 `Dockerfile` 和 `README.md` 文件上传到你的 Space 仓库根目录。
|
| 326 |
+
|
| 327 |
+
3. **配置 Secrets**: 进入你的 Space 页面的 **Settings -> Secrets** 部分。
|
| 328 |
+
* **添加 `CONFIG_YAML` Secret**:
|
| 329 |
+
* 点击 "New secret"。
|
| 330 |
+
* 名称 (Name) 输入: `CONFIG_YAML`
|
| 331 |
+
* 值 (Value) 粘贴: **复制上方提供的推荐配置内容**。**再次强调:粘贴前请务必修改 `basicAuthUser` 下的 `username` 和 `password` 为你自己的安全凭据!**
|
| 332 |
+
* 点击 "Add secret"。
|
| 333 |
+
* **(推荐) 添加 `PLUGINS` Secret**:
|
| 334 |
+
* 再次点击 "New secret"。
|
| 335 |
+
* 名称 (Name) 输入: `PLUGINS`
|
| 336 |
+
* 值 (Value) 粘贴: 推荐至少包含 `cloud-saves` 插件。例如:`https://github.com/fuwei99/cloud-saves.git`。如果你需要其他插件,用逗号隔开添加,例如:`https://github.com/fuwei99/cloud-saves.git,https://github.com/user/other-plugin.git`。
|
| 337 |
+
* **重要提醒**: 请确保你已经在本地 SillyTavern 安装了 `cloud-saves` 并至少进行了一次存档。
|
| 338 |
+
* 点击 "Add secret"。如果你确实不需要任何额外插件,可以跳过这一步。
|
| 339 |
+
|
| 340 |
+
* **(可选) 添加 `EXTENSIONS` Secret**:
|
| 341 |
+
* 再次点击 "New secret"。
|
| 342 |
+
* 名称 (Name) 输入: `EXTENSIONS`
|
| 343 |
+
* 值 (Value) 粘贴: 你需要安装的扩展 Git URL 列表,用逗号隔开。例如:`https://github.com/user1/extension1.git,https://github.com/user2/extension2.git`。
|
| 344 |
+
* 点击 "Add secret"。如果你不需要安装扩展,可以跳过这一步。
|
| 345 |
+
|
| 346 |
+
* **(可选) 添加 `INSTALL_FOR_ALL_USERS` Secret**:
|
| 347 |
+
* 如果你添加了 `EXTENSIONS` Secret,可以继续添加这个 Secret 来控制扩展安装模式。
|
| 348 |
+
* 再次点击 "New secret"。
|
| 349 |
+
* 名称 (Name) 输入: `INSTALL_FOR_ALL_USERS`
|
| 350 |
+
* 值 (Value) 输入: `true`(系统级安装,所有用户可用)或 `false`(用户级安装,仅默认用户可用)。
|
| 351 |
+
* **推荐**: 对于 Hugging Face Space 单用户环境,建议设置为 `false` 或不设置此 Secret。
|
| 352 |
+
* 点击 "Add secret"。如果不设置,默认为用户级安装。
|
| 353 |
+
|
| 354 |
+
* **(可选) 添加 `REPO_URL` Secret**:
|
| 355 |
+
* 再次点击 "New secret"。
|
| 356 |
+
* 名称 (Name) 输入: `REPO_URL`
|
| 357 |
+
* 值 (Value) 输入: 你的 GitHub 仓库地址,用于 cloud-saves 插件自动配置。例如:`https://github.com/yourusername/yourrepo`
|
| 358 |
+
* 点击 "Add secret"。
|
| 359 |
+
|
| 360 |
+
* **(可选) 添加 `GITHUB_TOKEN` Secret**:
|
| 361 |
+
* 再次点击 "New secret"。
|
| 362 |
+
* 名称 (Name) 输入: `GITHUB_TOKEN`
|
| 363 |
+
* 值 (Value) 输入: 你的 GitHub 访问令牌,用于 cloud-saves 插件自动配置。例如:`ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
|
| 364 |
+
* 点击 "Add secret"。
|
| 365 |
+
|
| 366 |
+
* **(可选) 添加 `AUTOSAVE_INTERVAL` Secret**:
|
| 367 |
+
* 再次点击 "New secret"。
|
| 368 |
+
* 名称 (Name) 输入: `AUTOSAVE_INTERVAL`
|
| 369 |
+
* 值 (Value) 输入: 自动保存间隔秒数,不填写默认为30秒
|
| 370 |
+
* 点击 "Add secret"。
|
| 371 |
+
|
| 372 |
+
* **(可选) 添加 `AUTOSAVE_TARGET_TAG` Secret**:
|
| 373 |
+
* 再次点击 "New secret"。
|
| 374 |
+
* 名称 (Name) 输入: `AUTOSAVE_TARGET_TAG`
|
| 375 |
+
* 值 (Value) 输入: 自动保存目标标签,不填写默认为空
|
| 376 |
+
* 点击 "Add secret"。
|
| 377 |
+
|
| 378 |
+
4. **构建与启动**: Hugging Face 会自动检测到 `Dockerfile` 和 Secrets,并开始构建镜像、启动容器。你可以在 Space 的 **Logs** 标签页查看构建和启动过程。
|
| 379 |
+
|
| 380 |
+
5. **访问**: 构建成功并启动后,通过 Space 提供的公共 URL 访问 SillyTavern 界面。
|
| 381 |
+
|
| 382 |
+
## 插件访问
|
| 383 |
+
|
| 384 |
+
如果通过 `PLUGINS` 环境变量安装了插件,你需要根据各个插件的说明文档找到访问其界面的路径。
|
| 385 |
+
|
| 386 |
+
* 对于推荐安装的 `cloud-saves` 插件,其管理界面通常位于:
|
| 387 |
+
`http://<你的SillyTavern访问地址>/api/plugins/cloud-saves/ui`
|
| 388 |
+
例如,如果是本地部署,则为 `http://127.0.0.1:8000/api/plugins/cloud-saves/ui`。如果是 Hugging Face Space,则将 `<你的SillyTavern访问地址>` 替换为你的 Space 公共 URL。
|
| 389 |
+
|
| 390 |
+
其他插件的访问路径请参考其各自的文档。
|
entrypoint.sh
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
CONFIG_FILE="${APP_HOME}/config.yaml"
|
| 5 |
+
|
| 6 |
+
# Priority 1: Use USERNAME/PASSWORD if both are provided
|
| 7 |
+
if [ -n "${USERNAME}" ] && [ -n "${PASSWORD}" ]; then
|
| 8 |
+
echo "--- Basic auth enabled: Creating config.yaml with provided credentials. ---"
|
| 9 |
+
|
| 10 |
+
cat <<EOT > ${CONFIG_FILE}
|
| 11 |
+
dataRoot: ./data
|
| 12 |
+
listen: true
|
| 13 |
+
listenAddress:
|
| 14 |
+
ipv4: 0.0.0.0
|
| 15 |
+
ipv6: '[::]'
|
| 16 |
+
protocol:
|
| 17 |
+
ipv4: true
|
| 18 |
+
ipv6: false
|
| 19 |
+
dnsPreferIPv6: false
|
| 20 |
+
autorunHostname: "auto"
|
| 21 |
+
port: 8000
|
| 22 |
+
autorunPortOverride: -1
|
| 23 |
+
ssl:
|
| 24 |
+
enabled: false
|
| 25 |
+
certPath: "./certs/cert.pem"
|
| 26 |
+
keyPath: "./certs/privkey.pem"
|
| 27 |
+
whitelistMode: false
|
| 28 |
+
enableForwardedWhitelist: false
|
| 29 |
+
whitelist:
|
| 30 |
+
- ::1
|
| 31 |
+
- 127.0.0.1
|
| 32 |
+
whitelistDockerHosts: true
|
| 33 |
+
basicAuthMode: true
|
| 34 |
+
basicAuthUser:
|
| 35 |
+
username: "${USERNAME}"
|
| 36 |
+
password: "${PASSWORD}"
|
| 37 |
+
enableCorsProxy: false
|
| 38 |
+
requestProxy:
|
| 39 |
+
enabled: false
|
| 40 |
+
url: "socks5://username:password@example.com:1080"
|
| 41 |
+
bypass:
|
| 42 |
+
- localhost
|
| 43 |
+
- 127.0.0.1
|
| 44 |
+
enableUserAccounts: false
|
| 45 |
+
enableDiscreetLogin: false
|
| 46 |
+
autheliaAuth: false
|
| 47 |
+
perUserBasicAuth: false
|
| 48 |
+
sessionTimeout: -1
|
| 49 |
+
disableCsrfProtection: false
|
| 50 |
+
securityOverride: false
|
| 51 |
+
logging:
|
| 52 |
+
enableAccessLog: true
|
| 53 |
+
minLogLevel: 0
|
| 54 |
+
rateLimiting:
|
| 55 |
+
preferRealIpHeader: false
|
| 56 |
+
autorun: false
|
| 57 |
+
avoidLocalhost: false
|
| 58 |
+
backups:
|
| 59 |
+
common:
|
| 60 |
+
numberOfBackups: 50
|
| 61 |
+
chat:
|
| 62 |
+
enabled: true
|
| 63 |
+
checkIntegrity: true
|
| 64 |
+
maxTotalBackups: -1
|
| 65 |
+
throttleInterval: 10000
|
| 66 |
+
thumbnails:
|
| 67 |
+
enabled: true
|
| 68 |
+
format: "jpg"
|
| 69 |
+
quality: 95
|
| 70 |
+
dimensions: { 'bg': [160, 90], 'avatar': [96, 144] }
|
| 71 |
+
performance:
|
| 72 |
+
lazyLoadCharacters: false
|
| 73 |
+
memoryCacheCapacity: '100mb'
|
| 74 |
+
useDiskCache: true
|
| 75 |
+
allowKeysExposure: true
|
| 76 |
+
skipContentCheck: false
|
| 77 |
+
whitelistImportDomains:
|
| 78 |
+
- localhost
|
| 79 |
+
- cdn.discordapp.com
|
| 80 |
+
- files.catbox.moe
|
| 81 |
+
- raw.githubusercontent.com
|
| 82 |
+
requestOverrides: []
|
| 83 |
+
extensions:
|
| 84 |
+
enabled: true
|
| 85 |
+
autoUpdate: false
|
| 86 |
+
models:
|
| 87 |
+
autoDownload: true
|
| 88 |
+
classification: Cohee/distilbert-base-uncased-go-emotions-onnx
|
| 89 |
+
captioning: Xenova/vit-gpt2-image-captioning
|
| 90 |
+
embedding: Cohee/jina-embeddings-v2-base-en
|
| 91 |
+
speechToText: Xenova/whisper-small
|
| 92 |
+
textToSpeech: Xenova/speecht5_tts
|
| 93 |
+
enableDownloadableTokenizers: true
|
| 94 |
+
promptPlaceholder: "[Start a new chat]"
|
| 95 |
+
openai:
|
| 96 |
+
randomizeUserId: false
|
| 97 |
+
captionSystemPrompt: ""
|
| 98 |
+
deepl:
|
| 99 |
+
formality: default
|
| 100 |
+
mistral:
|
| 101 |
+
enablePrefix: false
|
| 102 |
+
ollama:
|
| 103 |
+
keepAlive: -1
|
| 104 |
+
batchSize: -1
|
| 105 |
+
claude:
|
| 106 |
+
enableSystemPromptCache: false
|
| 107 |
+
cachingAtDepth: -1
|
| 108 |
+
enableServerPlugins: true
|
| 109 |
+
enableServerPluginsAutoUpdate: false
|
| 110 |
+
EOT
|
| 111 |
+
|
| 112 |
+
# Priority 2: Use CONFIG_YAML if provided (and username/password are not)
|
| 113 |
+
elif [ -n "${CONFIG_YAML}" ]; then
|
| 114 |
+
echo "--- Found CONFIG_YAML, creating config.yaml from environment variable. ---"
|
| 115 |
+
echo "${CONFIG_YAML}" | base64 -d > ${CONFIG_FILE}
|
| 116 |
+
|
| 117 |
+
# Priority 3: No config provided, let the app use its defaults
|
| 118 |
+
else
|
| 119 |
+
echo "--- No user/pass or CONFIG_YAML provided. App will use its default settings. ---"
|
| 120 |
+
fi
|
| 121 |
+
|
| 122 |
+
# --- BEGIN: Update SillyTavern Core at Runtime ---
|
| 123 |
+
echo '--- Attempting to update SillyTavern Core from GitHub (staging branch) ---'
|
| 124 |
+
if [ -d ".git" ] && [ "$(git rev-parse --abbrev-ref HEAD)" = "staging" ]; then
|
| 125 |
+
echo 'Existing staging branch found. Resetting and pulling latest changes...'
|
| 126 |
+
git reset --hard HEAD && \
|
| 127 |
+
git pull origin staging || echo 'WARN: git pull failed, continuing with code from build time.'
|
| 128 |
+
echo '--- SillyTavern Core update check finished. ---'
|
| 129 |
+
else
|
| 130 |
+
echo 'WARN: .git directory not found or not on staging branch. Skipping runtime update. Code from build time will be used.'
|
| 131 |
+
fi
|
| 132 |
+
# --- END: Update SillyTavern Core at Runtime ---
|
| 133 |
+
|
| 134 |
+
# --- BEGIN: Configure Git default identity at Runtime ---
|
| 135 |
+
echo '--- Configuring Git default user identity at runtime ---'
|
| 136 |
+
git config --global user.name "SillyTavern Sync" && \
|
| 137 |
+
git config --global user.email "sillytavern-sync@example.com" && \
|
| 138 |
+
git config --global --add safe.directory "${APP_HOME}/data"
|
| 139 |
+
echo '--- Git identity configured for runtime user. ---'
|
| 140 |
+
# --- END: Configure Git default identity at Runtime ---
|
| 141 |
+
|
| 142 |
+
# --- BEGIN: Dynamically Install Plugins at Runtime ---
|
| 143 |
+
echo '--- Checking for PLUGINS environment variable ---'
|
| 144 |
+
if [ -n "$PLUGINS" ]; then
|
| 145 |
+
echo "*** Installing Plugins specified in PLUGINS environment variable: $PLUGINS ***"
|
| 146 |
+
# Ensure plugins directory exists
|
| 147 |
+
mkdir -p ./plugins && chown node:node ./plugins
|
| 148 |
+
# Set comma as delimiter
|
| 149 |
+
IFS=','
|
| 150 |
+
# Loop through each plugin URL
|
| 151 |
+
for plugin_url in $PLUGINS; do
|
| 152 |
+
# Trim leading/trailing whitespace
|
| 153 |
+
plugin_url=$(echo "$plugin_url" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
| 154 |
+
if [ -z "$plugin_url" ]; then continue; fi
|
| 155 |
+
# Extract plugin name
|
| 156 |
+
plugin_name_git=$(basename "$plugin_url")
|
| 157 |
+
plugin_name=${plugin_name_git%.git}
|
| 158 |
+
plugin_dir="./plugins/$plugin_name"
|
| 159 |
+
echo "--- Installing plugin: $plugin_name from $plugin_url into $plugin_dir ---"
|
| 160 |
+
# Remove existing dir if it exists
|
| 161 |
+
rm -rf "$plugin_dir"
|
| 162 |
+
# Clone the plugin (run as root, fix perms later)
|
| 163 |
+
git clone --depth 1 "$plugin_url" "$plugin_dir"
|
| 164 |
+
if [ -f "$plugin_dir/package.json" ]; then
|
| 165 |
+
echo "--- Installing dependencies for $plugin_name ---"
|
| 166 |
+
(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"
|
| 167 |
+
else
|
| 168 |
+
echo "--- No package.json found for $plugin_name, skipping dependency install. ---"
|
| 169 |
+
fi || echo "WARN: Failed to clone $plugin_name from $plugin_url, skipping..."
|
| 170 |
+
|
| 171 |
+
# Configure cloud-saves plugin if this is the cloud-saves plugin
|
| 172 |
+
if [ "$plugin_name" = "cloud-saves" ]; then
|
| 173 |
+
echo "--- Detected cloud-saves plugin, checking for configuration environment variables ---"
|
| 174 |
+
|
| 175 |
+
# Set default values
|
| 176 |
+
REPO_URL_VALUE=${REPO_URL:-"https://github.com/fuwei99/sillytravern"}
|
| 177 |
+
GITHUB_TOKEN_VALUE=${GITHUB_TOKEN:-""}
|
| 178 |
+
AUTOSAVE_INTERVAL_VALUE=${AUTOSAVE_INTERVAL:-30}
|
| 179 |
+
AUTOSAVE_TARGET_TAG_VALUE=${AUTOSAVE_TARGET_TAG:-""}
|
| 180 |
+
|
| 181 |
+
# Always set autosave to false as required
|
| 182 |
+
AUTOSAVE_ENABLED="false"
|
| 183 |
+
|
| 184 |
+
echo "--- Creating cloud-saves plugin configuration file ---"
|
| 185 |
+
CONFIG_JSON_FILE="$plugin_dir/config.json"
|
| 186 |
+
|
| 187 |
+
# Generate config.json file
|
| 188 |
+
cat <<EOT > ${CONFIG_JSON_FILE}
|
| 189 |
+
{
|
| 190 |
+
"repo_url": "${REPO_URL_VALUE}",
|
| 191 |
+
"branch": "main",
|
| 192 |
+
"username": "cloud-saves",
|
| 193 |
+
"github_token": "${GITHUB_TOKEN_VALUE}",
|
| 194 |
+
"display_name": "",
|
| 195 |
+
"is_authorized": true,
|
| 196 |
+
"last_save": null,
|
| 197 |
+
"current_save": null,
|
| 198 |
+
"has_temp_stash": false,
|
| 199 |
+
"autoSaveEnabled": ${AUTOSAVE_ENABLED},
|
| 200 |
+
"autoSaveInterval": ${AUTOSAVE_INTERVAL_VALUE},
|
| 201 |
+
"autoSaveTargetTag": "${AUTOSAVE_TARGET_TAG_VALUE}"
|
| 202 |
+
}
|
| 203 |
+
EOT
|
| 204 |
+
|
| 205 |
+
# Set correct permissions for config file
|
| 206 |
+
chown node:node ${CONFIG_JSON_FILE}
|
| 207 |
+
|
| 208 |
+
echo "--- cloud-saves plugin configuration file created at: ${CONFIG_JSON_FILE} ---"
|
| 209 |
+
fi
|
| 210 |
+
done
|
| 211 |
+
# Reset IFS
|
| 212 |
+
unset IFS
|
| 213 |
+
# Fix permissions for plugins directory after installation
|
| 214 |
+
echo "--- Setting permissions for plugins directory ---"
|
| 215 |
+
chown -R node:node ./plugins
|
| 216 |
+
echo "*** Plugin installation finished. ***"
|
| 217 |
+
else
|
| 218 |
+
echo 'PLUGINS environment variable is not set or empty, skipping runtime plugin installation.'
|
| 219 |
+
fi
|
| 220 |
+
# --- END: Dynamically Install Plugins at Runtime ---
|
| 221 |
+
|
| 222 |
+
echo "*** Starting SillyTavern... ***"
|
| 223 |
+
node ${APP_HOME}/server.js &
|
| 224 |
+
SERVER_PID=$!
|
| 225 |
+
|
| 226 |
+
echo "SillyTavern server started with PID ${SERVER_PID}. Waiting for it to become responsive..."
|
| 227 |
+
|
| 228 |
+
# --- Health Check Logic ---
|
| 229 |
+
HEALTH_CHECK_URL="http://localhost:8000/"
|
| 230 |
+
CURL_COMMAND="curl -sf"
|
| 231 |
+
|
| 232 |
+
# If basic auth is enabled, provide credentials to curl for health checks
|
| 233 |
+
if [ -n "${USERNAME}" ] && [ -n "${PASSWORD}" ]; then
|
| 234 |
+
echo "--- Health check will use basic auth credentials. ---"
|
| 235 |
+
# The -u flag provides user:password for basic auth
|
| 236 |
+
CURL_COMMAND="curl -sf -u \"${USERNAME}:${PASSWORD}\""
|
| 237 |
+
fi
|
| 238 |
+
|
| 239 |
+
# Health check loop
|
| 240 |
+
RETRY_COUNT=0
|
| 241 |
+
MAX_RETRIES=12 # Wait for 60 seconds max
|
| 242 |
+
# Use eval to correctly execute the command string with quotes
|
| 243 |
+
while ! eval "${CURL_COMMAND} ${HEALTH_CHECK_URL}" > /dev/null; do
|
| 244 |
+
RETRY_COUNT=$((RETRY_COUNT+1))
|
| 245 |
+
if [ ${RETRY_COUNT} -ge ${MAX_RETRIES} ]; then
|
| 246 |
+
echo "SillyTavern failed to start. Exiting."
|
| 247 |
+
kill ${SERVER_PID}
|
| 248 |
+
exit 1
|
| 249 |
+
fi
|
| 250 |
+
echo "SillyTavern is still starting or not responsive on port 8000, waiting 5 seconds..."
|
| 251 |
+
sleep 5
|
| 252 |
+
done
|
| 253 |
+
|
| 254 |
+
echo "SillyTavern started successfully! Beginning periodic keep-alive..."
|
| 255 |
+
|
| 256 |
+
# --- BEGIN: Install Extensions after SillyTavern startup ---
|
| 257 |
+
install_extensions() {
|
| 258 |
+
echo "--- Waiting 40 seconds before installing extensions... ---"
|
| 259 |
+
sleep 40
|
| 260 |
+
|
| 261 |
+
echo "--- Checking for EXTENSIONS environment variable ---"
|
| 262 |
+
if [ -n "$EXTENSIONS" ]; then
|
| 263 |
+
echo "*** Installing Extensions specified in EXTENSIONS environment variable: $EXTENSIONS ***"
|
| 264 |
+
|
| 265 |
+
# Determine installation directory based on INSTALL_FOR_ALL_USERS
|
| 266 |
+
if [ "$INSTALL_FOR_ALL_USERS" = "true" ]; then
|
| 267 |
+
# System-level installation (for all users)
|
| 268 |
+
EXTENSIONS_DIR="./public/scripts/extensions/third-party"
|
| 269 |
+
echo "Installing extensions for all users in: $EXTENSIONS_DIR"
|
| 270 |
+
else
|
| 271 |
+
# User-level installation (for default user only)
|
| 272 |
+
EXTENSIONS_DIR="./data/default-user/extensions"
|
| 273 |
+
echo "Installing extensions for default user in: $EXTENSIONS_DIR"
|
| 274 |
+
fi
|
| 275 |
+
|
| 276 |
+
# Ensure extensions directory exists
|
| 277 |
+
mkdir -p "$EXTENSIONS_DIR" && chown node:node "$EXTENSIONS_DIR"
|
| 278 |
+
|
| 279 |
+
# Set comma as delimiter
|
| 280 |
+
IFS=','
|
| 281 |
+
|
| 282 |
+
# Loop through each extension URL
|
| 283 |
+
for extension_url in $EXTENSIONS; do
|
| 284 |
+
# Trim leading/trailing whitespace
|
| 285 |
+
extension_url=$(echo "$extension_url" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
| 286 |
+
if [ -z "$extension_url" ]; then continue; fi
|
| 287 |
+
|
| 288 |
+
# Extract extension name
|
| 289 |
+
extension_name_git=$(basename "$extension_url")
|
| 290 |
+
extension_name=${extension_name_git%.git}
|
| 291 |
+
extension_dir="$EXTENSIONS_DIR/$extension_name"
|
| 292 |
+
|
| 293 |
+
echo "--- Installing extension: $extension_name from $extension_url into $extension_dir ---"
|
| 294 |
+
|
| 295 |
+
# Remove existing dir if it exists
|
| 296 |
+
rm -rf "$extension_dir"
|
| 297 |
+
|
| 298 |
+
# Clone the extension
|
| 299 |
+
git clone --depth 1 "$extension_url" "$extension_dir"
|
| 300 |
+
|
| 301 |
+
# Check if extension has package.json and install dependencies if needed
|
| 302 |
+
if [ -f "$extension_dir/package.json" ]; then
|
| 303 |
+
echo "--- Installing dependencies for $extension_name ---"
|
| 304 |
+
(cd "$extension_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 $extension_name"
|
| 305 |
+
else
|
| 306 |
+
echo "--- No package.json found for $extension_name, skipping dependency install. ---"
|
| 307 |
+
fi || echo "WARN: Failed to clone $extension_name from $extension_url, skipping..."
|
| 308 |
+
done
|
| 309 |
+
|
| 310 |
+
# Reset IFS
|
| 311 |
+
unset IFS
|
| 312 |
+
|
| 313 |
+
# Fix permissions for extensions directory after installation
|
| 314 |
+
echo "--- Setting permissions for extensions directory ---"
|
| 315 |
+
chown -R node:node "$EXTENSIONS_DIR"
|
| 316 |
+
|
| 317 |
+
echo "*** Extensions installation finished. ***"
|
| 318 |
+
else
|
| 319 |
+
echo 'EXTENSIONS environment variable is not set or empty, skipping extensions installation.'
|
| 320 |
+
fi
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
# Run the extension installation in the background
|
| 324 |
+
install_extensions &
|
| 325 |
+
# --- END: Install Extensions after SillyTavern startup ---
|
| 326 |
+
|
| 327 |
+
# Keep-alive loop
|
| 328 |
+
while kill -0 ${SERVER_PID} 2>/dev/null; do
|
| 329 |
+
echo "Sending keep-alive request to ${HEALTH_CHECK_URL}"
|
| 330 |
+
# Use eval here as well for the keep-alive command
|
| 331 |
+
eval "${CURL_COMMAND} ${HEALTH_CHECK_URL}" > /dev/null || echo "Keep-alive request failed."
|
| 332 |
+
echo "Keep-alive request sent. Sleeping for 30 minutes."
|
| 333 |
+
sleep 1800
|
| 334 |
+
done &
|
| 335 |
+
|
| 336 |
+
wait ${SERVER_PID}
|