diff --git a/services/AUTOMATIC1111/Dockerfile b/services/AUTOMATIC1111/Dockerfile index 173b356a0..200f27b6d 100644 --- a/services/AUTOMATIC1111/Dockerfile +++ b/services/AUTOMATIC1111/Dockerfile @@ -21,7 +21,7 @@ RUN apk add --no-cache aria2 RUN aria2c -x 5 --dir / --out wheel.whl 'https://github.com/AbdBarho/stable-diffusion-webui-docker/releases/download/6.0.0/xformers-0.0.21.dev544-cp310-cp310-manylinux2014_x86_64-pytorch201.whl' -FROM python:3.10.9-slim +FROM python:3.10.9 ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1 @@ -80,6 +80,13 @@ RUN --mount=type=cache,target=/root/.cache/pip \ COPY . /docker +# Download extensions, install python pip dependencies, then throw extensions away +RUN --mount=type=cache,target=/root/.cache/pip \ + --mount=type=cache,target=/.automatic_extensions_cache \ + apt-get update && apt-get install libgl1 -y && \ + chmod +x /docker/download_automatic1111_extensions.sh && \ + /docker/download_automatic1111_extensions.sh /docker/automatic1111_extensions.txt /.automatic_extensions_cache + RUN \ python3 /docker/info.py ${ROOT}/modules/ui.py && \ mv ${ROOT}/style.css ${ROOT}/user.css && \ diff --git a/services/AUTOMATIC1111/automatic1111_extensions.txt b/services/AUTOMATIC1111/automatic1111_extensions.txt new file mode 100644 index 000000000..eeb58f194 --- /dev/null +++ b/services/AUTOMATIC1111/automatic1111_extensions.txt @@ -0,0 +1,10 @@ +https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris.git b0d24ca645b6a5cb9752169691a1c6385c6fe6ae +https://github.com/AlUlkesh/stable-diffusion-webui-images-browser.git 7da8aec62bc263acd47d76ec9cabdb658b01fc91 +https://github.com/civitai/sd_civitai_extension.git 68a419d1cbf2481fa06ae130d5c0f1e6e7c87f01 +https://github.com/kohya-ss/sd-webui-additional-networks.git e9f3d622b5a98650008a685ea23b27eb810da35a +https://github.com/Mikubill/sd-webui-controlnet.git 2514a460ab9e0c6db38033aed29b12c94d5f1964 +https://github.com/nonnonstop/sd-webui-3d-open-pose-editor.git f2d5aac51d891bc5f266b1549f3cf4495fc52160 +https://github.com/pharmapsychotic/clip-interrogator-ext.git 9e6bbd9b8931bbe869a8e28e7005b0e13c2efff0 +https://github.com/Coyote-A/ultimate-upscale-for-automatic1111.git 756bb50573ccc86ad2620b49f01f46d91a6fd682 +https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git 69975587141ebe4144c6dc64eb7712725259bd98 +https://github.com/Bing-su/adetailer.git b63205b4e3e91effb412af2c9a8e0a1d88bc235f diff --git a/services/AUTOMATIC1111/download_automatic1111_extensions.sh b/services/AUTOMATIC1111/download_automatic1111_extensions.sh new file mode 100644 index 000000000..bf2a76ae8 --- /dev/null +++ b/services/AUTOMATIC1111/download_automatic1111_extensions.sh @@ -0,0 +1,58 @@ + +#!/bin/bash + +# download_automatic1111_extensions.sh ensures that Automatic1111 extensions +# are installed in a given directory and set at a particular git commit +# +# The first argument is a file containing a list of git repository URLs of +# extensions andcorresponding hashes, one repo/hash pair per line. Comments +# are allowed in this file, following a hash. +# +# The second argument is the extensions directory where the extensions will +# be installed. +# +# If the repositories are already installed and the correct +# commit is checked out, this script does not require internet access, and +# should be fairly quick. +echo "Running download_automatic1111_extensions.sh, reading from repo/hash file " $1 ", putting extensions into " $2 +mkdir -p $2 # Create the destination directory if it doesn't exist already. +command | while read -r line; do { # read each line of repo/hash pairs. + line_stripped_of_comments=$(echo $line | sed -e 's/\#.*//g') # strip everything after hash. + if [[ $line_stripped_of_comments = *[![:space:]]* ]]; then # check if there's a non-comment, non-whitespace on this line + new_install=0 + git_repo_url=$(echo $line | awk '{print $1;}') + commit_hash=$(echo $line | awk '{print $2;}') + pushd $2 > /dev/null + extension_name=$(echo $git_repo_url | sed -e 's/.*\///' -e 's/\.git.*//') + echo "Reading $git_repo_url, and putting hash $commit_hash into $2/$extension_name" + if [ ! -d "$extension_name" ]; then + echo "$extension_name doesn't exist yet, cloning it" + git clone "$git_repo_url" "$extension_name" + new_install=1 + else + echo "$extension_name already present on disk" + fi + cd "$extension_name" + if [ $(git rev-parse --verify HEAD) != $commit_hash ]; then + echo "$extension_name is not at the right commit, checking out $commit_hash" + git fetch --all + git reset --hard $commit_hash + new_install=1 + else + echo "$extension_name is already at the right commit, $commit_hash" + fi + #if [ $new_install -eq 1 ]; then + if [ -e requirements.txt ]; then + echo "Installing pip requirements " $(cat requirements.txt) + pip install -r requirements.txt + fi + if [ -e install.py ]; then + export PYTHONPATH="/stable-diffusion-webui" + python install.py + fi + #fi + popd > /dev/null + + fi +}; done < $1 +echo "Finished running download_automatic1111_extensions.sh" diff --git a/services/AUTOMATIC1111/entrypoint.sh b/services/AUTOMATIC1111/entrypoint.sh index 337a4d662..20f657486 100755 --- a/services/AUTOMATIC1111/entrypoint.sh +++ b/services/AUTOMATIC1111/entrypoint.sh @@ -2,6 +2,9 @@ set -Eeuo pipefail +#Download extensions and install dependencies +/docker/download_automatic1111_extensions.sh /docker/automatic1111_extensions.txt /data/config/auto/extensions/ + # TODO: move all mkdir -p ? mkdir -p /data/config/auto/scripts/ # mount scripts individually