From 5538ea42ecc3862ea0409b4b0c43b101e7ccee3e Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 4 Oct 2020 00:01:14 +0200 Subject: [PATCH] Add registry cache job Signed-off-by: CrazyMax --- .github/workflows/ci.yml | 91 ++++++++++++++++++++++++++++++++++++++++ UPGRADE.md | 4 +- 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c700d8b..f8deddd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -219,6 +219,97 @@ jobs: if: always() uses: crazy-max/ghaction-dump-context@v1 + registry-cache: + runs-on: ubuntu-latest + services: + registry: + image: registry:2 + ports: + - 5000:5000 + steps: + - + name: Checkout + uses: actions/checkout@v2.3.3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: all + - + name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + driver-opts: network=host + - + name: Build and push (1) + id: docker_build + uses: ./ + with: + context: ./test + file: ./test/Dockerfile-multi + builder: ${{ steps.buildx.outputs.name }} + platforms: linux/amd64,linux/arm64 + push: true + tags: | + localhost:5000/name/app:latest + localhost:5000/name/app:1.0.0 + cache-from: type=registry,ref=localhost:5000/name/app:cache + cache-to: type=registry,ref=localhost:5000/name/app:cache + - + name: Inspect (1) + run: | + docker buildx imagetools inspect localhost:5000/name/app:1.0.0 + - + name: Inspect cache (1) + run: | + docker buildx imagetools inspect localhost:5000/name/app:cache + - + name: Image digest (1) + run: echo ${{ steps.docker_build.outputs.digest }} + - + name: Prune + run: | + docker buildx prune -a -f --verbose + - + name: Build and push (2) + id: docker_build2 + uses: ./ + with: + context: ./test + file: ./test/Dockerfile-multi + builder: ${{ steps.buildx.outputs.name }} + platforms: linux/amd64,linux/arm64 + push: true + tags: | + localhost:5000/name/app:latest + localhost:5000/name/app:1.0.0 + cache-from: type=registry,ref=localhost:5000/name/app:cache + cache-to: type=registry,ref=localhost:5000/name/app:cache + - + name: Inspect (2) + run: | + docker buildx imagetools inspect localhost:5000/name/app:1.0.0 + - + name: Inspect cache (2) + run: | + docker buildx imagetools inspect localhost:5000/name/app:cache + - + name: Image digest (2) + run: echo ${{ steps.docker_build2.outputs.digest }} + - + name: Check digests + run: | + echo Compare "${{ steps.docker_build.outputs.digest }}" with "${{ steps.docker_build2.outputs.digest }}" + if [ "${{ steps.docker_build.outputs.digest }}" != "${{ steps.docker_build2.outputs.digest }}" ]; then + echo "::error::Digests should be identical" + exit 1 + fi + - + name: Dump context + if: always() + uses: crazy-max/ghaction-dump-context@v1 + github-cache-first: runs-on: ubuntu-latest outputs: diff --git a/UPGRADE.md b/UPGRADE.md index 7f017d9..72e4ecf 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -66,8 +66,8 @@ steps: pull: true push: true build-args: arg1=value1,arg2=value2 - cache-from: type=registry,ref=myorg/myrepository - cache-to: type=registry,ref=myorg/myrepository + cache-from: type=registry,ref=myorg/myrepository:cache + cache-to: type=registry,ref=myorg/myrepository:cache tags: myorg/myrepository:latest ```