mirror of
https://github.com/kodxana/madiator-docker-runpod.git
synced 2024-11-24 03:40:12 +01:00
Added Better Forge Template
This commit is contained in:
parent
bed81abfef
commit
df79a6d19d
6 changed files with 238 additions and 0 deletions
83
official-templates/better-forge/Dockerfile
Normal file
83
official-templates/better-forge/Dockerfile
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
# Stage 1: Base Image
|
||||||
|
FROM madiator2011/better-base:cuda12.1 as base
|
||||||
|
|
||||||
|
ARG PYTHON_VERSION1=3.11
|
||||||
|
|
||||||
|
# Install additional packages
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y pv git rsync libtcmalloc-minimal4 bc && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Stage 2: Forge Installation
|
||||||
|
FROM base as forge-install
|
||||||
|
|
||||||
|
# Create virtual environment with the correct path
|
||||||
|
RUN mkdir -p /workspace && python -m venv /workspace/bforge
|
||||||
|
|
||||||
|
# Set environment variables for the virtual environment
|
||||||
|
ENV VIRTUAL_ENV="/workspace/bforge"
|
||||||
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
|
||||||
|
# Clone Stable Diffusion WebUI Forge and additional repositories
|
||||||
|
RUN git clone https://github.com/lllyasviel/stable-diffusion-webui-forge.git /stable-diffusion-webui-forge && \
|
||||||
|
mkdir -p /stable-diffusion-webui-forge/repositories && \
|
||||||
|
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git /stable-diffusion-webui-forge/repositories/stable-diffusion-webui-assets && \
|
||||||
|
git clone https://github.com/lllyasviel/huggingface_guess.git /stable-diffusion-webui-forge/repositories/huggingface_guess && \
|
||||||
|
git clone https://github.com/salesforce/BLIP.git /stable-diffusion-webui-forge/repositories/BLIP && \
|
||||||
|
rm /stable-diffusion-webui-forge/webui-user.sh
|
||||||
|
|
||||||
|
# Activate the virtual environment and install packages
|
||||||
|
RUN $VIRTUAL_ENV/bin/pip install --upgrade pip setuptools wheel && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install -r /stable-diffusion-webui-forge/requirements_versions.txt && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install -U xformers --index-url https://download.pytorch.org/whl/cu121 && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install accelerate wheel && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install ipykernel ipywidgets && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install "https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip" && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install "https://github.com/mlfoundations/open_clip/archive/bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b.zip" && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install fvcore mediapipe onnxruntime svglib insightface && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install "https://github.com/huchenlei/HandRefinerPortable/releases/download/v1.0.1/handrefinerportable-2024.2.12.0-py2.py3-none-any.whl" && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install "https://github.com/huchenlei/Depth-Anything/releases/download/v1.0.0/depth_anything-2024.1.22.0-py2.py3-none-any.whl" && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install "https://github.com/MackinationsAi/UDAV2-ControlNet/releases/download/v1.0.0/depth_anything_v2-2024.7.1.0-py2.py3-none-any.whl" && \
|
||||||
|
$VIRTUAL_ENV/bin/pip install bitsandbytes==0.43.3 && \
|
||||||
|
$VIRTUAL_ENV/bin/python -m ipykernel install --name "python3" --display-name "Python 3 (Better Forge Venv)"
|
||||||
|
|
||||||
|
# Create tar archive of the virtual environment
|
||||||
|
RUN tar -czf /bforge.tar.gz -C /workspace/bforge .
|
||||||
|
|
||||||
|
# Remove the original venv to save space in the image
|
||||||
|
RUN rm -rf /workspace/bforge
|
||||||
|
|
||||||
|
# Stage 3: Final Image
|
||||||
|
FROM forge-install as final
|
||||||
|
|
||||||
|
# Set environment variables for runtime
|
||||||
|
ENV VIRTUAL_ENV="/workspace/bforge"
|
||||||
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
|
||||||
|
# Copy the README.md
|
||||||
|
COPY README.md /usr/share/nginx/html/README.md
|
||||||
|
|
||||||
|
# NGINX Proxy
|
||||||
|
COPY --from=proxy nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY --from=proxy readme.html /usr/share/nginx/html/readme.html
|
||||||
|
|
||||||
|
# Copy all necessary scripts
|
||||||
|
COPY --from=scripts start.sh /
|
||||||
|
COPY pre_start.sh /pre_start.sh
|
||||||
|
COPY webui-user.sh /stable-diffusion-webui-forge/webui-user.sh
|
||||||
|
RUN chmod +x /start.sh /pre_start.sh /stable-diffusion-webui-forge/webui-user.sh
|
||||||
|
COPY settings.json /root/.local/share/code-server/User/settings.json
|
||||||
|
|
||||||
|
# Copy the tar archive and Stable Diffusion WebUI Forge
|
||||||
|
COPY --from=forge-install /bforge.tar.gz /bforge.tar.gz
|
||||||
|
COPY --from=forge-install /stable-diffusion-webui-forge /stable-diffusion-webui-forge
|
||||||
|
|
||||||
|
# Welcome Message
|
||||||
|
COPY --from=logo runpod.txt /etc/runpod.txt
|
||||||
|
RUN echo 'cat /etc/runpod.txt' >> /root/.bashrc && \
|
||||||
|
echo 'echo -e "\nFor detailed documentation and guides, please visit:\n\033[1;34mhttps://docs.runpod.io/\033[0m and \033[1;34mhttps://blog.runpod.io/\033[0m\n\n"' >> /root/.bashrc
|
||||||
|
|
||||||
|
# CMD
|
||||||
|
CMD [ "/start.sh" ]
|
7
official-templates/better-forge/README.md
Normal file
7
official-templates/better-forge/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
## Build Options
|
||||||
|
|
||||||
|
To build with default options, run `docker buildx bake`, to build a specific target, run `docker buildx bake <target>`.
|
||||||
|
|
||||||
|
## Ports
|
||||||
|
|
||||||
|
- 22/tcp (SSH)
|
17
official-templates/better-forge/docker-bake.hcl
Normal file
17
official-templates/better-forge/docker-bake.hcl
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
group "default" {
|
||||||
|
targets = ["light"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "light" {
|
||||||
|
contexts = {
|
||||||
|
scripts = "../../container-template"
|
||||||
|
proxy = "../../container-template/proxy"
|
||||||
|
logo = "../../container-template"
|
||||||
|
}
|
||||||
|
dockerfile = "Dockerfile"
|
||||||
|
args = {
|
||||||
|
BASE_IMAGE = "madiator2011/better-base:cuda12.1",
|
||||||
|
PYTHON_VERSION = "3.11"
|
||||||
|
}
|
||||||
|
tags = ["madiator2011/better-forge:light"]
|
||||||
|
}
|
64
official-templates/better-forge/pre_start.sh
Normal file
64
official-templates/better-forge/pre_start.sh
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit immediately if a command exits with a non-zero status
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Function to print colorized feedback
|
||||||
|
print_feedback() {
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
echo -e "${GREEN}[Forge Startup]:${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to run rsync with progress bar and optimizations
|
||||||
|
rsync_with_progress() {
|
||||||
|
rsync -aHvx --info=progress2 --ignore-existing --update --stats "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the NO_SYNC variable is set to true
|
||||||
|
if [ "${NO_SYNC}" == "true" ]; then
|
||||||
|
print_feedback "Skipping sync and startup as per environment variable setting."
|
||||||
|
exec bash -c 'sleep infinity'
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_feedback "Starting Forge setup..."
|
||||||
|
|
||||||
|
# Extract the virtual environment if it doesn't exist
|
||||||
|
if [ ! -d "/workspace/bforge" ]; then
|
||||||
|
print_feedback "Extracting virtual environment..."
|
||||||
|
mkdir -p /workspace/bforge
|
||||||
|
tar -xzf /bforge.tar.gz -C /workspace/bforge
|
||||||
|
else
|
||||||
|
print_feedback "Virtual environment already exists, skipping extraction..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Activate the virtual environment
|
||||||
|
source /workspace/bforge/bin/activate
|
||||||
|
|
||||||
|
# Check if Stable Diffusion WebUI Forge exists in the workspace
|
||||||
|
if [ ! -d "/workspace/stable-diffusion-webui-forge" ] || [ -z "$(ls -A /workspace/stable-diffusion-webui-forge)" ]; then
|
||||||
|
print_feedback "Stable Diffusion WebUI Forge not found or empty. Syncing all files..."
|
||||||
|
rsync_with_progress /stable-diffusion-webui-forge/ /workspace/stable-diffusion-webui-forge/
|
||||||
|
print_feedback "Initial sync completed."
|
||||||
|
else
|
||||||
|
print_feedback "Stable Diffusion WebUI Forge found. Skipping sync to preserve user modifications."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Change to the Forge directory
|
||||||
|
cd /workspace/stable-diffusion-webui-forge
|
||||||
|
|
||||||
|
# Modify webui.sh to allow running as root, only if needed
|
||||||
|
print_feedback "Checking webui.sh configuration..."
|
||||||
|
if grep -q "can_run_as_root=0" webui.sh; then
|
||||||
|
print_feedback "Modifying webui.sh to allow running as root..."
|
||||||
|
sed -i 's/can_run_as_root=0/can_run_as_root=1/' webui.sh
|
||||||
|
else
|
||||||
|
print_feedback "webui.sh already configured to run as root or configuration not found."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create logs directory if it doesn't exist
|
||||||
|
mkdir -p /workspace/logs
|
||||||
|
|
||||||
|
# Start webui-user.sh and log output
|
||||||
|
print_feedback "Starting webui-user.sh..."
|
||||||
|
./webui.sh -f > >(tee /workspace/logs/webui.log) 2>&1 &
|
21
official-templates/better-forge/settings.json
Normal file
21
official-templates/better-forge/settings.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"workbench.colorTheme": "Default Dark Modern",
|
||||||
|
"workbench.startupEditor": "none",
|
||||||
|
"workbench.enableExperiments": false,
|
||||||
|
"telemetry.enableTelemetry": false,
|
||||||
|
"telemetry.enableCrashReporter": false,
|
||||||
|
"security.workspace.trust.enabled": false,
|
||||||
|
"update.mode": "manual",
|
||||||
|
"extensions.autoUpdate": false,
|
||||||
|
"python.showStartPage": false,
|
||||||
|
"jupyter.experiments.enabled": false,
|
||||||
|
"jupyter.askForKernelRestart": false,
|
||||||
|
"jupyter.askForKernelSource": false,
|
||||||
|
"jupyter.alwaysTrustNotebooks": true,
|
||||||
|
"extensions.ignoreRecommendations": true,
|
||||||
|
"files.autoSave": "afterDelay",
|
||||||
|
"files.autoSaveDelay": 1000,
|
||||||
|
"python.defaultInterpreterPath": "/workspace/bforge/bin/python",
|
||||||
|
"python.analysis.extraPaths": ["/workspace/bforge/lib/python3.11/site-packages"],
|
||||||
|
"jupyter.notebookFileRoot": "/workspace"
|
||||||
|
}
|
46
official-templates/better-forge/webui-user.sh
Normal file
46
official-templates/better-forge/webui-user.sh
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#########################################################
|
||||||
|
# Uncomment and change the variables below to your need:#
|
||||||
|
#########################################################
|
||||||
|
|
||||||
|
# Install directory without trailing slash
|
||||||
|
export install_dir="/workspace"
|
||||||
|
|
||||||
|
# Name of the subdirectory
|
||||||
|
export clone_dir="stable-diffusion-webui-forge"
|
||||||
|
|
||||||
|
# Commandline arguments for webui.py, for example:
|
||||||
|
export COMMANDLINE_ARGS="--listen --port 7860 --enable-insecure-extension-access --api"
|
||||||
|
|
||||||
|
# python3 executable
|
||||||
|
export python_cmd="python3"
|
||||||
|
|
||||||
|
# git executable
|
||||||
|
export GIT="git"
|
||||||
|
|
||||||
|
# python3 venv without trailing slash (defaults to ${install_dir}/${clone_dir}/venv)
|
||||||
|
export venv_dir="/workspace/bforge"
|
||||||
|
|
||||||
|
# script to launch to start the app
|
||||||
|
#export LAUNCH_SCRIPT="launch.py"
|
||||||
|
|
||||||
|
# install command for torch
|
||||||
|
#export TORCH_COMMAND="pip install torch==1.12.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113"
|
||||||
|
|
||||||
|
# Requirements file to use for stable-diffusion-webui
|
||||||
|
#export REQS_FILE="requirements_versions.txt"
|
||||||
|
|
||||||
|
# Fixed git repos
|
||||||
|
#export K_DIFFUSION_PACKAGE=""
|
||||||
|
#export GFPGAN_PACKAGE=""
|
||||||
|
|
||||||
|
# Fixed git commits
|
||||||
|
#export STABLE_DIFFUSION_COMMIT_HASH=""
|
||||||
|
#export CODEFORMER_COMMIT_HASH=""
|
||||||
|
#export BLIP_COMMIT_HASH=""
|
||||||
|
|
||||||
|
# Uncomment to enable accelerated launch
|
||||||
|
#export ACCELERATE="True"
|
||||||
|
|
||||||
|
# Uncomment to disable TCMalloc
|
||||||
|
#export NO_TCMALLOC="True"
|
Loading…
Reference in a new issue