Skip to content

Commit 9379083

Browse files
authored
Merge pull request #299 from crazy-max/split-docs
Enhance documentation
2 parents af867d4 + a63b18d commit 9379083

12 files changed

+594
-499
lines changed

README.md

+58-493
Large diffs are not rendered by default.

TROUBLESHOOTING.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ jobs:
5959
uses: docker/build-push-action@v2
6060
with:
6161
context: .
62-
file: ./Dockerfile
63-
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
62+
platforms: linux/amd64,linux/arm64
6463
tags: docker.io/user/app:latest
6564
outputs: type=oci,dest=/tmp/image.tar
6665
-

UPGRADE.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ steps:
6363
uses: docker/build-push-action@v2
6464
with:
6565
context: .
66-
file: ./Dockerfile
6766
pull: true
6867
push: true
6968
build-args: |
@@ -136,7 +135,6 @@ steps:
136135
uses: docker/build-push-action@v2
137136
with:
138137
context: .
139-
file: ./Dockerfile
140138
push: ${{ github.event_name != 'pull_request' }}
141139
tags: ${{ steps.prep.outputs.tags }}
142140
labels: |
@@ -145,5 +143,5 @@ steps:
145143
org.opencontainers.image.revision=${{ github.sha }}
146144
```
147145
148-
> You can also use the [Docker meta action](https://github.com/crazy-max/ghaction-docker-meta) to handle tags and
149-
> labels based on GitHub actions events and Git metadata. A workflow example is available in the [README](README.md#handle-tags-and-labels).
146+
> You can also use the [Docker meta action to handle tags and labels](docs/advanced/tags-labels.md) based on GitHub
147+
> actions events and Git metadata.

docs/advanced/cache.md

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Cache
2+
3+
* [Registry cache](#registry-cache)
4+
* [GitHub cache](#github-cache)
5+
6+
> More info about buildx cache: https://github.com/docker/buildx#--cache-fromnametypetypekeyvalue
7+
8+
## Registry cache
9+
10+
You can import/export cache from a cache manifest or (special) image configuration on the registry.
11+
12+
```yaml
13+
name: ci
14+
15+
on:
16+
push:
17+
branches:
18+
- 'master'
19+
20+
jobs:
21+
docker:
22+
runs-on: ubuntu-latest
23+
steps:
24+
-
25+
name: Checkout
26+
uses: actions/checkout@v2
27+
-
28+
name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v1
30+
-
31+
name: Login to DockerHub
32+
uses: docker/login-action@v1
33+
with:
34+
username: ${{ secrets.DOCKERHUB_USERNAME }}
35+
password: ${{ secrets.DOCKERHUB_TOKEN }}
36+
-
37+
name: Build and push
38+
uses: docker/build-push-action@v2
39+
with:
40+
context: .
41+
push: true
42+
tags: user/app:latest
43+
cache-from: type=registry,ref=user/app:latest
44+
cache-to: type=inline
45+
```
46+
47+
## GitHub cache
48+
49+
> :warning: At the moment caches are copied over the existing cache so it [keeps growing](https://github.com/docker/build-push-action/issues/252).
50+
> The `Move cache` step is used as a temporary fix (see https://github.com/moby/buildkit/issues/1896).
51+
52+
> :rocket: There is a new cache backend using GitHub cache being developed that will lighten your workflow.
53+
> More info: https://github.com/docker/buildx/pull/535
54+
55+
You can leverage [GitHub cache](https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows)
56+
using [actions/cache](https://github.com/actions/cache) with this action:
57+
58+
```yaml
59+
name: ci
60+
61+
on:
62+
push:
63+
branches:
64+
- 'master'
65+
66+
jobs:
67+
docker:
68+
runs-on: ubuntu-latest
69+
steps:
70+
-
71+
name: Checkout
72+
uses: actions/checkout@v2
73+
-
74+
name: Set up Docker Buildx
75+
uses: docker/setup-buildx-action@v1
76+
-
77+
name: Cache Docker layers
78+
uses: actions/cache@v2
79+
with:
80+
path: /tmp/.buildx-cache
81+
key: ${{ runner.os }}-buildx-${{ github.sha }}
82+
restore-keys: |
83+
${{ runner.os }}-buildx-
84+
-
85+
name: Login to DockerHub
86+
uses: docker/login-action@v1
87+
with:
88+
username: ${{ secrets.DOCKERHUB_USERNAME }}
89+
password: ${{ secrets.DOCKERHUB_TOKEN }}
90+
-
91+
name: Build and push
92+
uses: docker/build-push-action@v2
93+
with:
94+
context: .
95+
push: true
96+
tags: user/app:latest
97+
cache-from: type=local,src=/tmp/.buildx-cache
98+
cache-to: type=local,dest=/tmp/.buildx-cache-new
99+
-
100+
# Temp fix
101+
# https://github.com/docker/build-push-action/issues/252
102+
# https://github.com/moby/buildkit/issues/1896
103+
name: Move cache
104+
run: |
105+
rm -rf /tmp/.buildx-cache
106+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
107+
```

docs/advanced/dockerhub-desc.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Update DockerHub repo description
2+
3+
You can update the [DockerHub repository description](https://docs.docker.com/docker-hub/repos/) using
4+
a third party action called [DockerHub Description](https://github.com/peter-evans/dockerhub-description)
5+
with this action:
6+
7+
```yaml
8+
name: ci
9+
10+
on:
11+
push:
12+
branches:
13+
- 'master'
14+
15+
jobs:
16+
docker:
17+
runs-on: ubuntu-latest
18+
steps:
19+
-
20+
name: Checkout
21+
uses: actions/checkout@v2
22+
-
23+
name: Set up QEMU
24+
uses: docker/setup-qemu-action@v1
25+
-
26+
name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v1
28+
-
29+
name: Login to DockerHub
30+
uses: docker/login-action@v1
31+
with:
32+
username: ${{ secrets.DOCKERHUB_USERNAME }}
33+
password: ${{ secrets.DOCKERHUB_TOKEN }}
34+
-
35+
name: Build and push
36+
uses: docker/build-push-action@v2
37+
with:
38+
context: .
39+
push: true
40+
tags: user/app:latest
41+
-
42+
name: Update repo description
43+
uses: peter-evans/dockerhub-description@v2
44+
with:
45+
username: ${{ secrets.DOCKERHUB_USERNAME }}
46+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
47+
repository: user/app
48+
```

docs/advanced/export-docker.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Export image to Docker
2+
3+
You may want your build result to be available in the Docker client through `docker images` to be able to use it
4+
in another step of your workflow:
5+
6+
```yaml
7+
name: ci
8+
9+
on:
10+
push:
11+
branches:
12+
- 'master'
13+
14+
jobs:
15+
docker:
16+
runs-on: ubuntu-latest
17+
steps:
18+
-
19+
name: Checkout
20+
uses: actions/checkout@v2
21+
-
22+
name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v1
24+
-
25+
name: Build
26+
uses: docker/build-push-action@v2
27+
with:
28+
context: .
29+
load: true
30+
tags: myimage:latest
31+
-
32+
name: Inspect
33+
run: |
34+
docker image inspect myimage:latest
35+
```

docs/advanced/isolated-builders.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Isolated builders
2+
3+
```yaml
4+
name: ci
5+
6+
on:
7+
push:
8+
branches:
9+
- 'master'
10+
11+
jobs:
12+
docker:
13+
runs-on: ubuntu-latest
14+
steps:
15+
-
16+
name: Checkout
17+
uses: actions/checkout@v2
18+
-
19+
uses: docker/setup-buildx-action@v1
20+
id: builder1
21+
-
22+
uses: docker/setup-buildx-action@v1
23+
id: builder2
24+
-
25+
name: Builder 1 name
26+
run: echo ${{ steps.builder1.outputs.name }}
27+
-
28+
name: Builder 2 name
29+
run: echo ${{ steps.builder2.outputs.name }}
30+
-
31+
name: Build against builder1
32+
uses: docker/build-push-action@v2
33+
with:
34+
builder: ${{ steps.builder1.outputs.name }}
35+
context: .
36+
target: mytarget1
37+
-
38+
name: Build against builder2
39+
uses: docker/build-push-action@v2
40+
with:
41+
builder: ${{ steps.builder2.outputs.name }}
42+
context: .
43+
target: mytarget2
44+
```

docs/advanced/local-registry.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Local registry
2+
3+
For testing purposes you may need to create a [local registry](https://hub.docker.com/_/registry) to push images into:
4+
5+
```yaml
6+
name: ci
7+
8+
on:
9+
push:
10+
branches:
11+
- 'master'
12+
13+
jobs:
14+
docker:
15+
runs-on: ubuntu-latest
16+
services:
17+
registry:
18+
image: registry:2
19+
ports:
20+
- 5000:5000
21+
steps:
22+
-
23+
name: Checkout
24+
uses: actions/checkout@v2
25+
-
26+
name: Set up QEMU
27+
uses: docker/setup-qemu-action@v1
28+
-
29+
name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v1
31+
with:
32+
driver-opts: network=host
33+
-
34+
name: Build and push to local registry
35+
uses: docker/build-push-action@v2
36+
with:
37+
context: .
38+
push: true
39+
tags: localhost:5000/name/app:latest
40+
-
41+
name: Inspect
42+
run: |
43+
docker buildx imagetools inspect localhost:5000/name/app:latest
44+
```

docs/advanced/multi-platform.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Multi-platform image
2+
3+
You can build multi-platform images using the [`platforms` input](../../README.md#inputs) as described below.
4+
5+
> :bulb: List of available platforms will be displayed and available through our [setup-buildx](https://github.com/docker/setup-buildx-action#about) action.
6+
7+
> :bulb: If you want support for more platforms, you can use QEMU with our [setup-qemu](https://github.com/docker/setup-qemu-action) action.
8+
9+
```yaml
10+
name: ci
11+
12+
on:
13+
push:
14+
branches:
15+
- 'master'
16+
17+
jobs:
18+
docker:
19+
runs-on: ubuntu-latest
20+
steps:
21+
-
22+
name: Checkout
23+
uses: actions/checkout@v2
24+
-
25+
name: Set up QEMU
26+
uses: docker/setup-qemu-action@v1
27+
-
28+
name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v1
30+
-
31+
name: Login to DockerHub
32+
uses: docker/login-action@v1
33+
with:
34+
username: ${{ secrets.DOCKERHUB_USERNAME }}
35+
password: ${{ secrets.DOCKERHUB_TOKEN }}
36+
-
37+
name: Build and push
38+
uses: docker/build-push-action@v2
39+
with:
40+
context: .
41+
platforms: linux/amd64,linux/arm64
42+
push: true
43+
tags: user/app:latest
44+
```

0 commit comments

Comments
 (0)