Skip to content

Commit 4e09069

Browse files
committedJun 24, 2024·
Merge branch 'arm64-runner'
2 parents bf867f8 + 1ae0f69 commit 4e09069

File tree

1 file changed

+74
-12
lines changed

1 file changed

+74
-12
lines changed
 

‎.github/workflows/main.yml

+74-12
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@ on:
22
- push
33
- workflow_dispatch
44
jobs:
5-
build:
5+
build-amd64:
66
runs-on: ubuntu-latest-64-cores
77
steps:
8-
- name: Set up QEMU
9-
uses: docker/setup-qemu-action@v2
10-
118
- name: Set up Docker Buildx
12-
uses: docker/setup-buildx-action@v2
9+
uses: docker/setup-buildx-action@v3
1310

1411
- name: Log into Docker Hub
15-
uses: docker/login-action@v2
12+
uses: docker/login-action@v3
1613
with:
1714
username: ${{ secrets.DOCKERHUB_USERNAME }}
1815
password: ${{ secrets.DOCKERHUB_TOKEN }}
1916

2017
- name: Setup Python
2118
uses: actions/setup-python@v5
2219
with:
23-
python-version: '3.11'
20+
python-version: '3.12'
2421

2522
- name: Build for linux/amd64
26-
uses: docker/build-push-action@v3
23+
uses: docker/build-push-action@v5
2724
with:
2825
build-args: |
2926
VCS_REF=${{ github.sha }}
27+
BUILDARCH=amd64
3028
load: true
3129
platforms: linux/amd64
32-
tags: cs50/server:amd64
30+
tags: |
31+
cs50/server:amd64
32+
cs50/server:canary-amd64
3333
cache-from: type=registry,ref=cs50/server:amd64-buildcache
3434
cache-to: type=registry,ref=cs50/server:amd64-buildcache,mode=max
3535

@@ -43,31 +43,93 @@ jobs:
4343
run: |
4444
docker push cs50/server:amd64
4545
46+
- name: Push linux/amd64 build to Docker Hub (canary)
47+
run: |
48+
docker push cs50/server:canary-amd64
49+
50+
build-arm64:
51+
runs-on: ubuntu-latest-64-cores-arm
52+
steps:
53+
- name: Install Docker (remove once Docker is pre-installed on arm64 runners)
54+
run: |
55+
export DEBIAN_FRONTEND=noninteractive
56+
sudo apt update
57+
sudo apt install -y ca-certificates curl
58+
sudo install -m 0755 -d /etc/apt/keyrings
59+
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
60+
sudo chmod a+r /etc/apt/keyrings/docker.asc
61+
echo \
62+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
63+
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
64+
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
65+
sudo apt update
66+
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
67+
sudo usermod -aG docker $USER
68+
sudo apt install -y acl
69+
sudo setfacl --modify user:$USER:rw /var/run/docker.sock
70+
71+
- name: Set up Docker Buildx
72+
uses: docker/setup-buildx-action@v3
73+
74+
- name: Log into Docker Hub
75+
uses: docker/login-action@v3
76+
with:
77+
username: ${{ secrets.DOCKERHUB_USERNAME }}
78+
password: ${{ secrets.DOCKERHUB_TOKEN }}
79+
80+
- name: Install Python (replace with setup-python once available on arm64 runners)
81+
run: |
82+
sudo apt install -y python3 python3-pip
83+
4684
- name: Build for linux/arm64
47-
uses: docker/build-push-action@v3
85+
uses: docker/build-push-action@v5
4886
with:
4987
build-args: |
5088
VCS_REF=${{ github.sha }}
89+
BUILDARCH=arm64
5190
load: true
5291
platforms: linux/arm64
53-
tags: cs50/server:arm64
92+
tags: |
93+
cs50/server:arm64
94+
cs50/server:canary-arm64
5495
cache-from: type=registry,ref=cs50/server:arm64-buildcache
5596
cache-to: type=registry,ref=cs50/server:arm64-buildcache,mode=max
5697

5798
- name: Squash for linux/arm64
5899
run: |
59100
pip3 install docker-squash
60-
docker-squash --tag cs50/server:arm64 cs50/server:arm64
101+
$HOME/.local/bin/docker-squash --tag cs50/server:arm64 cs50/server:arm64
61102
62103
- name: Push linux/arm64 build to Docker Hub
63104
if: ${{ github.ref == 'refs/heads/main' }}
64105
run: |
65106
docker push cs50/server:arm64
66107
108+
- name: Push linux/arm64 build to Docker Hub (canary)
109+
run: |
110+
docker push cs50/server:canary-arm64
111+
112+
finalize:
113+
needs: [build-amd64, build-arm64]
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Log into Docker Hub
117+
uses: docker/login-action@v3
118+
with:
119+
username: ${{ secrets.DOCKERHUB_USERNAME }}
120+
password: ${{ secrets.DOCKERHUB_TOKEN }}
121+
67122
- name: Create multi-arch manifest and push to Docker Hub
68123
if: ${{ github.ref == 'refs/heads/main' }}
69124
run: |
70125
docker manifest create cs50/server:latest \
71126
--amend cs50/server:amd64 \
72127
--amend cs50/server:arm64
73128
docker manifest push cs50/server:latest
129+
130+
- name: Create multi-arch manifest and push to Docker Hub (canary)
131+
run: |
132+
docker manifest create cs50/server:canary \
133+
--amend cs50/server:canary-amd64 \
134+
--amend cs50/server:canary-arm64
135+
docker manifest push cs50/server:canary

0 commit comments

Comments
 (0)
Please sign in to comment.