mirror of
https://gitea.com/docker/build-push-action.git
synced 2024-11-22 01:19:40 +01:00
Add registry cache job
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
499091e46b
commit
5538ea42ec
2 changed files with 93 additions and 2 deletions
91
.github/workflows/ci.yml
vendored
91
.github/workflows/ci.yml
vendored
|
@ -219,6 +219,97 @@ jobs:
|
||||||
if: always()
|
if: always()
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
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:
|
github-cache-first:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
|
|
|
@ -66,8 +66,8 @@ steps:
|
||||||
pull: true
|
pull: true
|
||||||
push: true
|
push: true
|
||||||
build-args: arg1=value1,arg2=value2
|
build-args: arg1=value1,arg2=value2
|
||||||
cache-from: type=registry,ref=myorg/myrepository
|
cache-from: type=registry,ref=myorg/myrepository:cache
|
||||||
cache-to: type=registry,ref=myorg/myrepository
|
cache-to: type=registry,ref=myorg/myrepository:cache
|
||||||
tags: myorg/myrepository:latest
|
tags: myorg/myrepository:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue