Tavern-Docker / Dockerfile
malt666's picture
Upload Dockerfile
9adc675 verified
FROM node:lts-alpine3.19
# Arguments
ARG APP_HOME=/home/node/app
ARG PLUGINS="" # Comma-separated list of plugin git URLs
# 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
RUN apk add --no-cache gcompat tini git unzip wget curl
# 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
# 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}
# Download the health check script from GitHub and place it in the app directory
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
EXPOSE 8000
# Entrypoint: Execute the health check and startup script
ENTRYPOINT ["tini", "--", "/home/node/app/health.sh"]