diff --git a/.github/workflows/publish-images.yaml b/.github/workflows/publish-images.yaml index f18c42a..d2108bd 100644 --- a/.github/workflows/publish-images.yaml +++ b/.github/workflows/publish-images.yaml @@ -1,17 +1,27 @@ -name: Publish client-node Docker Images to ghcr.io +name: Publish Images on: push: branches: ["main"] pull_request: - branches: ["main"] + branches: ["main"] env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} + AIDOCK_COMFYUI_DOCKERFILE: build/client-node-inference.dockerfile + AIDOCK_TAG: -aidock-comfyui + AIDOCK_COMFYUI_IMAGE: ghcr.io/ai-dock/comfyui + AIDOCK_COMFYUI_TAG: pytorch-2.2.0-py3.10-cuda-11.8.0-runtime-22.04 + + COG_COMFYUI_DOCKERFILE: build/client-node-inference.dockerfile + COG_TAG: -cog-comfyui + COG_COMFYUI_IMAGE: ghcr.io/paipe-labs/cog-comfyui + COG_COMFYUI_TAG: latest + jobs: - cog-comfyui: + client-node-aidock-comfyui: runs-on: ubuntu-latest # `GITHUB_TOKEN` permissions for the actions in this job @@ -30,61 +40,78 @@ jobs: sudo rm -rf /usr/local/lib/android sudo rm -rf "$AGENT_TOOLSDIRECTORY" df -h - - name: Checkout cog-comfyui + + - name: Checkout Repository 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 + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ env.AIDOCK_TAG }} + + - name: Build and Push Docker Image + uses: docker/build-push-action@v5 with: - repository: fofr/cog-comfyui - submodules: true - - name: Clone Plugins - run: ./scripts/clone_plugins.sh + context: . + file: ${{ env.AIDOCK_COMFYUI_DOCKERFILE }} + build-args: | + INFERENCE_IMAGE=${{ env.AIDOCK_COMFYUI_IMAGE }} + INFERENCE_TAG=${{ env.AIDOCK_COMFYUI_TAG }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + client-node-cog-comfyui: + runs-on: ubuntu-latest + + # `GITHUB_TOKEN` permissions for the actions in this job + permissions: + contents: read + packages: write + + steps: + - 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 Repository + 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: Setup Cog - uses: replicate/setup-cog@v1 + + - name: Extract Metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ env.COG_TAG }} + - name: Build and Push Docker Image - run: cog push ghcr.io/paipe-labs/cog-comfyui - - # client-node-comfyui: - # runs-on: ubuntu-latest - - # # `GITHUB_TOKEN` permissions for the actions in this job - # permissions: - # contents: read - # packages: write - - # steps: - # - 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 - # id: meta - # uses: docker/metadata-action@v5 - # with: - # images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # - name: Build and Push Docker Image - # uses: docker/build-push-action@v5 - # with: - # context: . - # file: client-node-comfyui.dockerfile - # push: true - # tags: ${{ steps.meta.outputs.tags }} - # labels: ${{ steps.meta.outputs.labels }} + uses: docker/build-push-action@v5 + with: + context: . + file: ${{ env.COG_COMFYUI_DOCKERFILE }} + build-args: | + INFERENCE_IMAGE=${{ env.COG_COMFYUI_IMAGE }} + INFERENCE_TAG=${{ env.COG_COMFYUI_TAG }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/build/client-node-inference.dockerfile b/build/client-node-inference.dockerfile new file mode 100644 index 0000000..e15cc3e --- /dev/null +++ b/build/client-node-inference.dockerfile @@ -0,0 +1,42 @@ +ARG INFERENCE_IMAGE +ARG INFERENCE_TAG + +FROM ${INFERENCE_IMAGE}:${INFERENCE_TAG} + + +################################## install curl & jq #################################### +RUN apt-get update \ + && apt install -y curl \ + && apt install -y jq + + +############################### install node & npm & yarn ############################### +ENV NODE_VERSION=20.9.0 +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} +RUN npm install -g yarn + + +###################################### build node ####################################### +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, +# 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 + +COPY client-package . +RUN yarn build + + +################################## configure inference ################################## +COPY build . diff --git a/build/client-node.dockerfile b/build/client-node.dockerfile index ed4b5db..5377f3b 100644 --- a/build/client-node.dockerfile +++ b/build/client-node.dockerfile @@ -1,25 +1,8 @@ -ARG INFERENCE_IMAGE -ARG INFERENCE_TAG +FROM node:20-alpine3.18 -FROM ${INFERENCE_IMAGE}:${INFERENCE_TAG} - -################################## install curl & jq #################################### -RUN apt-get update \ - && apt install -y curl \ - && apt install -y jq - - -############################### install node & npm & yarn ############################### -ENV NODE_VERSION=20.9.0 -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} -RUN npm install -g yarn +###################################### install jq ####################################### +RUN apk update && apk add jq ###################################### build node ####################################### @@ -32,11 +15,11 @@ RUN yarn install # 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 + && mv temp.json node_modules/node-sd-webui/package.json COPY client-package . RUN yarn build -################################### configure comfyUI ################################### -COPY build . +####################################### run node ######################################## +ENTRYPOINT node public/run.js \ No newline at end of file diff --git a/build/cog-comfyui/run_comfyui.sh b/build/cog-comfyui/run_comfyui.sh index 2dae408..1012fcf 100755 --- a/build/cog-comfyui/run_comfyui.sh +++ b/build/cog-comfyui/run_comfyui.sh @@ -1,4 +1,3 @@ #!/bin/bash -python cog-comfyui/get_weights.py python /src/ComfyUI/main.py \ No newline at end of file