mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-10 04:15:40 +01:00
Merge pull request #104 from crazy-max/local-registry-example
Local registry example
This commit is contained in:
commit
b2462f3ff0
40
.github/workflows/ci.yml
vendored
40
.github/workflows/ci.yml
vendored
@ -18,11 +18,12 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
buildx-version:
|
buildx-version:
|
||||||
- latest
|
- latest
|
||||||
|
services:
|
||||||
|
registry:
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
steps:
|
steps:
|
||||||
-
|
|
||||||
name: Run local registry
|
|
||||||
run: |
|
|
||||||
docker run -d -p 5000:5000 registry:2
|
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.1
|
uses: actions/checkout@v2.3.1
|
||||||
@ -46,7 +47,6 @@ jobs:
|
|||||||
file: ./test/Dockerfile
|
file: ./test/Dockerfile
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
allow: network.host,security.insecure
|
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
localhost:5000/name/app:latest
|
localhost:5000/name/app:latest
|
||||||
@ -73,11 +73,12 @@ jobs:
|
|||||||
buildx-version:
|
buildx-version:
|
||||||
- ""
|
- ""
|
||||||
- latest
|
- latest
|
||||||
|
services:
|
||||||
|
registry:
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
steps:
|
steps:
|
||||||
-
|
|
||||||
name: Run local registry
|
|
||||||
run: |
|
|
||||||
docker run -d -p 5000:5000 registry:2
|
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.1
|
uses: actions/checkout@v2.3.1
|
||||||
@ -101,7 +102,6 @@ jobs:
|
|||||||
context: ./test
|
context: ./test
|
||||||
file: ./test/Dockerfile
|
file: ./test/Dockerfile
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
allow: network.host,security.insecure
|
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
localhost:5000/name/app:latest
|
localhost:5000/name/app:latest
|
||||||
@ -129,11 +129,12 @@ jobs:
|
|||||||
dockerfile:
|
dockerfile:
|
||||||
- multi
|
- multi
|
||||||
- multi-sudo
|
- multi-sudo
|
||||||
|
services:
|
||||||
|
registry:
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
steps:
|
steps:
|
||||||
-
|
|
||||||
name: Run local registry
|
|
||||||
run: |
|
|
||||||
docker run -d -p 5000:5000 registry:2
|
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.1
|
uses: actions/checkout@v2.3.1
|
||||||
@ -158,7 +159,6 @@ jobs:
|
|||||||
file: ./test/Dockerfile-${{ matrix.dockerfile }}
|
file: ./test/Dockerfile-${{ matrix.dockerfile }}
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
allow: network.host,security.insecure
|
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
localhost:5000/name/app:latest
|
localhost:5000/name/app:latest
|
||||||
@ -177,11 +177,12 @@ jobs:
|
|||||||
|
|
||||||
github-cache:
|
github-cache:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
registry:
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
steps:
|
steps:
|
||||||
-
|
|
||||||
name: Run local registry
|
|
||||||
run: |
|
|
||||||
docker run -d -p 5000:5000 registry:2
|
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.1
|
uses: actions/checkout@v2.3.1
|
||||||
@ -214,7 +215,6 @@ jobs:
|
|||||||
file: ./test/Dockerfile-multi-golang
|
file: ./test/Dockerfile-multi-golang
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
allow: network.host,security.insecure
|
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
localhost:5000/name/app:latest
|
localhost:5000/name/app:latest
|
||||||
|
66
README.md
66
README.md
@ -51,9 +51,11 @@ jobs:
|
|||||||
main:
|
main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@master
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@master
|
uses: docker/setup-buildx-action@master
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
@ -66,7 +68,6 @@ jobs:
|
|||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
push: true
|
push: true
|
||||||
tags: user/app:latest
|
tags: user/app:latest
|
||||||
-
|
-
|
||||||
@ -83,7 +84,6 @@ as a secret named `GIT_AUTH_TOKEN` to be able to authenticate against it with bu
|
|||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
push: true
|
push: true
|
||||||
tags: user/app:latest
|
tags: user/app:latest
|
||||||
secrets: |
|
secrets: |
|
||||||
@ -111,14 +111,9 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@master
|
uses: docker/setup-qemu-action@master
|
||||||
with:
|
|
||||||
platforms: all
|
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@master
|
uses: docker/setup-buildx-action@master
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
@ -129,7 +124,6 @@ jobs:
|
|||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64,linux/386
|
platforms: linux/amd64,linux/arm64,linux/386
|
||||||
@ -195,11 +189,8 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@master
|
uses: docker/setup-qemu-action@master
|
||||||
with:
|
|
||||||
platforms: all
|
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@master
|
uses: docker/setup-buildx-action@master
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
@ -211,7 +202,6 @@ jobs:
|
|||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
|
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
|
||||||
@ -221,6 +211,46 @@ jobs:
|
|||||||
user/app:1.0.0
|
user/app:1.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Local registry
|
||||||
|
|
||||||
|
For testing purposes you may need to create a [local registry](https://hub.docker.com/_/registry) to push images into.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
local-registry:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
registry:
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@master
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@master
|
||||||
|
with:
|
||||||
|
driver-opts: network=host
|
||||||
|
-
|
||||||
|
name: Build and push to local registry
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: localhost:5000/name/app:latest
|
||||||
|
-
|
||||||
|
name: Inspect
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect localhost:5000/name/app:latest
|
||||||
|
```
|
||||||
|
|
||||||
### Leverage GitHub cache
|
### Leverage GitHub cache
|
||||||
|
|
||||||
You can leverage [GitHub cache](https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows)
|
You can leverage [GitHub cache](https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows)
|
||||||
@ -239,7 +269,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@master
|
uses: docker/setup-buildx-action@master
|
||||||
-
|
-
|
||||||
name: Cache Docker layers
|
name: Cache Docker layers
|
||||||
@ -257,17 +286,12 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
push: true
|
push: true
|
||||||
tags: user/app:latest
|
tags: user/app:latest
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Complete workflow
|
### Complete workflow
|
||||||
@ -317,11 +341,8 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@master
|
uses: docker/setup-qemu-action@master
|
||||||
with:
|
|
||||||
platforms: all
|
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@master
|
uses: docker/setup-buildx-action@master
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
@ -335,7 +356,6 @@ jobs:
|
|||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64,linux/386
|
platforms: linux/amd64,linux/arm64,linux/386
|
||||||
|
Loading…
Reference in New Issue
Block a user