2021-05-12 10:23:06 +00:00
|
|
|
# Copy images between registries
|
|
|
|
|
2022-10-07 17:00:09 +00:00
|
|
|
[Multi-platform images](https://docs.docker.com/build/building/multi-platform/)
|
|
|
|
built using Buildx can be copied from one registry to another using the
|
|
|
|
[`imagetools create` command](https://docs.docker.com/engine/reference/commandline/buildx_imagetools_create/):
|
2021-05-12 10:23:06 +00:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
name: ci
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2022-01-18 13:57:27 +00:00
|
|
|
- 'main'
|
2021-05-12 10:23:06 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
docker:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2022-05-28 16:36:30 +00:00
|
|
|
uses: actions/checkout@v3
|
2021-05-12 10:23:06 +00:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2022-05-05 17:24:32 +00:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2021-05-12 10:23:06 +00:00
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
2022-05-05 17:24:32 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-10-07 17:00:09 +00:00
|
|
|
-
|
|
|
|
name: Login to Docker Hub
|
2022-05-05 17:24:32 +00:00
|
|
|
uses: docker/login-action@v2
|
2021-05-12 10:23:06 +00:00
|
|
|
with:
|
2022-10-07 17:00:09 +00:00
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2021-05-12 10:23:06 +00:00
|
|
|
-
|
|
|
|
name: Login to GitHub Container Registry
|
2022-05-05 17:24:32 +00:00
|
|
|
uses: docker/login-action@v2
|
2021-05-12 10:23:06 +00:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
-
|
|
|
|
name: Build and push
|
2022-05-05 17:24:32 +00:00
|
|
|
uses: docker/build-push-action@v3
|
2021-05-12 10:23:06 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
push: true
|
|
|
|
tags: |
|
|
|
|
user/app:latest
|
|
|
|
user/app:1.0.0
|
2022-10-07 17:00:09 +00:00
|
|
|
-
|
|
|
|
name: Push image to GHCR
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools create \
|
|
|
|
--tag ghcr.io/user/app:latest \
|
|
|
|
--tag ghcr.io/user/app:1.0.0 \
|
|
|
|
user/app:latest
|
2021-05-12 10:23:06 +00:00
|
|
|
```
|