docker-image-comfyui #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Reference: Multi-platform image with GitHub Actions | |
| # https://docs.docker.com/build/ci/github-actions/multi-platform/ | |
| # https://docs.docker.com/build/ci/github-actions/push-multi-registries/ | |
| name: docker-image-comfyui | |
| concurrency: deploy-${{ github.workflow }} | |
| on: | |
| push: | |
| branches: | |
| - '*' | |
| paths: | |
| - comfyui/Dockerfile | |
| - comfyui/entrypoint.sh | |
| workflow_dispatch: | |
| schedule: | |
| - cron: ' 0 20 * * 4' | |
| env: | |
| IMAGE_CONTEXT: ./comfyui | |
| REGISTRY_IMAGE: ${{ github.repository_owner }}/comfyui | |
| BUILD_PLATFORMS: | | |
| linux/amd64 | |
| jobs: | |
| check-updates: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| remote_version: ${{ steps.remote_version.outputs.remote_version }} | |
| steps: | |
| # 1. 获取远程版本 | |
| - name: Get remote version | |
| id: remote_version | |
| run: | | |
| REMOTE_REPO="comfyanonymous/ComfyUI" | |
| # 使用 GitHub CLI 或 curl/jq 获取最新 Release Tag | |
| LATEST_TAG=$(curl -s "https://api.github.com/repos/${REMOTE_REPO}/releases/latest" | jq -r .tag_name) | |
| if [ "$LATEST_TAG" = "null" ]; then | |
| echo "::error::Could not find latest release tag." | |
| exit 1 | |
| fi | |
| echo "Remote Version: $LATEST_TAG" | |
| echo "remote_version=$LATEST_TAG" >> $GITHUB_OUTPUT | |
| build-images: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: | |
| - check-updates | |
| if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' | |
| steps: | |
| - name: Prepare | |
| run: | | |
| echo "TODAY=$(date +'%Y%m%d')" >> $GITHUB_ENV | |
| echo "TODAY: $TODAY" | |
| - name: Maximize build space | |
| uses: easimon/maximize-build-space@master | |
| with: | |
| build-mount-path: '/var/lib/docker/' | |
| root-reserve-mb: 512 | |
| temp-reserve-mb: 32 | |
| swap-size-mb: 32 | |
| remove-dotnet: 'true' | |
| remove-android: 'true' | |
| remove-haskell: 'true' | |
| remove-codeql: 'true' | |
| remove-docker-images: 'true' | |
| - name: Restart docker | |
| run: sudo service docker restart | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build slim images | |
| id: build-slim | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: ${{ env.BUILD_PLATFORMS }} | |
| context: ${{ env.IMAGE_CONTEXT }} | |
| file: ${{ env.IMAGE_CONTEXT }}/Dockerfile | |
| tags: | | |
| ${{ env.REGISTRY_IMAGE }}:latest-slim | |
| ghcr.io/${{ env.REGISTRY_IMAGE }}:latest-slim | |
| ${{ env.REGISTRY_IMAGE }}:${{ needs.check-updates.outputs.remote_version }}-slim-${{ env.TODAY }} | |
| ghcr.io/${{ env.REGISTRY_IMAGE }}:${{ needs.check-updates.outputs.remote_version }}-slim-${{ env.TODAY }} | |
| push: true | |
| build-args: | | |
| VERSION=${{ needs.check-updates.outputs.remote_version }} | |
| BUILD_MODE=slim | |
| - name: Build pro images | |
| id: build-pro | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: ${{ env.BUILD_PLATFORMS }} | |
| context: ${{ env.IMAGE_CONTEXT }} | |
| file: ${{ env.IMAGE_CONTEXT }}/Dockerfile | |
| tags: | | |
| ${{ env.REGISTRY_IMAGE }}:latest | |
| ghcr.io/${{ env.REGISTRY_IMAGE }}:latest | |
| ${{ env.REGISTRY_IMAGE }}:latest-pro | |
| ghcr.io/${{ env.REGISTRY_IMAGE }}:latest-pro | |
| ${{ env.REGISTRY_IMAGE }}:${{ needs.check-updates.outputs.remote_version }}-pro-${{ env.TODAY }} | |
| ghcr.io/${{ env.REGISTRY_IMAGE }}:${{ needs.check-updates.outputs.remote_version }}-pro-${{ env.TODAY }} | |
| push: true | |
| build-args: | | |
| VERSION=${{ needs.check-updates.outputs.remote_version }} | |
| BUILD_MODE=pro |