Skip to content

Commit

Permalink
Fix and document AUTO_UPDATE var
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Aug 15, 2024
1 parent c561675 commit 8298f7a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 48 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
matrix:
build:
# Undeclared release tag finds latest from GitHub tags
- {latest: "true", tag: "v1.10.0", python: "3.10", pytorch: "2.3.1"}
- {latest: "false", webui: "v1.10.1", python: "3.10", pytorch: "2.4.0"}
steps:
-
name: Free Space
Expand Down Expand Up @@ -61,21 +61,21 @@ jobs:
name: Set tags
run: |
img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}"
if [[ -z '${{ matrix.build.tag }}' ]]; then
WEBUI_TAG="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | jq -r '.[0].name')"
if [[ -z '${{ matrix.build.webui }}' ]]; then
WEBUI_BUILD_REF="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | jq -r '.[0].name')"
else
WEBUI_TAG="${{ matrix.build.tag }}"
WEBUI_BUILD_REF="${{ matrix.build.webui }}"
fi
[ -z "$WEBUI_TAG" ] && { echo "Error: WEBUI_TAG is empty. Exiting script." >&2; exit 1; }
echo "WEBUI_TAG=${WEBUI_TAG}" >> ${GITHUB_ENV}
[ -z "$WEBUI_BUILD_REF" ] && { echo "Error: WEBUI_BUILD_REF is empty. Exiting script." >&2; exit 1; }
echo "WEBUI_BUILD_REF=${WEBUI_BUILD_REF}" >> ${GITHUB_ENV}
base_tag="v2-cpu-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-cpu"
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_BUILD_REF}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-cpu"
else
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}"
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_BUILD_REF}"
fi
echo "TAGS=${TAGS}" >> ${GITHUB_ENV}
-
Expand All @@ -87,7 +87,7 @@ jobs:
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.build.python }}-v2-cpu-${{ env.UBUNTU_VERSION }}
PYTHON_VERSION=${{ matrix.build.python }}
PYTORCH_VERSION=${{ matrix.build.pytorch }}
WEBUI_TAG=${{ env.WEBUI_TAG }}
WEBUI_BUILD_REF=${{ env.WEBUI_BUILD_REF }}
push: true
# Avoids unknown/unknown architecture and extra metadata
provenance: false
Expand All @@ -100,7 +100,7 @@ jobs:
matrix:
build:
# Undeclared release tag finds latest from GitHub tags
- {latest: "true", tag: "v1.10.0", python: "3.10", pytorch: "2.3.1", cuda: "12.1.1-base"}
- {latest: "false", webui: "v1.10.1", python: "3.10", pytorch: "2.4.0", cuda: "12.1.1-base"}

steps:
-
Expand Down Expand Up @@ -146,24 +146,24 @@ jobs:
run: |
img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}"
img_path_dhub="${{ vars.DOCKERHUB_USER }}/${{ env.REPO_NAME }}-cuda"
if [[ -z '${{ matrix.build.tag }}' ]]; then
WEBUI_TAG="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | jq -r '.[0].name')"
if [[ -z '${{ matrix.build.webui }}' ]]; then
WEBUI_BUILD_REF="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | jq -r '.[0].name')"
else
WEBUI_TAG="${{ matrix.build.tag }}"
WEBUI_BUILD_REF="${{ matrix.build.webui }}"
fi
[ -z "$WEBUI_TAG" ] && { echo "Error: WEBUI_TAG is empty. Exiting script." >&2; exit 1; }
echo "WEBUI_TAG=${WEBUI_TAG}" >> ${GITHUB_ENV}
[ -z "$WEBUI_BUILD_REF" ] && { echo "Error: WEBUI_BUILD_REF is empty. Exiting script." >&2; exit 1; }
echo "WEBUI_BUILD_REF=${WEBUI_BUILD_REF}" >> ${GITHUB_ENV}
base_tag="v2-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
# GHCR.io Tags
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest, ${img_path_ghcr}:latest-cuda"
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_BUILD_REF}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest, ${img_path_ghcr}:latest-cuda"
# Docker.io Tags
TAGS="${TAGS}, ${img_path_dhub}:${WEBUI_TAG}, ${img_path_dhub}:latest"
TAGS="${TAGS}, ${img_path_dhub}:${WEBUI_BUILD_REF}, ${img_path_dhub}:latest"
else
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}, ${img_path_dhub}:${WEBUI_TAG}"
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_BUILD_REF}, ${img_path_dhub}:${WEBUI_BUILD_REF}"
fi
echo "TAGS=${TAGS}" >> ${GITHUB_ENV}
-
Expand All @@ -175,7 +175,7 @@ jobs:
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.build.python }}-v2-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}
PYTHON_VERSION=${{ matrix.build.python }}
PYTORCH_VERSION=${{ matrix.build.pytorch }}
WEBUI_TAG=${{ env.WEBUI_TAG }}
WEBUI_BUILD_REF=${{ env.WEBUI_BUILD_REF }}
push: true
provenance: false
tags: ${{ env.TAGS }}
Expand All @@ -186,7 +186,7 @@ jobs:
fail-fast: false
matrix:
build:
- {latest: "true", tag: "v1.10.0", python: "3.10", pytorch: "2.3.1", rocm: "6.0-core"}
- {latest: "false", webui: "v1.10.1", python: "3.10", pytorch: "2.3.1", rocm: "6.0-core"}
steps:
-
name: Free Space
Expand Down Expand Up @@ -231,24 +231,24 @@ jobs:
run: |
img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}"
img_path_dhub="${{ vars.DOCKERHUB_USER }}/${{ env.REPO_NAME }}-rocm"
if [[ -z '${{ matrix.build.tag }}' ]]; then
WEBUI_TAG="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | jq -r '.[0].name')"
if [[ -z '${{ matrix.build.webui }}' ]]; then
WEBUI_BUILD_REF="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | jq -r '.[0].name')"
else
WEBUI_TAG="${{ matrix.build.tag }}"
WEBUI_BUILD_REF="${{ matrix.build.webui }}"
fi
[ -z "$WEBUI_TAG" ] && { echo "Error: WEBUI_TAG is empty. Exiting script." >&2; exit 1; }
echo "WEBUI_TAG=${WEBUI_TAG}" >> ${GITHUB_ENV}
[ -z "$WEBUI_BUILD_REF" ] && { echo "Error: WEBUI_BUILD_REF is empty. Exiting script." >&2; exit 1; }
echo "WEBUI_BUILD_REF=${WEBUI_BUILD_REF}" >> ${GITHUB_ENV}
base_tag="v2-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
# GHCR.io Tags
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-rocm"
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_BUILD_REF}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-rocm"
# Docker.io Tags
TAGS="${TAGS}, ${img_path_dhub}:${WEBUI_TAG}, ${img_path_dhub}:latest"
TAGS="${TAGS}, ${img_path_dhub}:${WEBUI_BUILD_REF}, ${img_path_dhub}:latest"
else
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}, ${img_path_dhub}:${WEBUI_TAG}"
TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_BUILD_REF}, ${img_path_dhub}:${WEBUI_BUILD_REF}"
fi
echo "TAGS=${TAGS}" >> ${GITHUB_ENV}
-
Expand All @@ -260,7 +260,7 @@ jobs:
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.build.python }}-v2-rocm-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }}
PYTHON_VERSION=${{ matrix.build.python }}
PYTORCH_VERSION=${{ matrix.build.pytorch }}
WEBUI_TAG=${{ env.WEBUI_TAG }}
WEBUI_BUILD_REF=${{ env.WEBUI_BUILD_REF }}
push: true
provenance: false
tags: ${{ env.TAGS }}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Tags follow these patterns:

- `:latest-cpu` → `:v2-cpu-22.04`

Browse [here](https://github.com/ai-dock/stable-diffusion-webui/pkgs/container/stable-diffusion-webui) for an image suitable for your target environment. Alternatively, view a select range of [CUDA](https://hub.docker.com/r/aidockorg/stable-diffusion-webui-cuda) and [ROCm](https://hub.docker.com/r/aidockorg/stable-diffusion-webui-rocm) builds at DockerHub.
Browse [ghcr.io](https://github.com/ai-dock/stable-diffusion-webui/pkgs/container/stable-diffusion-webui) for an image suitable for your target environment. Alternatively, view a select range of [CUDA](https://hub.docker.com/r/aidockorg/stable-diffusion-webui-cuda) and [ROCm](https://hub.docker.com/r/aidockorg/stable-diffusion-webui-rocm) builds at DockerHub.

Supported Python versions: `3.10`

Expand All @@ -46,9 +46,11 @@ Supported Platforms: `NVIDIA CUDA`, `AMD ROCm`, `CPU`
| Variable | Description |
| ------------------------ | ----------- |
| `AUTO_UPDATE` | Update A1111 Web UI on startup (default `false`) |
| `WEBUI_BRANCH` | WebUI branch/commit hash for auto update. (default `master`) |
| `CIVITAI_TOKEN` | Authenticate download requests from Civitai - Required for gated models |
| `HF_TOKEN` | Authenticate download requests from HuggingFace - Required for gated models (SD3, FLUX, etc.) |
| `WEBUI_ARGS` | Startup arguments. eg. `--no-half --api` |
| `WEBUI_PORT_HOST` | Web UI port (default `7860`) |
| `WEBUI_REF` | Git reference for auto update. Accepts branch, tag or commit hash. Default: latest release |
| `WEBUI_URL` | Override `$DIRECT_ADDRESS:port` with URL for Web UI |

See the base environment variables [here](https://github.com/ai-dock/base-image/wiki/2.0-Environment-Variables) for more configuration options.
Expand Down
8 changes: 4 additions & 4 deletions build/COPY_ROOT_1/opt/ai-dock/bin/build/layer1/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ build_common_main() {

build_common_install_webui() {
# Get latest tag from GitHub if not provided
if [[ -z $WEBUI_TAG ]]; then
export WEBUI_TAG="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | \
if [[ -z $WEBUI_BUILD_REF ]]; then
export WEBUI_BUILD_REF="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | \
jq -r '.[0].name')"
env-store WEBUI_TAG
env-store WEBUI_BUILD_REF
fi

cd /opt
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd /opt/stable-diffusion-webui
git checkout "$WEBUI_TAG"
git checkout "$WEBUI_BUILD_REF"

"$WEBUI_VENV_PIP" install --no-cache-dir -r requirements_versions.txt
}
Expand Down
23 changes: 14 additions & 9 deletions build/COPY_ROOT_1/opt/ai-dock/bin/update-webui.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
#!/bin/bash
umask 002
branch=master

source /opt/ai-dock/bin/venv-set.sh webui

if [[ -n "${WEBUI_BRANCH}" ]]; then
branch="${WEBUI_BRANCH}"
if [[ -n "${WEBUI_REF}" ]]; then
ref="${WEBUI_REF}"
else
# The latest tagged release
ref="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | \
jq -r '.[0].name')"
fi

# -b flag has priority
while getopts b: flag
# -r argument has priority
while getopts r: flag
do
case "${flag}" in
b) branch="$OPTARG";;
r) ref="$OPTARG";;
esac
done

printf "Updating stable-diffusion-webui (${branch})...\n"
[[ -n $ref ]] || { echo "Failed to get update target"; exit 1; }

printf "Updating A1111 WebUI (${ref})...\n"

cd /opt/stable-diffusion-webui
git fetch --tags
git checkout ${branch}
git checkout ${ref}
git pull

"$WEBUI_VENV_PIP" install --no-cache-dir -r requirements_versions.txt
"$WEBUI_VENV_PIP" install --no-cache-dir -r requirements.txt
8 changes: 4 additions & 4 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# For build automation - Allows building from any ai-dock base image
# Use a *cuda*base* image as default because pytorch brings the libs
ARG IMAGE_BASE="ghcr.io/ai-dock/python:3.10-cuda-11.8.0-base-22.04"
ARG IMAGE_BASE="ghcr.io/ai-dock/python:3.10-v2-cuda-12.1.1-base-22.04"
FROM ${IMAGE_BASE}

LABEL org.opencontainers.image.source https://github.com/ai-dock/stable-diffusion-webui
Expand All @@ -17,15 +17,15 @@ ENV OPT_SYNC=stable-diffusion-webui
# Prepare environment
ARG PYTHON_VERSION="3.10"
ENV PYTHON_VERSION="${PYTHON_VERSION}"
ARG PYTORCH_VERSION="2.2.2"
ARG PYTORCH_VERSION="2.4.0"
ENV PYTORCH_VERSION="${PYTORCH_VERSION}"
COPY --chown=0:1111 ./COPY_ROOT_0/ /
ARG IMAGE_BASE
RUN set -eo pipefail && /opt/ai-dock/bin/build/layer0/init.sh | tee /var/log/build.log

# Install software
ARG WEBUI_TAG
ENV WEBUI_TAG=${WEBUI_TAG}
ARG WEBUI_BUILD_REF
ENV WEBUI_BUILD_REF=${WEBUI_BUILD_REF}
COPY --chown=0:1111 ./COPY_ROOT_1/ /
ARG IMAGE_BASE
RUN set -eo pipefail && /opt/ai-dock/bin/build/layer1/init.sh | tee -a /var/log/build.log
Expand Down

0 comments on commit 8298f7a

Please sign in to comment.