From fef6ecc99006249661f4409cfde0a53eb18ca72e Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 11:54:20 +0200 Subject: [PATCH 01/31] ci: use branch name for creating dev releases --- .github/workflows/dev.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 065cf3e..27545c2 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -3,8 +3,8 @@ name: Development on: workflow_dispatch: push: - branches: - - "dev" + branches-ignore: + - main jobs: dev: @@ -45,4 +45,4 @@ jobs: with: push: true tags: | - ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:dev + ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:${{ github.ref_name }} From c7caa965938c5238e90f1ae07d51e6889c3435ca Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 12:02:56 +0200 Subject: [PATCH 02/31] ci: replace "/" with "-" to have a valid tag name --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 27545c2..63b3efb 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -45,4 +45,4 @@ jobs: with: push: true tags: | - ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:${{ github.ref_name }} + ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:${{ github.ref_name | replace('/', '-') }} From ba8c4c9a81dcfe59eb8f32045b814c0d92e53c9c Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 12:05:06 +0200 Subject: [PATCH 03/31] ci: correctly handle the tag name --- .github/workflows/dev.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 63b3efb..c2630a0 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -40,9 +40,13 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set branch name as tag + id: get_tag + run: echo "::set-output name=tag::${GITHUB_REF##*/}" | sed 's/\//-/g' + - name: Build and push uses: docker/build-push-action@v5 with: push: true tags: | - ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:${{ github.ref_name | replace('/', '-') }} + ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:${{ steps.get_tag.outputs.tag }} From 97fb24c95b22682d14d801415597a7d670797354 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 15:31:31 +0200 Subject: [PATCH 04/31] ci: build an image that contains sd3 using docker bake --- .github/workflows/dev.yml | 15 +++++++++------ Dockerfile | 30 +++++++++++++++++++++++------- docker-bake.hcl | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 docker-bake.hcl diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index c2630a0..0f9c1d8 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -40,13 +40,16 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set branch name as tag + - name: Set branch name as RELEASE_VERSION id: get_tag - run: echo "::set-output name=tag::${GITHUB_REF##*/}" | sed 's/\//-/g' + run: echo "RELEASE_VERSION=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV - - name: Build and push - uses: docker/build-push-action@v5 + - name: Build and push the images + uses: docker/bake-action@v2 with: push: true - tags: | - ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:${{ steps.get_tag.outputs.tag }} + targets: sd3 + args: | + HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} + DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }} + DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }} diff --git a/Dockerfile b/Dockerfile index a809a94..fa41cfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# Use Nvidia CUDA base image +# Stage 1: Base image with common dependencies FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 as base # Prevents prompts from packages asking for user input during installation @@ -24,12 +24,6 @@ RUN git clone https://github.com/comfyanonymous/ComfyUI.git /comfyui # Change working directory to ComfyUI WORKDIR /comfyui -ARG SKIP_DEFAULT_MODELS -# Download checkpoints/vae/LoRA to include in image. -RUN if [ -z "$SKIP_DEFAULT_MODELS" ]; then wget -O models/checkpoints/sd_xl_base_1.0.safetensors https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors; fi -RUN if [ -z "$SKIP_DEFAULT_MODELS" ]; then wget -O models/vae/sdxl_vae.safetensors https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors; fi -RUN if [ -z "$SKIP_DEFAULT_MODELS" ]; then wget -O models/vae/sdxl-vae-fp16-fix.safetensors https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors; fi - # Install ComfyUI dependencies RUN pip3 install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 \ && pip3 install --no-cache-dir xformers==0.0.21 \ @@ -48,5 +42,27 @@ WORKDIR / ADD src/start.sh src/rp_handler.py test_input.json ./ RUN chmod +x /start.sh +# Stage 2: Final image with optional model weights +FROM base as final + +# Define build arguments +ARG MODEL_TYPE +ARG HUGGINGFACE_ACCESS_TOKEN + +# Change working directory to ComfyUI +WORKDIR /comfyui + +# Download checkpoints/vae/LoRA to include in image based on model type +RUN if [ "$MODEL_TYPE" = "sdxl" ]; then \ + wget -O models/checkpoints/sd_xl_base_1.0.safetensors https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors && \ + wget -O models/vae/sdxl_vae.safetensors https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors && \ + wget -O models/vae/sdxl-vae-fp16-fix.safetensors https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors; \ + elif [ "$MODEL_TYPE" = "sd3" ]; then \ + wget --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/checkpoints/sd3_medium_incl_clips_t5xxlfp8.safetensors https://huggingface.co/stabilityai/stable-diffusion-3-medium/resolve/main/sd3_medium_incl_clips_t5xxlfp8.safetensors; \ + fi + +# Go back to the root +WORKDIR / + # Start the container CMD /start.sh diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..fad4b7c --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,32 @@ +group "default" { + targets = ["base", "sdxl", "sd3"] +} + +target "base" { + context = "." + dockerfile = "Dockerfile" + target = "base" + tags = ["${DOCKERHUB_REPO}/${DOCKERHUB_IMG}:${RELEASE_VERSION}-base"] +} + +target "sdxl" { + context = "." + dockerfile = "Dockerfile" + target = "final" + args = { + MODEL_TYPE = "sdxl" + } + tags = ["${DOCKERHUB_REPO}/${DOCKERHUB_IMG}:${RELEASE_VERSION}-sdxl"] + inherits = ["base"] +} + +target "sd3" { + context = "." + dockerfile = "Dockerfile" + target = "final" + args = { + MODEL_TYPE = "sd3" + } + tags = ["${DOCKERHUB_REPO}/${DOCKERHUB_IMG}:${RELEASE_VERSION}-sd3"] + inherits = ["base"] +} From e5ba5121136ac8f0a11b8504f89ae8ba02cfd5b3 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 15:35:59 +0200 Subject: [PATCH 05/31] ci: use "set" instead of "args" --- .github/workflows/dev.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 0f9c1d8..ca9d056 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -49,7 +49,7 @@ jobs: with: push: true targets: sd3 - args: | - HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} - DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }} - DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }} + set: | + sd3.args.HUGGINGFACE_API_KEY=${{ secrets.HUGGINGFACE_API_KEY }} + sd3.args.DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }} + sd3.args.DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }} From e9da998278fed28727bd3497c24d8eb3100165a4 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 15:44:10 +0200 Subject: [PATCH 06/31] ci: use "env" instead of "set" --- .github/workflows/dev.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index ca9d056..2bdfac0 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -49,7 +49,7 @@ jobs: with: push: true targets: sd3 - set: | - sd3.args.HUGGINGFACE_API_KEY=${{ secrets.HUGGINGFACE_API_KEY }} - sd3.args.DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }} - sd3.args.DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }} + env: + HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} + DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }} + DOCKERHUB_IMG: ${{ secrets.DOCKERHUB_IMG }} From 2abfa58ddc66cd140d89fa8949bfc456bf3cd9e1 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 16:45:17 +0200 Subject: [PATCH 07/31] ci: use variables instead of args --- .github/workflows/dev.yml | 11 ++++++----- docker-bake.hcl | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 2bdfac0..5009640 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -40,7 +40,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set branch name as RELEASE_VERSION + - name: Set branch name as release version id: get_tag run: echo "RELEASE_VERSION=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV @@ -49,7 +49,8 @@ jobs: with: push: true targets: sd3 - env: - HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} - DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }} - DOCKERHUB_IMG: ${{ secrets.DOCKERHUB_IMG }} + set: | + DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }} + DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} diff --git a/docker-bake.hcl b/docker-bake.hcl index fad4b7c..99d06fd 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,3 +1,19 @@ +variable "DOCKERHUB_REPO" { + default = "" +} + +variable "DOCKERHUB_IMG" { + default = "" +} + +variable "RELEASE_VERSION" { + default = "" +} + +variable "HUGGINGFACE_ACCESS_TOKEN" { + default = "" +} + group "default" { targets = ["base", "sdxl", "sd3"] } @@ -26,6 +42,7 @@ target "sd3" { target = "final" args = { MODEL_TYPE = "sd3" + HUGGINGFACE_ACCESS_TOKEN = "${HUGGINGFACE_ACCESS_TOKEN}" } tags = ["${DOCKERHUB_REPO}/${DOCKERHUB_IMG}:${RELEASE_VERSION}-sd3"] inherits = ["base"] From 1b0127dc48eb149b5357c686c3500d5e39dfeda7 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 16:51:28 +0200 Subject: [PATCH 08/31] ci: set variables directly for the targets --- .github/workflows/dev.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 5009640..7313c56 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -50,7 +50,10 @@ jobs: push: true targets: sd3 set: | - DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }} - DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }} - RELEASE_VERSION=${{ env.RELEASE_VERSION }} - HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} + base.args.DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }} + base.args.DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }} + base.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} + sd3.args.HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} + sd3.args.DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }} + sd3.args.DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }} + sd3.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} From 5095500f706a05782b69c83c06cbd2f6c45ea273 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 17:10:12 +0200 Subject: [PATCH 09/31] ci: write the secrets into the GITHUB_ENV --- .github/workflows/dev.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 7313c56..4009bb5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -40,9 +40,12 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set branch name as release version - id: get_tag - run: echo "RELEASE_VERSION=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV + - name: Set environment variables + run: | + echo "DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }}" >> $GITHUB_ENV + echo "DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }}" >> $GITHUB_ENV + echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV + echo "RELEASE_VERSION=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV - name: Build and push the images uses: docker/bake-action@v2 @@ -50,10 +53,14 @@ jobs: push: true targets: sd3 set: | - base.args.DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }} - base.args.DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }} + base.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + base.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} base.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} - sd3.args.HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} - sd3.args.DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }} - sd3.args.DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }} + sdxl.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + sdxl.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} + sdxl.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} + sd3.args.HUGGINGFACE_ACCESS_TOKEN=${{ env.HUGGINGFACE_ACCESS_TOKEN }} + sd3.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + sd3.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} sd3.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} + sd3.tags=${{ env.DOCKERHUB_REPO }}/${{ env.DOCKERHUB_IMG }}:${{ env.RELEASE_VERSION }}-sd3 From 4b85af2582ec76aeb74770b03f189adffbf50031 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 22:55:58 +0200 Subject: [PATCH 10/31] ci: handle env variables correctly --- .github/workflows/dev.yml | 25 ++++++------------------- docker-bake.hcl | 5 +++++ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 4009bb5..28d732c 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -9,6 +9,12 @@ on: jobs: dev: runs-on: ubuntu-latest-m + env: + DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }} + DOCKERHUB_IMG: ${{ secrets.DOCKERHUB_IMG }} + HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} + RELEASE_VERSION: ${{ github.ref_name }} + steps: - name: Checkout uses: actions/checkout@v3 @@ -40,27 +46,8 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set environment variables - run: | - echo "DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }}" >> $GITHUB_ENV - echo "DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }}" >> $GITHUB_ENV - echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV - echo "RELEASE_VERSION=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV - - name: Build and push the images uses: docker/bake-action@v2 with: push: true targets: sd3 - set: | - base.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} - base.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} - base.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} - sdxl.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} - sdxl.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} - sdxl.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} - sd3.args.HUGGINGFACE_ACCESS_TOKEN=${{ env.HUGGINGFACE_ACCESS_TOKEN }} - sd3.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} - sd3.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} - sd3.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} - sd3.tags=${{ env.DOCKERHUB_REPO }}/${{ env.DOCKERHUB_IMG }}:${{ env.RELEASE_VERSION }}-sd3 diff --git a/docker-bake.hcl b/docker-bake.hcl index 99d06fd..a9b2f26 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -22,6 +22,11 @@ target "base" { context = "." dockerfile = "Dockerfile" target = "base" + args = { + DOCKERHUB_REPO = "${DOCKERHUB_REPO}" + DOCKERHUB_IMG = "${DOCKERHUB_IMG}" + RELEASE_VERSION = "${RELEASE_VERSION}" + } tags = ["${DOCKERHUB_REPO}/${DOCKERHUB_IMG}:${RELEASE_VERSION}-base"] } From 337b93970b3b8666faace3de0b9e0058f622acfb Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 23:15:57 +0200 Subject: [PATCH 11/31] ci: use env variables from GitHub Variables --- .github/workflows/dev.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 28d732c..55d71d7 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -10,8 +10,6 @@ jobs: dev: runs-on: ubuntu-latest-m env: - DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }} - DOCKERHUB_IMG: ${{ secrets.DOCKERHUB_IMG }} HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} RELEASE_VERSION: ${{ github.ref_name }} From 22c37083d70e4db0c9a28ba17a22dcf16df027fd Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 23:23:20 +0200 Subject: [PATCH 12/31] ci: added back to env --- .github/workflows/dev.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 55d71d7..2d50119 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -10,6 +10,8 @@ jobs: dev: runs-on: ubuntu-latest-m env: + DOCKERHUB_REPO: ${{ env.DOCKERHUB_REPO }} + DOCKERHUB_IMG: ${{ env.DOCKERHUB_IMG }} HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} RELEASE_VERSION: ${{ github.ref_name }} From 06294cc9174a0fb41b2c2c18a70ef9a5ef840402 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 23:25:12 +0200 Subject: [PATCH 13/31] ci: print out env --- .github/workflows/dev.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 2d50119..b8ee8e6 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -10,12 +10,13 @@ jobs: dev: runs-on: ubuntu-latest-m env: - DOCKERHUB_REPO: ${{ env.DOCKERHUB_REPO }} - DOCKERHUB_IMG: ${{ env.DOCKERHUB_IMG }} HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} RELEASE_VERSION: ${{ github.ref_name }} steps: + - name: show env + run: env + - name: Checkout uses: actions/checkout@v3 From 9981e452f5637cc9947c698095064c636e8a0ab6 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 23:33:22 +0200 Subject: [PATCH 14/31] ci: adding the vars directly into the workflow --- .github/workflows/dev.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index b8ee8e6..ba5c792 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -10,6 +10,8 @@ jobs: dev: runs-on: ubuntu-latest-m env: + DOCKERHUB_REPO: "timpietruskyblibla" + DOCKERHUB_IMG: "runpod-worker-comfy" HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} RELEASE_VERSION: ${{ github.ref_name }} From 77bd5ab87aa6233f22014a3369413b565135e3f6 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 23:45:33 +0200 Subject: [PATCH 15/31] ci: example workflow for sd3 --- test_resources/workflows/workflow_sd3.json | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 test_resources/workflows/workflow_sd3.json diff --git a/test_resources/workflows/workflow_sd3.json b/test_resources/workflows/workflow_sd3.json new file mode 100644 index 0000000..3118f74 --- /dev/null +++ b/test_resources/workflows/workflow_sd3.json @@ -0,0 +1,94 @@ +{ + "input": { + "workflow": { + "6": { + "inputs": { + "text": "comic illustration of a white unicorn with a golden horn and pink mane and tail standing amidst a colorful and magical fantasy landscape. The background is filled with pastel-colored mountains and fluffy clouds and colorful balloons and stars. There are vibrant rainbows arching across the sky. The ground is adorned with oversized, candy-like plants, trees shaped like lollipops, and swirling ice cream cones. The scene is bathed in soft, dreamy light, giving it an enchanting and otherworldly feel. 4k, high resolution", + "clip": ["252", 1] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP Text Encode (Prompt)" + } + }, + "13": { + "inputs": { + "shift": 3, + "model": ["252", 0] + }, + "class_type": "ModelSamplingSD3", + "_meta": { + "title": "ModelSamplingSD3" + } + }, + "71": { + "inputs": { + "text": "worst quality, lowres, blurry, deformed, overexposure, bright, hands, oversaturated, burned, oversharpened, artifacts, hand, human, handwriting, nsfw, breast, breasts", + "clip": ["252", 1] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP Text Encode (Negative Prompt)" + } + }, + "135": { + "inputs": { + "width": 1152, + "height": 768, + "batch_size": 1 + }, + "class_type": "EmptySD3LatentImage", + "_meta": { + "title": "EmptySD3LatentImage" + } + }, + "231": { + "inputs": { + "samples": ["271", 0], + "vae": ["252", 2] + }, + "class_type": "VAEDecode", + "_meta": { + "title": "VAE Decode" + } + }, + "252": { + "inputs": { + "ckpt_name": "sd3_medium_incl_clips_t5xxlfp8.safetensors" + }, + "class_type": "CheckpointLoaderSimple", + "_meta": { + "title": "Load Checkpoint" + } + }, + "271": { + "inputs": { + "seed": 291740611171897, + "steps": 28, + "cfg": 4.5, + "sampler_name": "dpmpp_2m", + "scheduler": "sgm_uniform", + "denoise": 1, + "model": ["13", 0], + "positive": ["6", 0], + "negative": ["71", 0], + "latent_image": ["135", 0] + }, + "class_type": "KSampler", + "_meta": { + "title": "KSampler" + } + }, + "273": { + "inputs": { + "filename_prefix": "sd3/sd3", + "images": ["231", 0] + }, + "class_type": "SaveImage", + "_meta": { + "title": "Save Image" + } + } + } + } +} From 0aca354bbcd36ac27c4f5634b249838773b572d4 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 23:49:55 +0200 Subject: [PATCH 16/31] ci: renamed DOCKERHUB_REPO to DOCKERHUB_REPOSITORY --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index ba5c792..1f05674 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -10,7 +10,7 @@ jobs: dev: runs-on: ubuntu-latest-m env: - DOCKERHUB_REPO: "timpietruskyblibla" + DOCKERHUB_REPOSITORY: "timpietruskyblibla" DOCKERHUB_IMG: "runpod-worker-comfy" HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} RELEASE_VERSION: ${{ github.ref_name }} From 26eadb94a2a68a661f92ca4c65d03c215ea80bc9 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 24 Jul 2024 23:54:48 +0200 Subject: [PATCH 17/31] ci: removed quotes for DOCKERHUB_REPOSITORY --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 1f05674..243c36d 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -10,7 +10,7 @@ jobs: dev: runs-on: ubuntu-latest-m env: - DOCKERHUB_REPOSITORY: "timpietruskyblibla" + DOCKERHUB_REPOSITORY: timpietruskyblibla DOCKERHUB_IMG: "runpod-worker-comfy" HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} RELEASE_VERSION: ${{ github.ref_name }} From 6d4cc16a4514667bb77191140f791401d5a749c0 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 25 Jul 2024 00:03:58 +0200 Subject: [PATCH 18/31] ci: only use DOCKERHUB_REPO in bake --- .github/workflows/dev.yml | 1 - docker-bake.hcl | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 243c36d..11a25df 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -10,7 +10,6 @@ jobs: dev: runs-on: ubuntu-latest-m env: - DOCKERHUB_REPOSITORY: timpietruskyblibla DOCKERHUB_IMG: "runpod-worker-comfy" HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} RELEASE_VERSION: ${{ github.ref_name }} diff --git a/docker-bake.hcl b/docker-bake.hcl index a9b2f26..7858657 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,5 +1,5 @@ variable "DOCKERHUB_REPO" { - default = "" + default = "timpietruskyblibla" } variable "DOCKERHUB_IMG" { From e65722895cc94d42660f8bb558c8971e93829fa8 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 25 Jul 2024 00:08:34 +0200 Subject: [PATCH 19/31] ci: added vars into sd3 target --- .github/workflows/release.yml | 1 - docker-bake.hcl | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4ca0245..cfcc12c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,7 +67,6 @@ jobs: push: true tags: | ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:${{ steps.semanticrelease.outputs.release-version }} - ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:latest - name: Update description on Docker Hub if: steps.semanticrelease.outputs.new-release-published == 'true' diff --git a/docker-bake.hcl b/docker-bake.hcl index 7858657..5398c58 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -46,6 +46,8 @@ target "sd3" { dockerfile = "Dockerfile" target = "final" args = { + DOCKERHUB_REPO = "${DOCKERHUB_REPO}" + DOCKERHUB_IMG = "${DOCKERHUB_IMG}" MODEL_TYPE = "sd3" HUGGINGFACE_ACCESS_TOKEN = "${HUGGINGFACE_ACCESS_TOKEN}" } From 4dea01de833bb34ca829ac4cac60afde110f4dcc Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 25 Jul 2024 00:13:57 +0200 Subject: [PATCH 20/31] ci: added direct target --- .github/workflows/dev.yml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 11a25df..543002e 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -8,16 +8,8 @@ on: jobs: dev: - runs-on: ubuntu-latest-m - env: - DOCKERHUB_IMG: "runpod-worker-comfy" - HUGGINGFACE_ACCESS_TOKEN: ${{ secrets.HUGGINGFACE_ACCESS_TOKEN }} - RELEASE_VERSION: ${{ github.ref_name }} - + runs-on: ubuntu-latest steps: - - name: show env - run: env - - name: Checkout uses: actions/checkout@v3 @@ -48,8 +40,26 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set environment variables + run: | + echo "DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }}" >> $GITHUB_ENV + echo "DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }}" >> $GITHUB_ENV + echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV + echo "RELEASE_VERSION=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV + - name: Build and push the images uses: docker/bake-action@v2 with: push: true targets: sd3 + set: | + base.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + base.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} + base.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} + sdxl.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + sdxl.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} + sdxl.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} + sd3.args.HUGGINGFACE_ACCESS_TOKEN=${{ env.HUGGINGFACE_ACCESS_TOKEN }} + sd3.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + sd3.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} + sd3.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} From 31aeade70bc0392f62a2a59bc09ed041b35b2459 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 25 Jul 2024 10:05:21 +0200 Subject: [PATCH 21/31] ci: back to basics --- .github/workflows/dev.yml | 17 +++++++++-------- docker-bake.hcl | 9 +-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 543002e..d7e3f9d 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -42,24 +42,25 @@ jobs: - name: Set environment variables run: | - echo "DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }}" >> $GITHUB_ENV - echo "DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }}" >> $GITHUB_ENV echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV echo "RELEASE_VERSION=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV + - name: Print env + run: env + - name: Build and push the images uses: docker/bake-action@v2 with: push: true targets: sd3 set: | - base.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} - base.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} + base.args.DOCKERHUB_REPO=${{ vars.DOCKERHUB_REPO }} + base.args.DOCKERHUB_IMG=${{ vars.DOCKERHUB_IMG }} base.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} - sdxl.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} - sdxl.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} + sdxl.args.DOCKERHUB_REPO=${{ vars.DOCKERHUB_REPO }} + sdxl.args.DOCKERHUB_IMG=${{ vars.DOCKERHUB_IMG }} sdxl.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} sd3.args.HUGGINGFACE_ACCESS_TOKEN=${{ env.HUGGINGFACE_ACCESS_TOKEN }} - sd3.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} - sd3.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} + sd3.args.DOCKERHUB_REPO=${{ vars.DOCKERHUB_REPO }} + sd3.args.DOCKERHUB_IMG=${{ vars.DOCKERHUB_IMG }} sd3.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} diff --git a/docker-bake.hcl b/docker-bake.hcl index 5398c58..99d06fd 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,5 +1,5 @@ variable "DOCKERHUB_REPO" { - default = "timpietruskyblibla" + default = "" } variable "DOCKERHUB_IMG" { @@ -22,11 +22,6 @@ target "base" { context = "." dockerfile = "Dockerfile" target = "base" - args = { - DOCKERHUB_REPO = "${DOCKERHUB_REPO}" - DOCKERHUB_IMG = "${DOCKERHUB_IMG}" - RELEASE_VERSION = "${RELEASE_VERSION}" - } tags = ["${DOCKERHUB_REPO}/${DOCKERHUB_IMG}:${RELEASE_VERSION}-base"] } @@ -46,8 +41,6 @@ target "sd3" { dockerfile = "Dockerfile" target = "final" args = { - DOCKERHUB_REPO = "${DOCKERHUB_REPO}" - DOCKERHUB_IMG = "${DOCKERHUB_IMG}" MODEL_TYPE = "sd3" HUGGINGFACE_ACCESS_TOKEN = "${HUGGINGFACE_ACCESS_TOKEN}" } From 258c57cf69aac9fc3d0b21e45b118d65f37a4bc7 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 25 Jul 2024 10:10:23 +0200 Subject: [PATCH 22/31] ci: multi-stage build to not expose the HUGGINGFACE_ACCESS_TOKEN --- Dockerfile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index fa41cfb..64c9b71 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,12 +42,11 @@ WORKDIR / ADD src/start.sh src/rp_handler.py test_input.json ./ RUN chmod +x /start.sh -# Stage 2: Final image with optional model weights -FROM base as final +# Stage 2: Download models +FROM base as downloader -# Define build arguments -ARG MODEL_TYPE ARG HUGGINGFACE_ACCESS_TOKEN +ARG MODEL_TYPE # Change working directory to ComfyUI WORKDIR /comfyui @@ -61,8 +60,11 @@ RUN if [ "$MODEL_TYPE" = "sdxl" ]; then \ wget --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/checkpoints/sd3_medium_incl_clips_t5xxlfp8.safetensors https://huggingface.co/stabilityai/stable-diffusion-3-medium/resolve/main/sd3_medium_incl_clips_t5xxlfp8.safetensors; \ fi -# Go back to the root -WORKDIR / +# Stage 3: Final image +FROM base + +# Copy models from stage 2 to the final image +COPY --from=downloader /comfyui/models /comfyui/models # Start the container -CMD /start.sh +CMD /start.sh \ No newline at end of file From fb5dd45546d9ad78a862012838d9bd3c560305ba Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 25 Jul 2024 10:10:36 +0200 Subject: [PATCH 23/31] ci: write everything into GITHUB_ENV again --- .github/workflows/dev.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index d7e3f9d..e833f04 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -42,6 +42,8 @@ jobs: - name: Set environment variables run: | + echo "DOCKERHUB_REPO=${{ vars.DOCKERHUB_REPO }}" >> $GITHUB_ENV + echo "DOCKERHUB_IMG=${{ vars.DOCKERHUB_IMG }}" >> $GITHUB_ENV echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV echo "RELEASE_VERSION=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV @@ -54,13 +56,13 @@ jobs: push: true targets: sd3 set: | - base.args.DOCKERHUB_REPO=${{ vars.DOCKERHUB_REPO }} - base.args.DOCKERHUB_IMG=${{ vars.DOCKERHUB_IMG }} + base.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + base.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} base.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} - sdxl.args.DOCKERHUB_REPO=${{ vars.DOCKERHUB_REPO }} - sdxl.args.DOCKERHUB_IMG=${{ vars.DOCKERHUB_IMG }} + sdxl.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + sdxl.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} sdxl.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} sd3.args.HUGGINGFACE_ACCESS_TOKEN=${{ env.HUGGINGFACE_ACCESS_TOKEN }} - sd3.args.DOCKERHUB_REPO=${{ vars.DOCKERHUB_REPO }} - sd3.args.DOCKERHUB_IMG=${{ vars.DOCKERHUB_IMG }} + sd3.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + sd3.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} sd3.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} From c8cb4bc4ee15a48c2c9a83007655d0be6eff68f2 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 25 Jul 2024 10:16:00 +0200 Subject: [PATCH 24/31] ci: use correct name for final stage --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 64c9b71..adb99d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,7 +61,7 @@ RUN if [ "$MODEL_TYPE" = "sdxl" ]; then \ fi # Stage 3: Final image -FROM base +FROM base as final # Copy models from stage 2 to the final image COPY --from=downloader /comfyui/models /comfyui/models From 9cc04d57aeedc300ce735c7c3687de41650e2bff Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 25 Jul 2024 10:41:20 +0200 Subject: [PATCH 25/31] ci: use correct runner --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index e833f04..03ce675 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -8,7 +8,7 @@ on: jobs: dev: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-m steps: - name: Checkout uses: actions/checkout@v3 From b9ca5e60edf1c7c4a2fc4dc2dc7c31561ce30070 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 25 Jul 2024 11:53:03 +0200 Subject: [PATCH 26/31] fix: make sure to use the latest versions of all packages --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index adb99d3..25696b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,9 +25,8 @@ RUN git clone https://github.com/comfyanonymous/ComfyUI.git /comfyui WORKDIR /comfyui # Install ComfyUI dependencies -RUN pip3 install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 \ - && pip3 install --no-cache-dir xformers==0.0.21 \ - && pip3 install -r requirements.txt +RUN pip3 install --upgrade --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 \ + && pip3 install --upgrade -r requirements.txt # Install runpod RUN pip3 install runpod requests From c4d259490f128ec9903fe54ae5885c6571c99713 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 25 Jul 2024 14:16:34 +0200 Subject: [PATCH 27/31] ci: simplified variables for all targets --- .github/workflows/dev.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 03ce675..3df6e7b 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -47,22 +47,12 @@ jobs: echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV echo "RELEASE_VERSION=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV - - name: Print env - run: env - - name: Build and push the images uses: docker/bake-action@v2 with: push: true - targets: sd3 set: | - base.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} - base.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} - base.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} - sdxl.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} - sdxl.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} - sdxl.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} + *.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + *.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} + *.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} sd3.args.HUGGINGFACE_ACCESS_TOKEN=${{ env.HUGGINGFACE_ACCESS_TOKEN }} - sd3.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} - sd3.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} - sd3.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} From 2bbd0f717631699f0c24886ed23453b22a98d115 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Fri, 26 Jul 2024 17:20:14 +0200 Subject: [PATCH 28/31] docs: added 3 images, updated build your own image --- README.md | 89 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index c898a65..8e5eb8f 100644 --- a/README.md +++ b/README.md @@ -19,27 +19,27 @@ Read our article here: https://blib.la/blog/comfyui-on-runpod - [Quickstart](#quickstart) - [Features](#features) - [Config](#config) - * [Upload image to AWS S3](#upload-image-to-aws-s3) + - [Upload image to AWS S3](#upload-image-to-aws-s3) - [Use the Docker image on RunPod](#use-the-docker-image-on-runpod) - [API specification](#api-specification) - * [JSON Request Body](#json-request-body) - * [Fields](#fields) - + ["input.images"](#inputimages) + - [JSON Request Body](#json-request-body) + - [Fields](#fields) + - ["input.images"](#inputimages) - [Interact with your RunPod API](#interact-with-your-runpod-api) - * [Health status](#health-status) - * [Generate an image](#generate-an-image) - + [Example request with cURL](#example-request-with-curl) + - [Health status](#health-status) + - [Generate an image](#generate-an-image) + - [Example request with cURL](#example-request-with-curl) - [How to get the workflow from ComfyUI?](#how-to-get-the-workflow-from-comfyui) - [Bring Your Own Models and Nodes](#bring-your-own-models-and-nodes) - * [Network Volume](#network-volume) - * [Custom Docker Image](#custom-docker-image) + - [Network Volume](#network-volume) + - [Custom Docker Image](#custom-docker-image) - [Local testing](#local-testing) - * [Setup](#setup) - + [Setup for Windows](#setup-for-windows) - * [Testing the RunPod handler](#testing-the-runpod-handler) - * [Local API](#local-api) - + [Access the local Worker API](#access-the-local-worker-api) - + [Access local ComfyUI](#access-local-comfyui) + - [Setup](#setup) + - [Setup for Windows](#setup-for-windows) + - [Testing the RunPod handler](#testing-the-runpod-handler) + - [Local API](#local-api) + - [Access the local Worker API](#access-the-local-worker-api) + - [Access local ComfyUI](#access-local-comfyui) - [Automatically deploy to Docker hub with GitHub Actions](#automatically-deploy-to-docker-hub-with-github-actions) - [Acknowledgments](#acknowledgments) @@ -49,7 +49,10 @@ Read our article here: https://blib.la/blog/comfyui-on-runpod ## Quickstart -- 🐳 Use the latest release of the image for your worker: [timpietruskyblibla/runpod-worker-comfy:2.1.3](https://hub.docker.com/r/timpietruskyblibla/runpod-worker-comfy) +- 🐳 Choose one of the three available images for your serverless endpoint: + - `timpietruskyblibla/runpod-worker-comfy:3.0.0-base`: doesn't contain any checkpoints, just a clean ComfyUI image + - `timpietruskyblibla/runpod-worker-comfy:3.0.0-sdxl`: contains the checkpoints and VAE for Stable Diffusion XL + - `timpietruskyblibla/runpod-worker-comfy:3.0.0-sd3`: contains the medium checkpoint for Stable Diffusion 3 - ⚙️ [Set the environment variables](#config) - ℹ️ [Use the Docker image on RunPod](#use-the-docker-image-on-runpod) @@ -60,11 +63,14 @@ Read our article here: https://blib.la/blog/comfyui-on-runpod - The generated image is either: - Returned as base64-encoded string (default) - Uploaded to AWS S3 ([if AWS S3 is configured](#upload-image-to-aws-s3)) -- Build-in checkpoint: - - [sd_xl_base_1.0.safetensors](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) -- Build-in VAE: - - [sdxl_vae.safetensors](https://huggingface.co/stabilityai/sdxl-vae/) - - [sdxl-vae-fp16-fix](https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/) +- There are three different Docker images to choose from: + - `-base`: doesn't contain any checkpoints, just a clean ComfyUI image + - `-sdxl`: contains the checkpoints and VAE for Stable Diffusion XL + - Checkpoint: [sd_xl_base_1.0.safetensors](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) + - VAEs: + - [sdxl_vae.safetensors](https://huggingface.co/stabilityai/sdxl-vae/) + - [sdxl-vae-fp16-fix](https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/) + - `-sd3`: contains the checkpoint [sd3_medium_incl_clips_t5xxlfp8.safetensors](https://huggingface.co/stabilityai/stable-diffusion-3-medium) for Stable Diffusion 3 - [Bring your own models](#bring-your-own-models) - Based on [Ubuntu + NVIDIA CUDA](https://hub.docker.com/r/nvidia/cuda) @@ -98,10 +104,10 @@ This is only needed if you want to upload the generated picture to AWS S3. If yo - In the dialog, configure: - Template Name: `runpod-worker-comfy` (it can be anything you want) - Template Type: serverless (change template type to "serverless") - - Container Image: `/:tag`, in this case: `timpietruskyblibla/runpod-worker-comfy:2.1.3` (or `dev` if you want to have the development release) + - Container Image: `/:tag`, in this case: `timpietruskyblibla/runpod-worker-comfy:3.0.0-sd3` (or `-base` for a clean image or `-sdxl` for Stable Diffusion XL) - Container Registry Credentials: You can leave everything as it is, as this repo is public - Container Disk: `20 GB` - - Enviroment Variables: [Configure S3](#upload-image-to-aws-s3) + - (optional) Environment Variables: [Configure S3](#upload-image-to-aws-s3) - Note: You can also not configure it, the images will then stay in the worker. In order to have them stored permanently, [we have to add the network volume](https://github.com/blib-la/runpod-worker-comfy/issues/1) - Click on `Save Template` - Navigate to [`Serverless > Endpoints`](https://www.runpod.io/console/serverless/user/endpoints) and click on `New Endpoint` @@ -112,7 +118,7 @@ This is only needed if you want to upload the generated picture to AWS S3. If yo - Max Workers: `3` (whatever makes sense for you) - Idle Timeout: `5` (you can leave the default) - Flash Boot: `enabled` (doesn't cost more, but provides faster boot of our worker, which is good) - - Advanced: If you are using a Network Volume, select it under `Select Network Volume`. Otherwise leave the defaults. + - (optional) Advanced: If you are using a Network Volume, select it under `Select Network Volume`. Otherwise leave the defaults. - Select a GPU that has some availability - GPUs/Worker: `1` - Click `deploy` @@ -283,15 +289,21 @@ If you prefer to include your models directly in the Docker image, follow these ``` 3. **Build Your Docker Image**: - - Build the image locally: + - Build the **base** image locally: ```bash - docker build -t /runpod-worker-comfy:dev --platform linux/amd64 . + docker build -t /runpod-worker-comfy:dev-base --target base --platform linux/amd64 . ``` - - Optionally, skip downloading the default models to reduce the image size: + - Build the **sdxl** image locally: ```bash - docker build --build-arg SKIP_DEFAULT_MODELS=1 -t /runpod-worker-comfy:dev --platform linux/amd64 . + docker build --build-arg MODEL_TYPE=sdxl -t /runpod-worker-comfy:dev-sdxl --platform linux/amd64 . ``` - - Ensure to specify `--platform linux/amd64` to avoid errors on RunPod, see [issue #13](https://github.com/blib-la/runpod-worker-comfy/issues/13). + - Build the **sd3** image locally: + ```bash + docker build --build-arg MODEL_TYPE=sd3 --build-arg HUGGINGFACE_ACCESS_TOKEN= -t /runpod-worker-comfy:dev-sd3 --platform linux/amd64 . + ``` + +> [!NOTE] +> Ensure to specify `--platform linux/amd64` to avoid errors on RunPod, see [issue #13](https://github.com/blib-la/runpod-worker-comfy/issues/13). ## Local testing @@ -385,14 +397,19 @@ The repo contains two workflows that publish the image to Docker hub using GitHu - [dev.yml](.github/workflows/dev.yml): Creates the image and pushes it to Docker hub with the `dev` tag on every push to the `main` branch - [release.yml](.github/workflows/release.yml): Creates the image and pushes it to Docker hub with the `latest` and the release tag. It will only be triggered when you create a release on GitHub -If you want to use this, you should add these secrets to your repository: +If you want to use this, you should add these **secrets** to your repository: + +| Configuration Variable | Description | Example Value | +| ---------------------- | ----------------------------------------- | --------------- | +| `DOCKERHUB_USERNAME` | Your Docker Hub username. | `your-username` | +| `DOCKERHUB_TOKEN` | Your Docker Hub token for authentication. | `your-token` | + +And also make sure to add these **variables** to your repository: -| Configuration Variable | Description | Example Value | -| ---------------------- | ------------------------------------------------------------ | --------------------- | -| `DOCKERHUB_USERNAME` | Your Docker Hub username. | `your-username` | -| `DOCKERHUB_TOKEN` | Your Docker Hub token for authentication. | `your-token` | -| `DOCKERHUB_REPO` | The repository on Docker Hub where the image will be pushed. | `timpietruskyblibla` | -| `DOCKERHUB_IMG` | The name of the image to be pushed to Docker Hub. | `runpod-worker-comfy` | +| Variable Name | Description | Example Value | +| ---------------- | ------------------------------------------------------------ | --------------------- | +| `DOCKERHUB_REPO` | The repository on Docker Hub where the image will be pushed. | `timpietruskyblibla` | +| `DOCKERHUB_IMG` | The name of the image to be pushed to Docker Hub. | `runpod-worker-comfy` | ## Acknowledgments From 35988f9748a69301b8494f2df85e93e086e711fe Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Fri, 26 Jul 2024 17:21:05 +0200 Subject: [PATCH 29/31] docs: updated TOC --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8e5eb8f..9c262a2 100644 --- a/README.md +++ b/README.md @@ -19,27 +19,27 @@ Read our article here: https://blib.la/blog/comfyui-on-runpod - [Quickstart](#quickstart) - [Features](#features) - [Config](#config) - - [Upload image to AWS S3](#upload-image-to-aws-s3) + * [Upload image to AWS S3](#upload-image-to-aws-s3) - [Use the Docker image on RunPod](#use-the-docker-image-on-runpod) - [API specification](#api-specification) - - [JSON Request Body](#json-request-body) - - [Fields](#fields) - - ["input.images"](#inputimages) + * [JSON Request Body](#json-request-body) + * [Fields](#fields) + + ["input.images"](#inputimages) - [Interact with your RunPod API](#interact-with-your-runpod-api) - - [Health status](#health-status) - - [Generate an image](#generate-an-image) - - [Example request with cURL](#example-request-with-curl) + * [Health status](#health-status) + * [Generate an image](#generate-an-image) + + [Example request with cURL](#example-request-with-curl) - [How to get the workflow from ComfyUI?](#how-to-get-the-workflow-from-comfyui) - [Bring Your Own Models and Nodes](#bring-your-own-models-and-nodes) - - [Network Volume](#network-volume) - - [Custom Docker Image](#custom-docker-image) + * [Network Volume](#network-volume) + * [Custom Docker Image](#custom-docker-image) - [Local testing](#local-testing) - - [Setup](#setup) - - [Setup for Windows](#setup-for-windows) - - [Testing the RunPod handler](#testing-the-runpod-handler) - - [Local API](#local-api) - - [Access the local Worker API](#access-the-local-worker-api) - - [Access local ComfyUI](#access-local-comfyui) + * [Setup](#setup) + + [Setup for Windows](#setup-for-windows) + * [Testing the RunPod handler](#testing-the-runpod-handler) + * [Local API](#local-api) + + [Access the local Worker API](#access-the-local-worker-api) + + [Access local ComfyUI](#access-local-comfyui) - [Automatically deploy to Docker hub with GitHub Actions](#automatically-deploy-to-docker-hub-with-github-actions) - [Acknowledgments](#acknowledgments) From 4906b4fd0031cccbb92574eb76597a936355dfea Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Fri, 26 Jul 2024 17:24:43 +0200 Subject: [PATCH 30/31] ci: updated name --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 3df6e7b..3731707 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -47,7 +47,7 @@ jobs: echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV echo "RELEASE_VERSION=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV - - name: Build and push the images + - name: Build and push the images to Docker Hub uses: docker/bake-action@v2 with: push: true From 0ca83bd51c2b43645298f19ad7b626700b747f66 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Fri, 26 Jul 2024 17:25:40 +0200 Subject: [PATCH 31/31] ci: use docker bake to publish 3 images instead of just 1 --- .github/workflows/release.yml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cfcc12c..320164b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,13 +60,22 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.BLIBLA_SEMANTIC_RELEASE }} - - name: Build image and push it to Docker Hub - if: steps.semanticrelease.outputs.new-release-published == 'true' - uses: docker/build-push-action@v5 + - name: Set environment variables + run: | + echo "DOCKERHUB_REPO=${{ vars.DOCKERHUB_REPO }}" >> $GITHUB_ENV + echo "DOCKERHUB_IMG=${{ vars.DOCKERHUB_IMG }}" >> $GITHUB_ENV + echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV + echo "RELEASE_VERSION=${{ steps.semanticrelease.outputs.release-version }}" >> $GITHUB_ENV + + - name: Build and push the images to Docker Hub + uses: docker/bake-action@v2 with: push: true - tags: | - ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:${{ steps.semanticrelease.outputs.release-version }} + set: | + *.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} + *.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} + *.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} + sd3.args.HUGGINGFACE_ACCESS_TOKEN=${{ env.HUGGINGFACE_ACCESS_TOKEN }} - name: Update description on Docker Hub if: steps.semanticrelease.outputs.new-release-published == 'true' @@ -74,4 +83,4 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }} + repository: ${{ env.DOCKERHUB_REPO }}/${{ env.DOCKERHUB_IMG }}