diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 9aca83fc..58a703c2 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -16,9 +16,7 @@ jobs: fail-fast: false matrix: build: - # Undeclared SHA tags with latest commit from master branch - # Only building periodic sha tagged images - - {latest: "true", sha: "de17a97", python: "3.10", pytorch: "2.3.1"} + - {latest: "false", comfyui: "v0.0.8", python: "3.10", pytorch: "2.4.0"} steps: - name: Free Space @@ -62,21 +60,21 @@ jobs: name: Set tags run: | img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}" - if [[ -z '${{ matrix.build.sha }}' ]]; then - COMFYUI_SHA="$(curl -fsSL "https://api.github.com/repos/comfyanonymous/ComfyUI/commits/master" | jq -r '.sha[0:7]')" + if [[ -z '${{ matrix.build.comfyui }}' ]]; then + COMFYUI_BUILD_REF="$(curl -s https://api.github.com/repos/comfyanonymous/ComfyUI/tags | jq -r '.[0].name')" else - COMFYUI_SHA="${{ matrix.build.sha }}" + COMFYUI_BUILD_REF="${{ matrix.build.comfyui }}" fi - [ -z "$COMFYUI_SHA" ] && { echo "Error: COMFYUI_SHA is empty. Exiting script." >&2; exit 1; } - echo "COMFYUI_SHA=${COMFYUI_SHA}" >> ${GITHUB_ENV} + [ -z "$COMFYUI_BUILD_REF" ] && { echo "Error: COMFYUI_BUILD_REF is empty. Exiting script." >&2; exit 1; } + echo "COMFYUI_BUILD_REF=${COMFYUI_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}-${COMFYUI_SHA}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-cpu" + TAGS="${img_path_ghcr}:${base_tag}-${COMFYUI_BUILD_REF}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-cpu" else - TAGS="${img_path_ghcr}:${base_tag}-${COMFYUI_SHA}" + TAGS="${img_path_ghcr}:${base_tag}-${COMFYUI_BUILD_REF}" fi echo "TAGS=${TAGS}" >> ${GITHUB_ENV} - @@ -88,7 +86,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 }} - COMFYUI_SHA=${{ env.COMFYUI_SHA }} + COMFYUI_BUILD_REF=${{ env.COMFYUI_BUILD_REF }} push: true # Avoids unknown/unknown architecture and extra metadata provenance: false @@ -100,9 +98,7 @@ jobs: fail-fast: false matrix: build: - # Undeclared SHA tags with latest commit from master branch - # Only building periodic sha tagged images - - {latest: "true", sha: "de17a97", python: "3.10", pytorch: "2.3.1", cuda: "12.1.1-base"} + - {latest: "false", comfyui: "v0.0.8", python: "3.10", pytorch: "2.3.1", cuda: "12.1.1-base"} steps: - name: Free Space @@ -147,24 +143,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.sha }}' ]]; then - COMFYUI_SHA="$(curl -fsSL "https://api.github.com/repos/comfyanonymous/ComfyUI/commits/master" | jq -r '.sha[0:7]')" + if [[ -z '${{ matrix.build.comfyui }}' ]]; then + COMFYUI_BUILD_REF="$(curl -s https://api.github.com/repos/comfyanonymous/ComfyUI/tags | jq -r '.[0].name')" else - COMFYUI_SHA="${{ matrix.build.sha }}" + COMFYUI_BUILD_REF="${{ matrix.build.comfyui }}" fi - [ -z "$COMFYUI_SHA" ] && { echo "Error: COMFYUI_SHA is empty. Exiting script." >&2; exit 1; } - echo "COMFYUI_SHA=${COMFYUI_SHA}" >> ${GITHUB_ENV} + [ -z "$COMFYUI_BUILD_REF" ] && { echo "Error: COMFYUI_BUILD_REF is empty. Exiting script." >&2; exit 1; } + echo "COMFYUI_BUILD_REF=${COMFYUI_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}-${COMFYUI_SHA}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest, ${img_path_ghcr}:latest-cuda" + TAGS="${img_path_ghcr}:${base_tag}-${COMFYUI_BUILD_REF}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest, ${img_path_ghcr}:latest-cuda" # Docker.io Tags - TAGS="${TAGS}, ${img_path_dhub}:${COMFYUI_SHA}, ${img_path_dhub}:latest" + TAGS="${TAGS}, ${img_path_dhub}:${COMFYUI_BUILD_REF}, ${img_path_dhub}:latest" else - TAGS="${img_path_ghcr}:${base_tag}-${COMFYUI_SHA}, ${img_path_dhub}:${COMFYUI_SHA}" + TAGS="${img_path_ghcr}:${base_tag}-${COMFYUI_BUILD_REF}, ${img_path_dhub}:${COMFYUI_BUILD_REF}" fi echo "TAGS=${TAGS}" >> ${GITHUB_ENV} - @@ -176,7 +172,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 }} - COMFYUI_SHA=${{ env.COMFYUI_SHA }} + COMFYUI_BUILD_REF=${{ env.COMFYUI_BUILD_REF }} push: true provenance: false tags: ${{ env.TAGS }} @@ -187,9 +183,7 @@ jobs: fail-fast: false matrix: build: - # Undeclared SHA tags with latest commit from master branch - # Only building periodic sha tagged images - - {latest: "true", sha: "de17a97", python: "3.10", pytorch: "2.3.1", rocm: "6.0-runtime"} + - {latest: "false", comfyui: "v0.0.8", python: "3.10", pytorch: "2.3.1", rocm: "6.0-runtime"} steps: - name: Free Space @@ -234,24 +228,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.sha }}' ]]; then - COMFYUI_SHA="$(curl -fsSL "https://api.github.com/repos/comfyanonymous/ComfyUI/commits/master" | jq -r '.sha[0:7]')" + if [[ -z '${{ matrix.build.comfyui }}' ]]; then + COMFYUI_BUILD_REF="$(curl -s https://api.github.com/repos/comfyanonymous/ComfyUI/tags | jq -r '.[0].name')" else - COMFYUI_SHA="${{ matrix.build.sha }}" + COMFYUI_BUILD_REF="${{ matrix.build.comfyui }}" fi - [ -z "$COMFYUI_SHA" ] && { echo "Error: COMFYUI_SHA is empty. Exiting script." >&2; exit 1; } - echo "COMFYUI_SHA=${COMFYUI_SHA}" >> ${GITHUB_ENV} + [ -z "$COMFYUI_BUILD_REF" ] && { echo "Error: COMFYUI_BUILD_REF is empty. Exiting script." >&2; exit 1; } + echo "COMFYUI_BUILD_REF=${COMFYUI_BUILD_REF}" >> ${GITHUB_ENV} base_tag="v2-rocm-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }}" if [[ ${{ matrix.build.latest }} == "true" ]]; then echo "Marking latest" # GHCR.io Tags - TAGS="${img_path_ghcr}:${base_tag}-${COMFYUI_SHA}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-rocm" + TAGS="${img_path_ghcr}:${base_tag}-${COMFYUI_BUILD_REF}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-rocm" # Docker.io Tags - TAGS="${TAGS}, ${img_path_dhub}:${COMFYUI_SHA}, ${img_path_dhub}:latest" + TAGS="${TAGS}, ${img_path_dhub}:${COMFYUI_BUILD_REF}, ${img_path_dhub}:latest" else - TAGS="${img_path_ghcr}:${base_tag}-${COMFYUI_SHA}, ${img_path_dhub}:${COMFYUI_SHA}" + TAGS="${img_path_ghcr}:${base_tag}-${COMFYUI_BUILD_REF}, ${img_path_dhub}:${COMFYUI_BUILD_REF}" fi echo "TAGS=${TAGS}" >> ${GITHUB_ENV} - @@ -263,7 +257,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 }} - COMFYUI_SHA=${{ env.COMFYUI_SHA }} + COMFYUI_BUILD_REF=${{ env.COMFYUI_BUILD_REF }} push: true provenance: false tags: ${{ env.TAGS }} \ No newline at end of file diff --git a/README.md b/README.md index 62b6521e..9076e128 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ Supported Platforms: `NVIDIA CUDA`, `AMD ROCm`, `CPU` | ------------------------ | ----------- | | `AUTO_UPDATE` | Update ComfyUI on startup (default `false`) | | `CIVITAI_TOKEN` | Authenticate download requests from Civitai - Required for gated models | -| `COMFYUI_BRANCH` | ComfyUI branch/commit hash for auto update (default `master`) | -| `COMFYUI_ARGS` | Startup flags. eg. `--gpu-only --highvram` | +| `COMFYUI_ARGS` | Startup arguments. eg. `--gpu-only --highvram` | | `COMFYUI_PORT_HOST` | ComfyUI interface port (default `8188`) | +| `COMFYUI_REF` | Git reference for auto update. Accepts branch, tag or commit hash. Default: latest release | | `COMFYUI_URL` | Override `$DIRECT_ADDRESS:port` with URL for ComfyUI | | `HF_TOKEN` | Authenticate download requests from HuggingFace - Required for gated models (SD3, FLUX, etc.) | 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 b4c21aa7..8c04322d 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 @@ -15,17 +15,17 @@ build_common_install_api() { } build_common_install_comfyui() { - # Set git SHA to latest if not provided - if [[ -z $COMFYUI_SHA ]]; then - export COMFYUI_SHA="$(curl -fsSL "https://api.github.com/repos/comfyanonymous/ComfyUI/commits/master" \ - | jq -r '.sha[0:7]')" - env-store COMFYUI_SHA + # Set to latest release if not provided + if [[ -z $COMFYUI_BUILD_REF ]]; then + export COMFYUI_BUILD_REF="$(curl -s https://api.github.com/repos/comfyanonymous/ComfyUI/tags | \ + jq -r '.[0].name')" + env-store COMFYUI_BUILD_REF fi cd /opt git clone https://github.com/comfyanonymous/ComfyUI cd /opt/ComfyUI - git checkout "$COMFYUI_SHA" + git checkout "$COMFYUI_BUILD_REF" $COMFYUI_VENV_PIP install --no-cache-dir \ -r requirements.txt diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/preflight.d/10-default.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/preflight.d/10-default.sh index 05c34c0d..08da7595 100755 --- a/build/COPY_ROOT_1/opt/ai-dock/bin/preflight.d/10-default.sh +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/preflight.d/10-default.sh @@ -4,12 +4,12 @@ function preflight_main() { preflight_update_comfyui - printf "%s" "${COMFYUI_FLAGS}" > /etc/comfyui_flags.conf + printf "%s" "${COMFYUI_ARGS}" > /etc/comfyui_args.conf } function preflight_serverless() { printf "Skipping ComfyUI updates in serverless mode\n" - printf "%s" "${COMFYUI_FLAGS}" > /etc/comfyui_flags.conf + printf "%s" "${COMFYUI_ARGS}" > /etc/comfyui_args.conf } function preflight_update_comfyui() { diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/set-comfyui-flags.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/set-comfyui-args.sh similarity index 100% rename from build/COPY_ROOT_1/opt/ai-dock/bin/set-comfyui-flags.sh rename to build/COPY_ROOT_1/opt/ai-dock/bin/set-comfyui-args.sh diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/supervisor-comfyui.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/supervisor-comfyui.sh index 2526bc18..e4e949f3 100755 --- a/build/COPY_ROOT_1/opt/ai-dock/bin/supervisor-comfyui.sh +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/supervisor-comfyui.sh @@ -38,12 +38,12 @@ function start() { printf "%s" "$file_content" > /run/http_ports/$PROXY_PORT - PLATFORM_FLAGS="" + PLATFORM_ARGS="" if [[ $XPU_TARGET = "CPU" ]]; then - PLATFORM_FLAGS="--cpu" + PLATFORM_ARGS="--cpu" fi - BASE_FLAGS="--disable-auto-launch" + BASE_ARGS="--disable-auto-launch" # Delay launch until venv is ready if [[ -f /run/workspace_sync || -f /run/container_config ]]; then @@ -78,14 +78,14 @@ function start() { fuser -k -SIGKILL ${LISTEN_PORT}/tcp > /dev/null 2>&1 & wait -n - FLAGS_COMBINED="${PLATFORM_FLAGS} ${BASE_FLAGS} $(cat /etc/comfyui_flags.conf)" + ARGS_COMBINED="${PLATFORM_ARGS} ${BASE_ARGS} $(cat /etc/comfyui_args.conf)" printf "Starting %s...\n" "${SERVICE_NAME}" cd /opt/ComfyUI source "$COMFYUI_VENV/bin/activate" LD_PRELOAD=libtcmalloc.so \ python main.py \ - ${FLAGS_COMBINED} --port ${LISTEN_PORT} + ${ARGS_COMBINED} --port ${LISTEN_PORT} } start 2>&1 \ No newline at end of file diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/update-comfyui.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/update-comfyui.sh index 42914595..07eb95eb 100755 --- a/build/COPY_ROOT_1/opt/ai-dock/bin/update-comfyui.sh +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/update-comfyui.sh @@ -1,24 +1,31 @@ #!/bin/bash +umask 002 -branch=master +source /opt/ai-dock/bin/venv-set.sh comfyui -if [[ -n "${COMFYUI_BRANCH}" ]]; then - branch="${COMFYUI_BRANCH}" +if [[ -n "${COMFYUI_REF}" ]]; then + ref="${COMFYUI_REF}" +else + # The latest tagged release + ref="$(curl -s https://api.github.com/repos/comfyanonymous/ComfyUI/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 ComfyUI (${branch})...\n" +[[ -n $ref ]] || { echo "Failed to get update target"; exit 1; } + +printf "Updating ComfyUI (${ref})...\n" cd /opt/ComfyUI -git checkout ${branch} +git fetch --tags +git checkout ${ref} git pull -"$COMFYUI_VENV_PIP" install --no-cache-dir \ - -r requirements.txt +"$COMFYUI_VENV_PIP" install --no-cache-dir -r requirements.txt diff --git a/build/Dockerfile b/build/Dockerfile index ff215ad7..9dc6f111 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-12.1.1-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/comfyui @@ -21,7 +21,7 @@ ENV OPT_SYNC=ComfyUI # Prepare environment ARG PYTHON_VERSION="3.10" ENV PYTHON_VERSION=${PYTHON_VERSION} -ARG PYTORCH_VERSION="2.3.1" +ARG PYTORCH_VERSION="2.4.0" ENV PYTORCH_VERSION="${PYTORCH_VERSION}" COPY --chown=0:1111 ./COPY_ROOT_0/ / ARG IMAGE_BASE @@ -29,8 +29,8 @@ RUN set -eo pipefail && /opt/ai-dock/bin/build/layer0/init.sh | tee /var/log/bui RUN echo "bust cache" # Install software -ARG COMFYUI_SHA -ENV COMFYUI_SHA=${COMFYUI_SHA} +ARG COMFYUI_BUILD_REF +ENV COMFYUI_BUILD_REF=${COMFYUI_BUILD_REF} COPY --chown=0:1111 ./COPY_ROOT_1/ / RUN set -eo pipefail && /opt/ai-dock/bin/build/layer1/init.sh | tee -a /var/log/build.log diff --git a/docker-compose.yaml b/docker-compose.yaml index 4f8b5312..de4bcdd9 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,13 +8,13 @@ services: args: PYTHON_VERSION: ${PYTHON_VERSION:-3.10} PYTORCH_VERSION: ${PYTORCH_VERSION:-2.3.0} - COMFYUI_SHA: ${COMFYUI_SHA:-} + COMFYUI_BUILD_REF: ${COMFYUI_BUILD_REF:-} # Base on Python image which is base + python + jupyter IMAGE_BASE: ${IMAGE_BASE:-ghcr.io/ai-dock/python:${PYTHON_VERSION:-3.10}-v2-cuda-12.1.1-base-22.04} tags: - - "ghcr.io/ai-dock/comfyui:${IMAGE_TAG:-pytorch-${PYTORCH_VERSION:-2.3.0}-py3.10-cuda-12.1.1-base-22.04}" + - "ghcr.io/ai-dock/comfyui:${IMAGE_TAG:-pytorch-${PYTORCH_VERSION:-2.3.0}-py3.10-v2-cuda-12.1.1-base-22.04}" - image: ghcr.io/ai-dock/comfyui:${IMAGE_TAG:-pytorch-${PYTORCH_VERSION:-2.3.0}-py3.10-cuda-12.1.1-base-22.04} + image: ghcr.io/ai-dock/comfyui:${IMAGE_TAG:-pytorch-${PYTORCH_VERSION:-2.3.0}-py3.10-v2-cuda-12.1.1-base-22.04} ## For Nvidia GPU's - You probably want to uncomment this #deploy: @@ -40,7 +40,7 @@ services: # Will echo to root-owned authorized_keys file; # Avoids changing local file owner - ./config/authorized_keys:/root/.ssh/authorized_keys_mount - - ./config/provisioning/default.sh:/opt/ai-dock/bin/provisioning.sh + #- ./config/provisioning/default.sh:/opt/ai-dock/bin/provisioning.sh # In-container development - ./build/COPY_ROOT_1/opt/ai-dock/api-wrapper:/opt/ai-dock/api-wrapper ports: @@ -68,14 +68,14 @@ services: - CIVITAI_TOKEN=${CIVITAI_TOKEN:-} - HF_TOKEN=${HF_TOKEN:-} - WEB_ENABLE_AUTH=${WEB_ENABLE_AUTH:-true} - - WEB_ENABLE_HTTPS=${WEB_ENABLE_HTTPS:-true} + - WEB_ENABLE_HTTPS=${WEB_ENABLE_HTTPS:-false} - WEB_USER=${WEB_USER:-user} - WEB_PASSWORD=${WEB_PASSWORD:-password} - SSH_PORT_HOST=${SSH_PORT_HOST:-2222} - SERVICEPORTAL_PORT_HOST=${SERVICEPORTAL_PORT_HOST:-1111} - SERVICEPORTAL_METRICS_PORT=${SERVICEPORTAL_METRICS_PORT:-21111} - SERVICEPORTAL_URL=${SERVICEPORTAL_URL:-} - - COMFYUI_FLAGS=${COMFYUI_FLAGS:-} + - COMFYUI_ARGS=${COMFYUI_ARGS:-} - COMFYUI_PORT_HOST=${COMFYUI_PORT_HOST:-8188} - COMFYUI_METRICS_PORT=${COMFYUI_METRICS_PORT:-28188} - COMFYUI_URL=${COMFYUI_URL:-}