diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml new file mode 100644 index 0000000..dec5eef --- /dev/null +++ b/.github/workflows/build-docker-images.yml @@ -0,0 +1,27 @@ +name: Build API Docker Images + +on: + release: + types: + - published + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Build Docker images + working-directory: ./docker + run: | + ./build-api-images + + - name: Push Docker images + working-directory: ./docker + run: | + ./push-api-images + diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index e3f7019..f97f44c 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -35,16 +35,16 @@ jobs: - name: Get version from package.json id: version - run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT + run: echo "version=$(jq -r .version package.json)" >> "$GITHUB_OUTPUT" - name: Get the PR that was merged into main id: pr-output env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - info=$(gh pr list --state merged --limit 1 --json title --json body) - echo "title=$(echo $info | jq -r '.title')" >> $GITHUB_OUTPUT - echo "body=$(echo $info | jq -r '.body')" >> $GITHUB_OUTPUT + info=$(gh pr list --state merged --limit 1 --json title,body | jq -r '.[0]') + echo "title=$(echo $info | jq '.title')" >> "$GITHUB_OUTPUT" + echo "body=$(echo $info | jq '.body')" >> "$GITHUB_OUTPUT" - name: Create a release uses: actions/create-release@v1 @@ -62,5 +62,3 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release upload ${{ steps.version.outputs.version }} ./bin/comfyui-api#Linux_x64 - - diff --git a/README.md b/README.md index c74e45a..e46f73a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ If you have your own ComfyUI dockerfile, you can add the comfyui-api server to i ```dockerfile # Change this to the version you want to use -ARG api_version=1.7.1 +ARG api_version=1.7.2 # Download the comfyui-api binary, and make it executable @@ -388,7 +388,7 @@ The tag pattern is `saladtechnologies/comfyui:comfy<comfy-version>-api<api-versi ## Considerations for Running on SaladCloud -- **SaladCloud's Container Gateway has a 100s timeout.** It is possible to construct very long running workflows, such for video generation, with ComfyUI that would exceed this timeout. In this scenario, you will need to either use a webhook to receive the results, or integrate with SaladCloud's [Job Queues](https://docs.salad.com/products/sce/job-queues/job-queues#job-queues) to handle long-running workflows. +- **SaladCloud's Container Gateway has a 100s timeout.** It is possible to construct very long running ComfyUI workflows, such as for video generation, that would exceed this timeout. In this scenario, you will need to either use a webhook to receive the results, or integrate with SaladCloud's [Job Queues](https://docs.salad.com/products/sce/job-queues/job-queues#job-queues) to handle long-running workflows. - **SaladCloud's maximum container image size is 35GB(compressed).** The base [comfyui-api image](https://hub.docker.com/r/saladtechnologies/comfyui/tags) is around 3.25GB(compressed), so any models and extensions must fit in the remaining space. ## Contributing diff --git a/docker/api.dockerfile b/docker/api.dockerfile index 5809a31..bccb8e1 100644 --- a/docker/api.dockerfile +++ b/docker/api.dockerfile @@ -7,7 +7,7 @@ FROM ghcr.io/saladtechnologies/comfyui-api:comfy${comfy_version}-torch${pytorch_ ENV WORKFLOW_DIR=/workflows ENV STARTUP_CHECK_MAX_TRIES=30 -ARG api_version=1.7.1 +ARG api_version=1.7.2 ADD https://github.com/SaladTechnologies/comfyui-api/releases/download/${api_version}/comfyui-api . RUN chmod +x comfyui-api diff --git a/docker/push-all b/docker/push-api-images similarity index 66% rename from docker/push-all rename to docker/push-api-images index 0576ee6..293f378 100755 --- a/docker/push-all +++ b/docker/push-api-images @@ -12,6 +12,8 @@ api_version=${4:-$current_api_version} bases=("runtime" "devel") for base in "${bases[@]}"; do - docker push ghcr.io/saladtechnologies/comfyui-api:comfy$comfy_version-torch$torch_version-cuda$cuda_version-$base docker push ghcr.io/saladtechnologies/comfyui-api:comfy$comfy_version-api$api_version-torch$torch_version-cuda$cuda_version-$base -done \ No newline at end of file +done + +docker tag ghcr.io/saladtechnologies/comfyui-api:comfy$comfy_version-api$api_version-torch$torch_version-cuda$cuda_version-runtime ghcr.io/saladtechnologies/comfyui-api:latest +docker push ghcr.io/saladtechnologies/comfyui-api:latest \ No newline at end of file diff --git a/docker/push-comfy-base-images b/docker/push-comfy-base-images new file mode 100755 index 0000000..e87aac5 --- /dev/null +++ b/docker/push-comfy-base-images @@ -0,0 +1,16 @@ +#! /usr/bin/bash + +usage="Usage: $0 [comfy_version] [torch_version] [cuda_version]" + +comfy_version=${1:-0.3.10} +torch_version=${2:-2.5.0} +cuda_version=${3:-12.1} + +bases=("runtime" "devel") + +for base in "${bases[@]}"; do + docker push ghcr.io/saladtechnologies/comfyui-api:comfy$comfy_version-torch$torch_version-cuda$cuda_version-$base +done + +docker tag ghcr.io/saladtechnologies/comfyui-api:comfy$comfy_version-torch$torch_version-cuda$cuda_version-runtime ghcr.io/saladtechnologies/comfyui-api:base +docker push ghcr.io/saladtechnologies/comfyui-api:base \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 894fe5e..526a529 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "comfyui-api", - "version": "1.7.1", + "version": "1.7.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "comfyui-api", - "version": "1.7.1", + "version": "1.7.2", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index ebe39e1..34e5f09 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "comfyui-api", - "version": "1.7.1", + "version": "1.7.2", "description": "Wraps comfyui to make it easier to use as a stateless web service", "main": "dist/src/index.js", "scripts": { diff --git a/src/commands.ts b/src/commands.ts index c351527..3524b5f 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -25,16 +25,22 @@ export class CommandExecutor { this.process.on("error", (err) => { console.error(`Failed to start subprocess: ${err.message}`); - reject(err); + return reject(err); }); this.process.on("exit", (code, signal) => { console.log(`Process exited with code ${code}, signal ${signal}`); this.process = null; if (code !== null) { - resolve(code); + if (code === 0) { + console.log("Command executed successfully"); + return resolve(code); + } + return reject(new Error(`Process exited with code ${code}`)); } else { - reject(new Error(`Process terminated due to signal: ${signal}`)); + return reject( + new Error(`Process terminated due to signal: ${signal}`) + ); } }); }); diff --git a/src/utils.ts b/src/utils.ts index e80bf32..9789dc3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -64,13 +64,16 @@ export async function waitForComfyUIToStart( export async function warmupComfyUI(): Promise<void> { if (config.warmupPrompt) { - await fetch(`http://localhost:${config.wrapperPort}/prompt`, { + const resp = await fetch(`http://localhost:${config.wrapperPort}/prompt`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ prompt: config.warmupPrompt }), }); + if (!resp.ok) { + throw new Error(`Failed to warmup Comfy UI: ${await resp.text()}`); + } } }