Docker Dev containers for HSG #217
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
name: Docker Dev containers for HSG | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: "0 0/12 * * *" | |
env: | |
TEST_TAG: joewiz/hsg-project:exist-ci | |
# EXIST_VER: 6.2.0 | |
jobs: | |
build: | |
name: Build and Test Images | |
runs-on: ubuntu-latest | |
# NOTE (DP): Test on PRs and pushes | |
if: github.ref == 'refs/heads/main' || github.base_ref == 'main' | |
steps: | |
# SETUP | |
- name: Maximize build space | |
uses: easimon/maximize-build-space@master | |
with: | |
build-mount-path: /var/lib/docker/ | |
remove-dotnet: 'true' | |
remove-android: 'true' | |
remove-haskell: 'true' | |
remove-codeql: 'true' | |
remove-docker-images: 'true' | |
- name: Restart docker | |
run: sudo service docker restart | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
# platforms: all | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Make buildkit default | |
uses: docker/setup-buildx-action@v3 | |
id: buildx | |
with: | |
install: true | |
- name: Install bats | |
run: sudo apt-get install bats | |
# sanity check | |
- name: check os | |
run: | | |
df -h /var/lib/docker | |
df -ih /var/lib/docker | |
- name: Check config | |
run: docker info | |
# BUILD | |
# see https://github.com/felipecrs/docker-images/commit/f74a9532da6549d9562574eb1709ef50cedb640c | |
- name: Build amd image for testing on CI | |
timeout-minutes: 40 | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64 | |
build-args: | | |
TEMPLATING_VERSION=1.1.0 | |
TEI_PUBLISHER_LIB_VERSION=2.10.1 | |
EXPATH_CRYPTO_VERSION=6.0.1 | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
cache-from: type=registry,ref=joewiz/hsg-project:buildcache-x86 | |
cache-to: type=registry,ref=joewiz/hsg-project:buildcache-x86,mode=max | |
- name: Build arm image to populate cache | |
timeout-minutes: 180 | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/arm64 | |
build-args: | | |
TEMPLATING_VERSION=1.1.0 | |
TEI_PUBLISHER_LIB_VERSION=2.10.1 | |
EXPATH_CRYPTO_VERSION=6.0.1 | |
load: true | |
tags: hsg-project:arm | |
cache-from: type=registry,ref=joewiz/hsg-project:buildcache-arm | |
cache-to: type=registry,ref=joewiz/hsg-project:buildcache-arm,mode=max | |
# TEST | |
- name: Start exist-ci containers | |
run: | | |
docker run -dit -p 8080:8080 --health-interval 4s --name exist-ci --rm ${{ env.TEST_TAG }} | |
- name: wait for boot to finish | |
timeout-minutes: 5 | |
run: | | |
while ! docker logs exist-ci | grep -q "Server has started"; \ | |
do sleep 2s; \ | |
done | |
- name: Run tests | |
run: bats --tap test/*.bats | |
# PUSH | |
# Release | |
- name: Push :latest to Dockerhub | |
if: github.ref == 'refs/heads/main' | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./ | |
platforms: linux/amd64,linux/arm64 | |
file: ./Dockerfile | |
build-args: | | |
TEMPLATING_VERSION=1.1.0 | |
TEI_PUBLISHER_LIB_VERSION=2.10.1 | |
EXPATH_CRYPTO_VERSION=6.0.1 | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: joewiz/hsg-project:latest | |
cache-from: | | |
type=registry,ref=joewiz/hsg-project:buildcache-x86 | |
type=registry,ref=joewiz/hsg-project:buildcache-arm |