ci: try faster build

This commit is contained in:
Glenn Y. Rolland 2021-12-21 16:14:29 +01:00
parent 137ecfbebb
commit 545221fa52

View file

@ -8,6 +8,9 @@ name: "Build, Test and Publish"
# run it during pull request
pull_request:
env:
IMAGE_NAME: glenux/teaching-boilerplate
jobs:
build-docker-image:
name: "Build docker image"
@ -24,21 +27,14 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build image and save as file
uses: docker/build-push-action@v2
with:
# relative path to the place where source code with Dockerfile
# is located
context: .
file: docker/Dockerfile
# Note: tags has to be all lower-case
tags: |
glenux/teaching-boilerplate:latest
outputs: type=docker,dest=/tmp/teaching-boilerplate.image.tar
run: |
docker build \
--cache-from $IMAGE_NAME:latest \
--tag $IMAGE_NAME:latest \
--build-arg BUILDKIT_INLINE_CACHE=1 \
"."
docker save $IMAGE_NAME:latest > /tmp/image.tar
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
@ -48,12 +44,12 @@ jobs:
echo "BUILD_VERSION=$BUILD_VERSION" >> /tmp/extra.env
cat /tmp/extra.env
- name: Upload artifact
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: teaching-boilerplate-image
name: artifacts
path: |
/tmp/teaching-boilerplate.image.tar
/tmp/image.tar
/tmp/extra.env
test-docker-image:
@ -68,7 +64,7 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: teaching-boilerplate-image
name: artifacts
path: /tmp
- name: Load environment
@ -77,7 +73,7 @@ jobs:
- name: Load image
run: |
docker load --input /tmp/teaching-boilerplate.image.tar
docker load --input /tmp/image.tar
docker image ls -a
- name: Build HTML for docs
@ -101,7 +97,7 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: teaching-boilerplate-image
name: artifacts
path: /tmp
- name: Load environment
@ -114,7 +110,7 @@ jobs:
- name: Load image
run: |
docker load --input /tmp/myimage.tar
docker load --input /tmp/image.tar
docker image ls -a
- name: Login to DockerHub