Skip to content

Commit

Permalink
Add shell script (services/AUTOMATIC1111/download_automatic_extension…
Browse files Browse the repository at this point in the history
…s.sh) that downloads Automatic1111 extensions with specific hashes specified in a text file (services/AUTOMATIC1111/automatic1111_extensions.txt). The Dockerfile now also downloads the extensions in order to install their pip requirements.
  • Loading branch information
cloudaxes committed Jun 1, 2023
1 parent 70416d9 commit 04620dc
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
9 changes: 8 additions & 1 deletion services/AUTOMATIC1111/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 && \
Expand Down
10 changes: 10 additions & 0 deletions services/AUTOMATIC1111/automatic1111_extensions.txt
Original file line number Diff line number Diff line change
@@ -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
58 changes: 58 additions & 0 deletions services/AUTOMATIC1111/download_automatic1111_extensions.sh
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions services/AUTOMATIC1111/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 04620dc

Please sign in to comment.