Skip to content

Commit 3ab4aab

Browse files
authored
feat: fixed various issues in the ARM64 build pipeline (#1198)
2 parents c486435 + 5dd156e commit 3ab4aab

File tree

2 files changed

+57
-9
lines changed

2 files changed

+57
-9
lines changed

.github/workflows/build-publish-mcr.yml

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ permissions:
1414
contents: read
1515

1616
env:
17-
# `public` indicates images to MCR wil be publicly available, and will be removed in the final MCR images
17+
# `public` indicates images to MCR will be publicly available, and will be removed in the final MCR images
1818
REGISTRY_REPO: public/aks/fleet
1919
ARC_REGISTRY_REPO: public/microsoft.fleetmember
2020

@@ -106,7 +106,7 @@ jobs:
106106
MCS_CONTROLLER_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.fleet_networking_version }}
107107
MEMBER_NET_CONTROLLER_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.fleet_networking_version }}
108108
REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.ARC_REGISTRY_REPO}}
109-
109+
110110
publish-images-arm64:
111111
runs-on:
112112
labels: [self-hosted, "1ES.Pool=1es-aks-fleet-pool-ubuntu-arm64"]
@@ -116,36 +116,70 @@ jobs:
116116
with:
117117
ref: ${{ needs.prepare-variables.outputs.release_tag }}
118118
- name: 'Install the Azure CLI'
119+
# Note (chenyu1): the self-hosted 1ES ARM64 pool, for some reason, does not have Azure CLI installed by default;
120+
# install it manually here.
119121
run:
120122
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
123+
- name: 'Set up build essential meta package'
124+
# Note (chenyu1): the self-hosted 1ES ARM64 pool, for some reason, does not have the common build
125+
# tools (e.g., make) installed by default; install the build-essential meta package to set them up.
126+
run: |
127+
sudo apt-get update
128+
sudo apt-get install -y build-essential
129+
- name: 'Set up Docker'
130+
# Note (chenyu1): the self-hosted 1ES ARM64 pool, for some reason, does not have Docker installed by default,
131+
# and cannot have Docker installed via the docker/setup-docker-action Github Action, hence the manual setup
132+
# steps here.
133+
run: |
134+
sudo apt-get update
135+
sudo apt-get -y install ca-certificates curl
136+
sudo install -m 0755 -d /etc/apt/keyrings
137+
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
138+
sudo chmod a+r /etc/apt/keyrings/docker.asc
139+
echo \
140+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
141+
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
142+
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
143+
sudo apt-get update
144+
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
121145
- name: 'Login the ACR'
122146
run: |
123-
az login --identity
147+
az login --identity
124148
az acr login -n ${{ secrets.AZURE_REGISTRY }}
149+
- name: 'Verify Docker CLI'
150+
# Note (chenyu1): the Docker installation has to be invoked with root privileges by default; for
151+
# simplicity reasons in this pipeline we will make no attempt to enable rootless Docker usage.
152+
run: |
153+
sudo docker version
154+
sudo docker info
125155
- name: Build and publish hub-agent
156+
# Note (chenyu1): must preserve the environment here.
126157
run: |
127-
make docker-build-hub-agent
158+
sudo -E make docker-build-hub-agent
128159
env:
129160
HUB_AGENT_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-arm64
130161
REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}
131162
TARGET_ARCH: arm64
132163
- name: Build and publish member-agent
164+
# Note (chenyu1): must preserve the environment here.
133165
run: |
134-
make docker-build-member-agent
166+
sudo -E make docker-build-member-agent
135167
env:
136168
MEMBER_AGENT_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-arm64
137169
REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}
138-
TARGET_ARCH: linux/arm64
170+
TARGET_ARCH: arm64
139171
- name: Build and publish refresh-token
172+
# Note (chenyu1): must preserve the environment here.
140173
run: |
141-
make docker-build-refresh-token
174+
sudo -E make docker-build-refresh-token
142175
env:
143176
REFRESH_TOKEN_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-arm64
144177
REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}
145178
TARGET_ARCH: arm64
146179
- name: Build and publish crd-installer
180+
# Note (chenyu1): must preserve the environment here.
147181
run: |
148-
make docker-build-crd-installer
182+
sudo -E make docker-build-crd-installer
149183
env:
150184
CRD_INSTALLER_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-arm64
151185
REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}

Makefile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,24 @@ push:
300300
$(MAKE) OUTPUT_TYPE="type=registry" docker-build-hub-agent docker-build-member-agent docker-build-refresh-token docker-build-crd-installer
301301

302302
# By default, docker buildx create will pull image moby/buildkit:buildx-stable-1 and hit the too many requests error
303+
#
304+
# Note (chenyu1): the step below sets up emulation for building/running non-native binaries on the host. The original
305+
# setup assumes that the Makefile is always run on an x86_64 platform, and adds support for non-x86_64 hosts. Here
306+
# we keep the original setup if the build target is x86_64 platforms (default) for compatibility reasons, but will switch to
307+
# a more general setup for non-x86_64 hosts.
308+
#
309+
# On some systems the emulation setup might not work at all (e.g., macOS on Apple Silicon -> Rosetta 2 will be used
310+
# by Docker Desktop as the default emulation option for AMD64 on ARM64 container compatibility).
303311
.PHONY: docker-buildx-builder
304312
docker-buildx-builder:
305313
@if ! docker buildx ls | grep $(BUILDX_BUILDER_NAME); then \
306-
docker run --rm --privileged mcr.microsoft.com/mirror/docker/multiarch/qemu-user-static:$(QEMU_VERSION) --reset -p yes; \
314+
if [ "$(TARGET_ARCH)" = "amd64" ] ; then \
315+
echo "The target is an x86_64 platform; setting up emulation for other known architectures"; \
316+
docker run --rm --privileged mcr.microsoft.com/mirror/docker/multiarch/qemu-user-static:$(QEMU_VERSION) --reset -p yes; \
317+
else \
318+
echo "Setting up emulation for known architectures"; \
319+
docker run --rm --privileged tonistiigi/binfmt --install all; \
320+
fi ;\
307321
docker buildx create --driver-opt image=mcr.microsoft.com/oss/v2/moby/buildkit:$(BUILDKIT_VERSION) --name $(BUILDX_BUILDER_NAME) --use; \
308322
docker buildx inspect $(BUILDX_BUILDER_NAME) --bootstrap; \
309323
fi

0 commit comments

Comments
 (0)