Skip to content

chore: improve Docker performance for caching #112

chore: improve Docker performance for caching

chore: improve Docker performance for caching #112

Workflow file for this run

name: docker_publish
on:
push:
branches:
- "master"
tags:
- "v*"
schedule:
- cron: "0 7 * * 0" # 7:00 AM every Sunday
workflow_dispatch:
jobs:
docker-tag:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Checkout submodule
run: |
cd stable-diffusion-webui && \
git fetch --all --tags && \
git checkout tags/${{ github.ref_name }} -b ${{ github.ref_name }}
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-setup-steps
with:
CR_PAT: ${{ secrets.CR_PAT }}
tag: ${{ github.ref_name }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
target: final
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
RELEASE=${{ github.run_number }}
platforms: linux/amd64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/stable-diffusion-webui:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/stable-diffusion-webui:cache,mode=max
docker-dev:
runs-on: ubuntu-latest
if: (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master'))
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Checkout submodule
run: |
cd stable-diffusion-webui && \
git fetch origin +refs/heads/*:refs/remotes/origin/* -v && \
git checkout -b dev origin/dev;
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-setup-steps
with:
CR_PAT: ${{ secrets.CR_PAT }}
tag: dev
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
target: final
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
VERSION=dev
RELEASE=${{ github.run_number }}
platforms: linux/amd64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/stable-diffusion-webui:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/stable-diffusion-webui:cache,mode=max
docker-forge:
runs-on: ubuntu-latest
if: (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master'))
# Runs one by one to reuse the docker layer cache
needs: docker-dev
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Checkout submodule
run: |
cd stable-diffusion-webui && \
git remote add forge https://github.com/lllyasviel/stable-diffusion-webui-forge && \
git fetch forge +refs/heads/*:refs/remotes/forge/* -v && \
git checkout -b main forge/main;
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-setup-steps
with:
CR_PAT: ${{ secrets.CR_PAT }}
tag: forge
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
target: final
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
VERSION=forge
RELEASE=${{ github.run_number }}
platforms: linux/amd64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/stable-diffusion-webui:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/stable-diffusion-webui:cache,mode=max