Spaces:
Paused
Paused
| FROM node:lts-alpine3.19 | |
| # Arguments | |
| ARG APP_HOME=/home/node/app | |
| ARG PLUGINS="" # Comma-separated list of plugin git URLs | |
| # Install system dependencies | |
| # Keep git for cloning | |
| # awk should be available via busybox in alpine | |
| RUN apk add --no-cache gcompat tini git unzip wget | |
| # Create app directory | |
| WORKDIR ${APP_HOME} | |
| # Set NODE_ENV to production | |
| ENV NODE_ENV=production | |
| # --- BEGIN: Clone SillyTavern Core from GitHub (staging branch) --- | |
| RUN \ | |
| echo "*** Cloning SillyTavern Core from GitHub (staging branch) ***" && \ | |
| # Clone the specific branch into the current directory | |
| git clone -b staging --depth 1 https://github.com/SillyTavern/SillyTavern.git . && \ | |
| echo "*** Cloning complete. ***" | |
| # --- END: Clone SillyTavern Core --- | |
| # --- BEGIN: Remove root .gitignore if exists --- | |
| RUN \ | |
| echo "*** Attempting to remove root .gitignore if it exists ***" && \ | |
| rm -f .gitignore && \ | |
| echo "*** Root .gitignore removed (if it existed). ***" | |
| # --- END: Remove root .gitignore --- | |
| # Install base SillyTavern dependencies (package*.json should be in the cloned root) | |
| RUN \ | |
| echo "*** Install Base npm packages ***" && \ | |
| if [ -f package.json ]; then \ | |
| # Added --force to potentially overcome file system issues in docker/overlayfs | |
| npm i --no-audit --no-fund --loglevel=error --no-progress --omit=dev --force && npm cache clean --force; \ | |
| else \ | |
| echo "No package.json found in root, skipping base npm install."; \ | |
| fi | |
| # Pre-compile public libraries (only if build-lib.js exists) | |
| RUN \ | |
| echo "*** Run Webpack (if build-lib.js exists) ***" && \ | |
| if [ -f "./build-lib.js" ]; then \ | |
| node "./build-lib.js"; \ | |
| else \ | |
| echo "build-lib.js not found, skipping Webpack build."; \ | |
| fi | |
| # Ensure the node user owns the application directory and its contents | |
| # Do this before COPYing the script as root | |
| RUN chown -R node:node ${APP_HOME} | |
| # Copy the entrypoint script and set permissions | |
| COPY entrypoint.sh /home/node/app/entrypoint.sh | |
| RUN chown node:node /home/node/app/entrypoint.sh && chmod +x /home/node/app/entrypoint.sh | |
| # Switch to non-root user | |
| USER node | |
| EXPOSE 8000 | |
| # Entrypoint: Use tini to launch the script | |
| ENTRYPOINT ["tini", "--", "/home/node/app/entrypoint.sh"] |