| 1 |
# Generate the containers that we use for builds. |
| 2 |
name: Build Containers |
| 3 |
|
| 4 |
on: |
| 5 |
workflow_call: |
| 6 |
|
| 7 |
env: |
| 8 |
docker-registry: ghcr.io |
| 9 |
docker-config-path: source/ci/docker |
| 10 |
|
| 11 |
jobs: |
| 12 |
# Build the docker container images that we will use for our Linux |
| 13 |
# builds. This will identify the last commit to the repository that |
| 14 |
# updated the docker images, and try to download the image tagged with |
| 15 |
# that sha. If it does not exist, we'll do a docker build and push |
| 16 |
# the image up to GitHub Packages for the actual CI/CD runs. We tag |
| 17 |
# with both the sha and "latest" so that the subsequent runs need not |
| 18 |
# know the sha. Only do this on CI builds (when the event is a "push") |
| 19 |
# because PR builds from forks lack permission to write packages. |
| 20 |
containers: |
| 21 |
strategy: |
| 22 |
matrix: |
| 23 |
container: |
| 24 |
- name: xenial |
| 25 |
- name: bionic |
| 26 |
- name: focal |
| 27 |
- name: noble |
| 28 |
- name: docurium |
| 29 |
- name: bionic-x86 |
| 30 |
dockerfile: bionic |
| 31 |
base: multiarch/ubuntu-core:x86-bionic |
| 32 |
qemu: true |
| 33 |
- name: bionic-arm32 |
| 34 |
dockerfile: bionic |
| 35 |
base: multiarch/ubuntu-core:armhf-bionic |
| 36 |
qemu: true |
| 37 |
- name: bionic-arm64 |
| 38 |
dockerfile: bionic |
| 39 |
base: multiarch/ubuntu-core:arm64-bionic |
| 40 |
qemu: true |
| 41 |
- name: centos7 |
| 42 |
- name: centos8 |
| 43 |
- name: fedora |
| 44 |
runs-on: ubuntu-latest |
| 45 |
name: "Create container: ${{ matrix.container.name }}" |
| 46 |
steps: |
| 47 |
- name: Check out repository |
| 48 |
uses: actions/checkout@v4 |
| 49 |
with: |
| 50 |
path: source |
| 51 |
fetch-depth: 0 |
| 52 |
if: github.event_name != 'pull_request' |
| 53 |
- name: Setup QEMU |
| 54 |
run: docker run --rm --privileged multiarch/qemu-user-static:register --reset |
| 55 |
if: matrix.container.qemu == true |
| 56 |
- name: Download existing container |
| 57 |
run: | |
| 58 |
"${{ github.workspace }}/source/ci/getcontainer.sh" "${{ matrix.container.name }}" "${{ matrix.container.dockerfile }}" |
| 59 |
env: |
| 60 |
DOCKER_REGISTRY: ${{ env.docker-registry }} |
| 61 |
GITHUB_TOKEN: ${{ secrets.github_token }} |
| 62 |
working-directory: ${{ env.docker-config-path }} |
| 63 |
if: github.event_name != 'pull_request' |
| 64 |
- name: Build and publish image |
| 65 |
run: | |
| 66 |
if [ "${{ matrix.container.base }}" != "" ]; then |
| 67 |
BASE_ARG="--build-arg BASE=${{ matrix.container.base }}" |
| 68 |
fi |
| 69 |
docker build -t ${{ env.docker-registry-container-sha }} --build-arg UID=$(id -u) --build-arg GID=$(id -g) ${BASE_ARG} -f ${{ env.dockerfile }} . |
| 70 |
docker tag ${{ env.docker-registry-container-sha }} ${{ env.docker-registry-container-latest }} |
| 71 |
docker push ${{ env.docker-registry-container-sha }} |
| 72 |
docker push ${{ env.docker-registry-container-latest }} |
| 73 |
working-directory: ${{ env.docker-config-path }} |
| 74 |
if: github.event_name != 'pull_request' && env.docker-container-exists != 'true' |