-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched to Docker's build-publish-action for client's CI
We experienced some problems with `satackey/action-docker-layer-caching` that caused workflow runners to get out of a disk space. This is related to the way the action stores layer incrementaly along with the previously cached ones. See: satackey/action-docker-layer-caching#55 There is also a solution from Docker that we can use for building images but also on later stage of RFC-18 implementation to publish images to registires. See: https://github.com/marketplace/actions/build-and-push-docker-images With the new solution we can also use caching and hopefully it won't cause problems we had before.
- Loading branch information
Showing
1 changed file
with
38 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,22 +13,39 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: satackey/[email protected] | ||
continue-on-error: true # ignore the failure of a step and avoid terminating the job | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.ref }}-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx-${{ github.ref }}- | ||
${{ runner.os }}-buildx- | ||
# TODO: This step was left here intentionally so we can track disk space | ||
# usage for a while. We were trying to fight problems with out of disk space | ||
# that happened due to the size of data restored from cache. The cache size | ||
# was growing linearly with subsequent workflow runs. We want to observe | ||
# available disk space for `/`. Fresh execution starts with 20 GB, we expect | ||
# to have no less than 15 GB after the cache is restored. | ||
- run: sudo df -h | ||
- name: Run Docker build | ||
run: | | ||
docker build \ | ||
--target gobuild \ | ||
--tag go-build-env . | ||
docker build \ | ||
--tag keep-client . | ||
|
||
- name: Build Docker Build Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
target: gobuild | ||
tags: go-build-env | ||
build-args: | | ||
REVISION=${{ github.sha }} | ||
# VERSION= ? TODO: Configure version, sample: 1.7.6 | ||
load: true # load image to local registry to use it in next steps | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
|
||
- name: Create test results directory | ||
run: | | ||
mkdir test-results | ||
|
@@ -47,3 +64,15 @@ jobs: | |
files: ./test-results/unit-tests.xml | ||
check_name: Go Test Results # name under which test results will be presented in GitHub (optional) | ||
comment_on_pr: false # turns off commenting on Pull Requests | ||
|
||
# This step is executed after the tests as we want to configure it eventually | ||
# as image publication step. | ||
- name: Build Docker Runtime Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
tags: keep-client | ||
labels: | | ||
revision=${{ github.sha }} | ||
# TODO: Check branch name and publish to a registry accordingly to the | ||
# environment. | ||
# push: true # publish to registry |