Spaces:
Running
Running
Upload Dockerfile
Browse files- Dockerfile +236 -188
Dockerfile
CHANGED
@@ -1,189 +1,237 @@
|
|
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 |
-
|
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 |
"]
|
|
|
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 |
+
# --- BEGIN: Dynamically Install Extensions at Runtime --- \
|
165 |
+
echo '--- Checking for EXTENSIONS environment variable ---'; \
|
166 |
+
if [ -n \"$EXTENSIONS\" ]; then \
|
167 |
+
echo \"*** Installing Extensions specified in EXTENSIONS environment variable: $EXTENSIONS ***\" && \
|
168 |
+
# Determine extension installation directory based on INSTALL_FOR_ALL_USERS
|
169 |
+
if [ \"$INSTALL_FOR_ALL_USERS\" = \"true\" ]; then \
|
170 |
+
ext_install_dir=\"./public/scripts/extensions/third-party\" && \
|
171 |
+
echo \"--- Installing extensions for all users (system-wide) to $ext_install_dir ---\"; \
|
172 |
+
else \
|
173 |
+
ext_install_dir=\"./data/default-user/extensions\" && \
|
174 |
+
echo \"--- Installing extensions for default user only to $ext_install_dir ---\"; \
|
175 |
+
fi && \
|
176 |
+
# Ensure extension directory exists
|
177 |
+
mkdir -p \"$ext_install_dir\" && chown node:node \"$ext_install_dir\" && \
|
178 |
+
# Set comma as delimiter
|
179 |
+
IFS=',' && \
|
180 |
+
# Loop through each extension URL
|
181 |
+
for ext_url in $EXTENSIONS; do \
|
182 |
+
# Trim leading/trailing whitespace
|
183 |
+
ext_url=$(echo \"$ext_url\" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') && \
|
184 |
+
if [ -z \"$ext_url\" ]; then continue; fi && \
|
185 |
+
# Extract extension name
|
186 |
+
ext_name_git=$(basename \"$ext_url\") && \
|
187 |
+
ext_name=${ext_name_git%.git} && \
|
188 |
+
ext_dir=\"$ext_install_dir/$ext_name\" && \
|
189 |
+
echo \"--- Installing extension: $ext_name from $ext_url into $ext_dir ---\" && \
|
190 |
+
# Remove existing dir if it exists
|
191 |
+
rm -rf \"$ext_dir\" && \
|
192 |
+
# Clone the extension (run as root, fix perms later)
|
193 |
+
git clone --depth 1 \"$ext_url\" \"$ext_dir\" && \
|
194 |
+
if [ -f \"$ext_dir/package.json\" ]; then \
|
195 |
+
echo \"--- Installing dependencies for extension $ext_name ---\" && \
|
196 |
+
(cd \"$ext_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 $ext_name\"; \
|
197 |
+
else \
|
198 |
+
echo \"--- No package.json found for extension $ext_name, skipping dependency install. ---\"; \
|
199 |
+
fi || echo \"WARN: Failed to clone extension $ext_name from $ext_url, skipping...\"; \
|
200 |
+
done && \
|
201 |
+
# Reset IFS
|
202 |
+
unset IFS && \
|
203 |
+
# Fix permissions for extensions directory after installation
|
204 |
+
echo \"--- Setting permissions for extensions directory ---\" && \
|
205 |
+
chown -R node:node \"$ext_install_dir\" && \
|
206 |
+
echo \"*** Extension installation finished. ***\"; \
|
207 |
+
else \
|
208 |
+
echo 'EXTENSIONS environment variable is not set or empty, skipping runtime extension installation.'; \
|
209 |
+
fi; \
|
210 |
+
# --- END: Dynamically Install Extensions at Runtime --- \
|
211 |
+
|
212 |
+
echo 'Starting SillyTavern server directly...'; \
|
213 |
+
|
214 |
+
# --- BEGIN: Cleanup before start --- \
|
215 |
+
# Remove .gitignore
|
216 |
+
echo 'Attempting final removal of .gitignore...' && \
|
217 |
+
rm -f .gitignore && \
|
218 |
+
if [ ! -e .gitignore ]; then \
|
219 |
+
echo '.gitignore successfully removed.'; \
|
220 |
+
else \
|
221 |
+
# This case is unlikely with rm -f unless permissions prevent removal
|
222 |
+
echo 'WARN: .gitignore could not be removed or reappeared.'; \
|
223 |
+
fi; \
|
224 |
+
# Remove .git directory
|
225 |
+
echo 'Attempting final removal of .git directory...' && \
|
226 |
+
rm -rf .git && \
|
227 |
+
if [ ! -d .git ]; then \
|
228 |
+
echo '.git directory successfully removed.'; \
|
229 |
+
else \
|
230 |
+
# This case usually indicates a permission issue
|
231 |
+
echo 'WARN: .git directory could not be removed.'; \
|
232 |
+
fi; \
|
233 |
+
# --- END: Cleanup before start --- \
|
234 |
+
|
235 |
+
# Execute node server directly, bypassing docker-entrypoint.sh
|
236 |
+
exec node server.js; \
|
237 |
"]
|