diff --git a/.github/workflows/clear-cache.yml b/.github/workflows/clear-cache.yml new file mode 100644 index 0000000..911cc49 --- /dev/null +++ b/.github/workflows/clear-cache.yml @@ -0,0 +1,54 @@ +name: Clear Cache + +on: + workflow_dispatch: + +permissions: + actions: write + +jobs: + clear-cache: + runs-on: ubuntu-latest + steps: + - name: Clear cache + uses: actions/github-script@v6 + with: + script: | + console.log("About to clear") + const response = await github.rest.actions.getActionsCacheList({ + owner: context.repo.owner, + repo: context.repo.repo, + page: 1, + per_page: 100 + }); + + const pages = (function() { + if (typeof response.headers.link !== 'undefined') { + return response.headers.link.split(">").slice(-2)[0].split('=').slice(-1)[0] + } + return 1; + })(); + + console.log("Total pages: " + pages); + + for (let page = pages; page >= 1; page--) { + console.log("Processing page " + page) + + const response = await github.rest.actions.getActionsCacheList({ + owner: context.repo.owner, + repo: context.repo.repo, + page: page, + per_page: 100 + }); + + for (const cache of response.data.actions_caches) { + console.log(cache) + github.rest.actions.deleteActionsCacheById({ + owner: context.repo.owner, + repo: context.repo.repo, + cache_id: cache.id, + }) + } + } + + console.log("Clear completed") \ No newline at end of file diff --git a/.github/workflows/publish-image.yaml b/.github/workflows/publish-images.yaml similarity index 57% rename from .github/workflows/publish-image.yaml rename to .github/workflows/publish-images.yaml index b43a737..f421882 100644 --- a/.github/workflows/publish-image.yaml +++ b/.github/workflows/publish-images.yaml @@ -1,17 +1,15 @@ -name: build and push client-node docker image to ghcr.io +name: Publish client-node Docker Images to ghcr.io on: push: branches: ["main"] - pull_request: - branches: ["main"] env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: - build_and_push_image: + client-node-comfyui: runs-on: ubuntu-latest # `GITHUB_TOKEN` permissions for the actions in this job @@ -20,22 +18,30 @@ jobs: packages: write steps: - - uses: actions/checkout@v4 - - - name: log in to the container registry + - name: Free Space + run: | + df -h + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf /usr/local/.ghcup + sudo rm -rf /usr/local/share/boost + sudo rm -rf /usr/local/lib/android + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + df -h + - name: Checkout + uses: actions/checkout@v4 + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: extract metadata (tags, labels) for docker + - name: Extract Metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: build and push docker image + - name: Build and Push Docker Image uses: docker/build-push-action@v5 with: context: . diff --git a/client-node-comfyui.dockerfile b/client-node-comfyui.dockerfile index 7e7b956..e520cc6 100644 --- a/client-node-comfyui.dockerfile +++ b/client-node-comfyui.dockerfile @@ -1,4 +1,6 @@ -FROM ghcr.io/ai-dock/comfyui:pytorch-2.0.1-py3.10-cpu-22.04 +ARG COMFYUI_TAG=pytorch-2.2.0-py3.10-cuda-11.8.0-runtime-22.04 + +FROM ghcr.io/ai-dock/comfyui:${COMFYUI_TAG} ################################## install curl & jq #################################### @@ -9,12 +11,13 @@ RUN apt-get update \ ############################### install node & npm & yarn ############################### ENV NODE_VERSION=20.9.0 -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash ENV NVM_DIR=/root/.nvm +ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" + +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION} RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION} -ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" RUN npm install -g yarn @@ -37,4 +40,5 @@ RUN yarn build ################################## run comfyUI & node ################################### ENV WEB_ENABLE_AUTH=false -CMD init.sh & node public/run.js -b 'ws://server:8080/' -i 'localhost:8188' -t 'comfyUI' +ENTRYPOINT init.sh & node public/run.js +CMD -b 'wss://apiv2.paipe.io/' -i 'localhost:8188' -t 'comfyUI' diff --git a/client-node.dockerfile b/client-node.dockerfile index a7e02c0..bf25839 100644 --- a/client-node.dockerfile +++ b/client-node.dockerfile @@ -10,10 +10,9 @@ WORKDIR /genai-node COPY client-package/package.json . COPY client-package/yarn.lock . - RUN yarn install -# Dirty hack to make node-sd-webui work with our imports, +# dirty hack to make node-sd-webui work with our imports, # remove when we replace library node-sd-webui RUN jq '. + { "type": "module" }' node_modules/node-sd-webui/package.json > temp.json \ && mv temp.json node_modules/node-sd-webui/package.json @@ -22,5 +21,7 @@ COPY client-package . RUN yarn build -####################################### run node ####################################### -ENTRYPOINT [ "npx", "ts-node", "public/run.js" ] +################################## run comfyUI & node ################################### +ENV WEB_ENABLE_AUTH=false + +ENTRYPOINT ["node", "public/run.js"] diff --git a/client-package/src/SessionManager.ts b/client-package/src/SessionManager.ts index 835188a..0f97d74 100644 --- a/client-package/src/SessionManager.ts +++ b/client-package/src/SessionManager.ts @@ -1,5 +1,5 @@ import axios from "axios"; -import { prettyPrintJson, uuidv4 } from "./helpers/index.js"; +import { waitForWebSocketConnection, uuidv4 } from "./helpers/index.js"; import { WebSocket as WebSocketNode } from 'ws'; @@ -92,6 +92,8 @@ export class SessionManager { } private async setupServerSession() { + await waitForWebSocketConnection(this._backendServerWebSocketUrl); + if (isNode) { this._ws = new WebSocketNode(this._backendServerWebSocketUrl); } else {