Skip to content

Docker

Docker #260

Workflow file for this run

name: Docker
on:
# Run this action every day
schedule:
- cron: '30 18 * * *'
# Run this action any time any dockerfile changes
pull_request:
paths:
- 'Dockerfile.**'
- '**docker.yml'
env:
CN_IMAGE_ID: ghcr.io/rems-project/cn
# Cancelling an in-progress job when a new push is performed causes the CI to
# show up as failed: https://github.com/orgs/community/discussions/8336
# This is noisy. If we want to enable that, we should consider:
# https://github.com/MercuryTechnologies/delete-cancelled-runs
concurrency:
group: docker-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
build-and-release:
name: Docker -- Build and Release
strategy:
matrix:
os: [ubuntu, redhat, devcontainer]
runner: [latest, 24.04-arm]
runs-on: ubuntu-${{ matrix.runner }}
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 ${{ matrix.os }}-${{ matrix.runner }} image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.CN_IMAGE_ID }}:release-${{ matrix.os }}-${{ matrix.runner }}
file: Dockerfile.${{ matrix.os }}
github-token: ${{ secrets.GITHUB_TOKEN }}
combine-multiplatform:
name: Docker -- Combine Multiplatform
if: ${{ github.event_name != 'pull_request' }}
strategy:
matrix:
os: [ubuntu, redhat, devcontainer]
runs-on: ubuntu-latest
needs: [build-and-release]
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: Create ${{ matrix.os }} manifest and push
run: |
docker manifest create \
${{ env.CN_IMAGE_ID }}:release-${{ matrix.os }} \
--amend ${{ env.CN_IMAGE_ID }}:release-${{ matrix.os }}-latest \
--amend ${{ env.CN_IMAGE_ID }}:release-${{ matrix.os }}-24.04-arm
docker manifest push ${{ env.CN_IMAGE_ID }}:release-${{ matrix.os }}
# Other CI is testing anyway - if need be, can run tests in Dockerfile itself
test-docker-images:
name: Docker -- Test Docker Images
if: ${{ github.event_name != 'pull_request' }}
strategy:
matrix:
os: [ubuntu, redhat, devcontainer]
runs-on: ubuntu-latest
needs: [combine-multiplatform]
steps:
- uses: actions/checkout@v4
- name: Run CI tests
run: |
docker pull ${{env.CN_IMAGE_ID}}:release-${{ matrix.os }}
docker run -v $PWD:/work -w /work ${{env.CN_IMAGE_ID}}:release-${{ matrix.os }} tests/diff-prog.py cn tests/cn/verify.json