Skip to content

Commit 6821e0f

Browse files
authored
Merge pull request #20 from macbre/ci-build-improved
Use the Docker image as a source of cache layers
2 parents 6a0917a + 15314a7 commit 6821e0f

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

.github/workflows/dockerimage.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,44 @@ on:
99
jobs:
1010

1111
build:
12-
1312
runs-on: ubuntu-latest
1413

1514
steps:
1615
- uses: actions/checkout@v2
1716

1817
- name: Build the Docker image
18+
env:
19+
CACHE_IMAGE: macbre/nginx-brotli:latest
20+
21+
# @see https://docs.docker.com/develop/develop-images/build_enhancements/
22+
COMPOSE_DOCKER_CLI_BUILD: "1"
23+
DOCKER_BUILDKIT: "1"
24+
1925
run: |
20-
docker build . --tag ${{ github.repository }}
26+
# build an image using the current Docker Hub container image as a layers cache
27+
28+
# @see https://docs.docker.com/engine/reference/commandline/build/#specifying-external-cache-sources
29+
# no need to "docker pull $CACHE_IMAGE", BuildKit is clever enough to pull it when needed
30+
docker build . \
31+
--tag ${{ github.repository }} \
32+
--build-arg BUILDKIT_INLINE_CACHE=1 \
33+
--cache-from $CACHE_IMAGE
2134
docker images
2235
2336
- name: Run nginx -V
2437
run: docker run -t ${{ github.repository }} nginx -V
2538

2639
- name: Serve a static asset
2740
run: |
28-
docker run --detach --rm -p 0.0.0.0:8888:80 -v "$PWD/tests":/static:ro -v "$PWD/tests/static.conf":/etc/nginx/conf.d/static.conf:ro -v "$PWD/tests/env.conf":/etc/nginx/main.d/env.conf:ro --env FOO=foo-test-value --name test_nginx -t ${{ github.repository }}
41+
docker run --detach --rm \
42+
-p 0.0.0.0:8888:80 \
43+
-v "$PWD/tests":/static:ro \
44+
-v "$PWD/tests/static.conf":/etc/nginx/conf.d/static.conf:ro \
45+
-v "$PWD/tests/env.conf":/etc/nginx/main.d/env.conf:ro \
46+
--env FOO=foo-test-value \
47+
--name test_nginx \
48+
-t ${{ github.repository }}
49+
2950
sleep 2; docker ps
3051
curl -v --compressed 0.0.0.0:8888 2>&1 | tee /tmp/out
3152

0 commit comments

Comments
 (0)