Skip to content

Commit

Permalink
Build multiplatform docker images (#430)
Browse files Browse the repository at this point in the history
* Build multiplatform docker images

* try to start from scratch

* Try QEMU action

* Restore missing jobs and clean up the whitespace

* Split the CI jobs, and run the docker build only on merge to master
  • Loading branch information
podhrmic authored Jul 25, 2024
1 parent 251beee commit 6edf463
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 38 deletions.
41 changes: 7 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# version: [4.12.0, 4.14.1]
version: [4.14.1]


runs-on: ubuntu-22.04

steps:
Expand All @@ -31,7 +31,7 @@ jobs:
- name: System dependencies (ubuntu)
run: |
sudo apt install build-essential libgmp-dev z3 opam cmake
- name: Restore cached opam
id: cache-opam-restore
uses: actions/cache/restore@v4
Expand All @@ -52,7 +52,7 @@ jobs:
opam pin --yes -n coq-sail-stdpp https://github.com/rems-project/coq-sail.git#f319aad
opam pin --yes -n coq-cheri-capabilities https://github.com/rems-project/coq-cheri-capabilities.git
opam install --deps-only --yes ./cerberus-lib.opam ./cerberus-cheri.opam
- name: Save cached opam
if: steps.cache-opam-restore.outputs.cache-hit != 'true'
id: cache-opam-save
Expand All @@ -76,9 +76,9 @@ jobs:
cd tests; USE_OPAM='' ./run-ci.sh
cd ..
- name: Download cvc5 release
uses: robinraju/release-downloader@v1
with:
- name: Download cvc5 release
uses: robinraju/release-downloader@v1
with:
repository: cvc5/cvc5
tag: cvc5-1.1.2
fileName: cvc5-Linux-static.zip
Expand All @@ -98,7 +98,7 @@ jobs:
- name: Checkout cn-tutorial
uses: actions/checkout@v4
with:
with:
repository: rems-project/cn-tutorial
path: cn-tutorial

Expand Down Expand Up @@ -143,30 +143,3 @@ jobs:
eval $(opam env --switch=with_coq)
cd tests; USE_OPAM='' ./run-cheri.sh
cd ..
deploy-docker:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build the Docker image
run: |
echo "Building ${{env.CERBERUS_IMAGE_ID}}"
make -f Makefile_docker release_cn
docker tag cn:release ${{env.CERBERUS_IMAGE_ID}}
- name: Push the Docker image
run: docker push ${{env.CERBERUS_IMAGE_ID}}
48 changes: 48 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
push:
branches:
- master

env:
CERBERUS_IMAGE_ID: ghcr.io/rems-project/cerberus/cn:release

# cancel in-progress job when a new push is performed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy-docker:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [linux/amd64, linux/arm64]
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build the Docker image
run: |
echo "Building ${{env.CERBERUS_IMAGE_ID}}"
PLATFORM=${{ matrix.platform }} make -f Makefile_docker release_cn
docker tag cn:release ${{env.CERBERUS_IMAGE_ID}}
- name: Push the Docker image
run: docker push ${{env.CERBERUS_IMAGE_ID}}
11 changes: 7 additions & 4 deletions Makefile_docker
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
.PHONY: all release dev-env deps

PLATFORM ?= linux/amd64
$(info Building for platform $(PLATFORM))

all:
@echo 'targets: deps|release|dev-env'

deps :
docker build --tag cerberus:deps -f Dockerfile.deps .
docker build --platform $(PLATFORM) --tag cerberus:deps -f Dockerfile.deps .

release: deps
docker build --tag cerberus:release -f Dockerfile.release .
docker build --platform $(PLATFORM) --tag cerberus:release -f Dockerfile.release .
@echo 'for example: docker run --volume `PWD`:/data/ cerberus:release cerberus tests/tcc/00_assignment.c --pp=core'

release_cn: deps
docker build --tag cn:release -f Dockerfile.release .
docker build --platform $(PLATFORM) --tag cn:release -f Dockerfile.release .
@echo 'for example: docker run --volume `PWD`:/data/ cn:release cerberus tests/tcc/00_assignment.c --pp=core'

dev-env: deps
docker build --tag cerberus:dev-env -f Dockerfile.dev-env .
docker build --platform $(PLATFORM) --tag cerberus:dev-env -f Dockerfile.dev-env .
@echo 'for example: docker run -ti --volume `PWD`:/home/user1/cerberus/ cerberus:dev-env'

0 comments on commit 6edf463

Please sign in to comment.