Skip to content

Commit

Permalink
Merge pull request #25 from paipe-labs/client-node_comfyui-setup
Browse files Browse the repository at this point in the history
client-node_comfyui-setup
  • Loading branch information
vvauijij authored Mar 26, 2024
2 parents 02d409f + 1bf10d8 commit 9f436ee
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 20 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/clear-cache.yml
Original file line number Diff line number Diff line change
@@ -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")
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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: .
Expand Down
12 changes: 8 additions & 4 deletions client-node-comfyui.dockerfile
Original file line number Diff line number Diff line change
@@ -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 ####################################
Expand All @@ -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


Expand All @@ -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'
9 changes: 5 additions & 4 deletions client-node.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
4 changes: 3 additions & 1 deletion client-package/src/SessionManager.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -92,6 +92,8 @@ export class SessionManager {
}

private async setupServerSession() {
await waitForWebSocketConnection(this._backendServerWebSocketUrl);

if (isNode) {
this._ws = new WebSocketNode(this._backendServerWebSocketUrl);
} else {
Expand Down

0 comments on commit 9f436ee

Please sign in to comment.