3
0
Fork 0
mirror of https://gitea.com/docker/build-push-action.git synced 2024-11-25 19:09:40 +01:00

Examples to push to multi-registries (#154) and cache to registry

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-10-04 01:24:41 +02:00
parent 818fbc8101
commit 3da3f281a0
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7

View file

@ -34,6 +34,8 @@ ___
* [Isolated builders](#isolated-builders) * [Isolated builders](#isolated-builders)
* [Multi-platform image](#multi-platform-image) * [Multi-platform image](#multi-platform-image)
* [Advanced usage](#advanced-usage) * [Advanced usage](#advanced-usage)
* [Push to multi-registries](#push-to-multi-registries)
* [Cache to registry](#push-to-multi-registries)
* [Local registry](#local-registry) * [Local registry](#local-registry)
* [Leverage GitHub cache](#leverage-github-cache) * [Leverage GitHub cache](#leverage-github-cache)
* [Complete workflow](#complete-workflow) * [Complete workflow](#complete-workflow)
@ -235,6 +237,102 @@ jobs:
## Advanced usage ## 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.
<details>
<summary><b>Show workflow</b></summary>
```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
```
</details>
### Cache to registry
You can import/export cache from a cache manifest or (special) image configuration on the registry.
<details>
<summary><b>Show workflow</b></summary>
```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
```
</details>
### Local registry ### Local registry
For testing purposes you may need to create a [local registry](https://hub.docker.com/_/registry) to push images into: For testing purposes you may need to create a [local registry](https://hub.docker.com/_/registry) to push images into: