diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index c512d5e7..9832ad9b 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -9,15 +9,28 @@ on: jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build the Docker image + env: + CACHE_IMAGE: macbre/nginx-brotli:latest + + # @see https://docs.docker.com/develop/develop-images/build_enhancements/ + COMPOSE_DOCKER_CLI_BUILD: "1" + DOCKER_BUILDKIT: "1" + run: | - docker build . --tag ${{ github.repository }} + # build an image using the current Docker Hub container image as a layers cache + + # @see https://docs.docker.com/engine/reference/commandline/build/#specifying-external-cache-sources + # no need to "docker pull $CACHE_IMAGE", BuildKit is clever enough to pull it when needed + docker build . \ + --tag ${{ github.repository }} \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --cache-from $CACHE_IMAGE docker images - name: Run nginx -V @@ -25,7 +38,15 @@ jobs: - name: Serve a static asset run: | - 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 }} + 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 }} + sleep 2; docker ps curl -v --compressed 0.0.0.0:8888 2>&1 | tee /tmp/out