File size: 3,420 Bytes
f4e3401 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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 |
FROM node:lts-alpine3.19
# Arguments
ARG APP_HOME=/home/node/app
ARG PLUGINS="" # Comma-separated list of plugin git URLs
ARG USERNAME=""
ARG PASSWORD=""
# Install system dependencies
# Add unzip for extracting the application code
# Keep git for potential use by scripts or future plugin updates
# Add wget to download the zip file
# Add curl for health checks and keep-alive
# Add dos2unix to fix CRLF issues
RUN apk add --no-cache gcompat tini git unzip wget curl dos2unix
# Create app directory
WORKDIR ${APP_HOME}
# Set NODE_ENV to production and set credentials from ARGs
ENV NODE_ENV=production
ENV APP_HOME=${APP_HOME}
ENV USERNAME=${USERNAME}
ENV PASSWORD=${PASSWORD}
# --- 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
# Go back to the main app directory (redundant but safe)
WORKDIR ${APP_HOME}
# Create config directory. config.yaml will be handled at runtime by ENTRYPOINT
RUN mkdir -p config
# Pre-compile public libraries (build-lib.js should be in the unzipped structure)
RUN \
echo "*** Run Webpack ***" && \
# Check if build-lib.js exists before running
if [ -f "./docker/build-lib.js" ]; then \
node "./docker/build-lib.js"; \
elif [ -f "./build-lib.js" ]; then \
node "./build-lib.js"; \
else \
echo "build-lib.js not found, skipping Webpack build."; \
fi
# Cleanup unnecessary files (like the docker dir if it exists in the zip) and make entrypoint executable
# This block is removed as we no longer use docker-entrypoint.sh
# RUN \
# echo "*** Cleanup and Permissions ***" && \
# ...
# Fix potential git safe.directory issues if git commands are run later by scripts
RUN git config --global --add safe.directory "${APP_HOME}"
# Ensure the node user owns the application directory and its contents
RUN chown -R node:node ${APP_HOME}
# No longer download external health.sh
# RUN git clone --depth 1 https://github.com/fuwei99/docker-health.sh.git /tmp/health_repo && \
# cp /tmp/health_repo/health.sh ${APP_HOME}/health.sh && \
# rm -rf /tmp/health_repo
# Make the downloaded script executable
# RUN chmod +x ${APP_HOME}/health.sh
# Copy the entrypoint script from the repository
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
# Make the new entrypoint executable
RUN chmod +x /usr/local/bin/entrypoint.sh
EXPOSE 8000
# Entrypoint: Execute the self-contained startup script
ENTRYPOINT ["tini", "--", "/usr/local/bin/entrypoint.sh"] |