Maximize build space #13
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: build | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-22.04 | |
# A local registry helps us reuse the built image between steps | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
steps: | |
# https://github.com/easimon/maximize-build-space/blob/6ae56c86ea8db291ae39f62352a412c36ab8179b/action.yml#L110-L126 | |
- name: Maximize build space | |
run: | | |
set -ex | |
a=$(df / | tail -n 1 | awk '{print $4}') | |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL | |
b=$(df / | tail -n 1 | awk '{print $4}') | |
d="$(expr $(($b-$a)) / 1000000000 )GB" | |
echo "Saved $d" | |
df -hl | |
- uses: actions/checkout@v3 | |
# QEMU is used for non-x86_64 builds | |
- uses: docker/setup-qemu-action@v2 | |
# buildx adds additional features to docker build | |
- uses: docker/setup-buildx-action@v2 | |
with: | |
driver-opts: network=host | |
# cache slightly improves rebuild time | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Build | |
uses: docker/build-push-action@v3 | |
id: docker_build | |
with: | |
context: . | |
file: ./Dockerfile | |
tags: | | |
localhost:5000/fnndsc/microminc-builder:latest | |
platforms: linux/amd64,linux/arm64,linux/ppc64le | |
push: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
- name: Test | |
run: | | |
podman run --rm -it \ | |
-v "$PWD/test.sh:/test.sh:ro" \ | |
localhost:5000/fnndsc/microminc-builder:latest /test.sh | |
- name: Login to DockerHub | |
id: dockerhub_login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push images | |
uses: docker/build-push-action@v3 | |
id: docker_push | |
with: | |
context: . | |
file: ./Dockerfile | |
tags: | | |
docker.io/fnndsc/microminc-builder:latest | |
docker.io/fnndsc/microminc-builder:2.1.1 | |
ghcr.io/fnndsc/microminc-builder:latest | |
ghcr.io/fnndsc/microminc-builder:2.1.1 | |
platforms: linux/amd64,linux/arm64,linux/ppc64le | |
push: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
- name: Update DockerHub description | |
uses: peter-evans/dockerhub-description@v3 | |
continue-on-error: true # it is not crucial that this works | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
short-description: Minimize images of CIVET + MINC tools | |
readme-filepath: ./README.md |