From 3da3f281a0e6c88501a89789f8a4208c31839626 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 4 Oct 2020 01:24:41 +0200 Subject: [PATCH] Examples to push to multi-registries (#154) and cache to registry Signed-off-by: CrazyMax --- README.md | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/README.md b/README.md index 0342850..66df705 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ ___ * [Isolated builders](#isolated-builders) * [Multi-platform image](#multi-platform-image) * [Advanced usage](#advanced-usage) + * [Push to multi-registries](#push-to-multi-registries) + * [Cache to registry](#push-to-multi-registries) * [Local registry](#local-registry) * [Leverage GitHub cache](#leverage-github-cache) * [Complete workflow](#complete-workflow) @@ -235,6 +237,102 @@ jobs: ## Advanced usage +### Push to multi-registries + +The following workflow will connect you to [DockerHub](https://github.com/docker/login-action#dockerhub) +and [GitHub Container Registry](https://github.com/docker/login-action#github-container-registry) and push the +image to these registries. + +
+ Show workflow + + ```yaml + name: ci + + on: + push: + branches: master + + jobs: + multi-registries: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x + push: true + tags: | + user/app:latest + user/app:1.0.0 + ghcr.io/user/app:latest + ghcr.io/user/app:1.0.0 + ``` +
+ +### Cache to registry + +You can import/export cache from a cache manifest or (special) image configuration on the registry. + +
+ Show workflow + + ```yaml + name: ci + + on: + push: + branches: master + + jobs: + registry-cache: + runs-on: ubuntu-latest + steps: + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + push: true + tags: user/app:latest + cache-from: type=registry,ref=user/app:latest + cache-to: type=inline + ``` +
+ ### Local registry For testing purposes you may need to create a [local registry](https://hub.docker.com/_/registry) to push images into: