From 8298f7aa5772109de46468acee98b0f633d9f131 Mon Sep 17 00:00:00 2001 From: Rob Ballantyne Date: Thu, 15 Aug 2024 18:25:28 +0100 Subject: [PATCH] Fix and document AUTO_UPDATE var --- .github/workflows/docker-build.yml | 58 +++++++++---------- README.md | 6 +- .../opt/ai-dock/bin/build/layer1/common.sh | 8 +-- .../opt/ai-dock/bin/update-webui.sh | 23 +++++--- build/Dockerfile | 8 +-- 5 files changed, 55 insertions(+), 48 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index d678474..7a07050 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -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 @@ -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} - @@ -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 @@ -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: - @@ -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} - @@ -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 }} @@ -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 @@ -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} - @@ -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 }} \ No newline at end of file diff --git a/README.md b/README.md index 0fc1957..5f01871 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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. diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/build/layer1/common.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/build/layer1/common.sh index 03ac16d..0092aac 100755 --- a/build/COPY_ROOT_1/opt/ai-dock/bin/build/layer1/common.sh +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/build/layer1/common.sh @@ -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 } diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/update-webui.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/update-webui.sh index 1f5326d..e895c7a 100755 --- a/build/COPY_ROOT_1/opt/ai-dock/bin/update-webui.sh +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/update-webui.sh @@ -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 diff --git a/build/Dockerfile b/build/Dockerfile index 51e01d4..4869e55 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -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 @@ -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