Skip to content

Commit 7d71b73

Browse files
committed
Preliminary updates to CI on the road to building maintainable multiplatform container images
- Build on both x86 and arm runners - Pin version of docker engine to be used for image builds - Only push x86 container images for now Signed-off-by: Phillip Ross <[email protected]>
1 parent 4d56d79 commit 7d71b73

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

.github/workflows/main.yml

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,68 @@ jobs:
1515
make-docker-images:
1616
strategy:
1717
matrix:
18+
runner-platform: ['ubuntu-24.04', 'ubuntu-24.04-arm']
1819
postgres: [13, 14, 15, 16, 17]
1920
postgis: ['3.5']
2021
variant: [default, alpine]
2122
include:
2223
- postgres: 16
2324
postgis: master
2425
variant: default
26+
runner-platform: 'ubuntu-24.04'
2527
- postgres: 17
2628
postgis: master
2729
variant: default
30+
runner-platform: 'ubuntu-24.04'
31+
- postgres: 16
32+
postgis: master
33+
variant: default
34+
runner-platform: 'ubuntu-24.04-arm'
35+
- postgres: 17
36+
postgis: master
37+
variant: default
38+
runner-platform: 'ubuntu-24.04-arm'
2839

29-
name: Build docker image for ${{ matrix.postgres }}-${{ matrix.postgis }} variant ${{ matrix.variant }}
30-
runs-on: ubuntu-24.04
40+
name: Build docker image for ${{ matrix.postgres }}-${{ matrix.postgis }} variant ${{ matrix.variant }} on ${{ matrix.runner-platform }}
41+
runs-on: ${{ matrix.runner-platform }}
3142
continue-on-error: ${{ matrix.postgis == 'master' }}
3243
env:
3344
VERSION: ${{ matrix.postgres }}-${{ matrix.postgis }}
3445
VARIANT: ${{ matrix.variant }}
46+
DOCKER_APT_PKG_VER: '5:28.0.0-1~ubuntu.24.04~noble'
3547

3648
steps:
49+
- name: Install/config specific version of Docker packages
50+
run: |
51+
echo "***** Removing any currently installed conflicting packages..."
52+
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
53+
echo "***** Setting up Docker's APT repo..."
54+
sudo apt-get update
55+
sudo apt-get install ca-certificates curl
56+
sudo install -m 0755 -d /etc/apt/keyrings
57+
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
58+
sudo chmod a+r /etc/apt/keyrings/docker.asc
59+
echo \
60+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
61+
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
62+
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
63+
sudo apt-get update
64+
echo "***** Installing Docker packages..."
65+
sudo apt-get install docker-ce=${{ env.DOCKER_APT_PKG_VER }} docker-ce-cli=${{ env.DOCKER_APT_PKG_VER }} containerd.io docker-buildx-plugin docker-compose-plugin
66+
echo "***** Verifying initial Docker installation..."
67+
docker run hello-world
68+
echo "***** Displaying Docker information..."
69+
docker info
70+
echo "***** Configuring Docker for containerd image store..."
71+
echo "{ \"features\": { \"containerd-snapshotter\": true }}" | sudo tee /etc/docker/daemon.json
72+
sudo systemctl restart docker
73+
docker info -f '{{ .DriverStatus }}'
74+
75+
- name: Load binfmt platforms for QEMU
76+
run: |
77+
docker run --privileged --rm tonistiigi/binfmt --install all
78+
docker images --tree
79+
3780
- name: Checkout source
3881
uses: actions/checkout@v4
3982

@@ -48,7 +91,8 @@ jobs:
4891
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
4992

5093
- name: Push docker image to dockerhub
51-
if: ${{ (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') }}
94+
# !!!! ONLY push the images when built on ubuntu-24.04 x86 runner for now, NOT for ubuntu-24.04-arm runners
95+
if: ${{ (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') && ( matrix.runner-platform == 'ubuntu-24.04' ) }}
5296
env:
5397
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
5498
DOCKERHUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

0 commit comments

Comments
 (0)