Daniel's Tech Blog

Cloud Computing, Cloud Native & Kubernetes

Building ARM-based container images with VSTS and Azure Container Registry Build

Azure Container Registry Build is currently in preview, but it is an awesome feature of ACR. But what is ACR Build? It is a native container build capability directly integrated into the Azure Container Registry. So, we do not need container build agents anymore.

The latest update of ACR Build includes the support for ARM-based container images.

-> https://blogs.msdn.microsoft.com/stevelasker/2018/07/25/acr-build-preview-now-supported-in-all-public-regions/

That said we do not have to use QEMU for emulation in our ARM-based container images and on the build agent itself as described in my previous blog post.

-> https://www.danielstechblog.io/building-arm-based-container-images-with-vsts-for-your-azure-iot-edge-deployments/

The files referenced trough out the blog article can be found in my GitHub repository.

-> https://github.com/neumanndaniel/kubernetes/tree/master/iotedge/acrbuild

Based on my previous blog article we only modify the Dockerfile and the build pipeline to leverage ACR Build.

In the Dockerfile itself we remove the COPY statement for the qemu-arm-static file, because with ACR Build this file is no longer necessary.

FROM arm32v7/ubuntu:18.04

LABEL Daniel Neumann <https://www.danielstechblog.io>

WORKDIR /webapp
ADD /go-webapp .
RUN chmod +x ./webapp

ENTRYPOINT ./webapp

EXPOSE 80

All previous tasks in the build pipeline have been deactivated and we add an Azure CLI task instead. The Azure CLI task runs an Inline Script with the following CLI command.

az acr build --registry azstcr1 --image go-webapp-arm:$(Build.BuildNumber) --image go-webapp-arm:latest $(Build.Repository.LocalPath)/go-webapp-arm

All we need is the ACR name for the –registry parameter, the tags for the –image parameters and the source location. As you can see with the recent update of ACR Build, support for multiple tags was added. That makes it very easy to have a specific build number as tag and the general tag latest.

acrbuild

We can now hit Save & queue to kick off the container build.

acrbuild02acrbuild03

Having a look at the log output, we see that the build context was send to ACR and that we do not use QEMU in the container image.

acrbuild04acrbuild05

Now we jump into the Azure portal to have a look at our container image in our Azure Container Registry. As we can see the image is tagged with the build number and latest. Clicking on latest and then on the link under Build ID opens the build logs.

acrbuild06acrbuild07

Finally, a short test run of the image on a Raspberry Pi.

In the end ACR Build enables us to build cross-platform container images without any additional infrastructure. You do not have to use VSTS for example. Instead of using VSTS you can directly kick off the container build via Azure CLI from your workstation or using Azure Cloud Shell. Here is an example.

az acr build --registry azstcr1 --image "go-webapp-arm:{{.Build.ID}}" --image "go-webapp-arm:latest" .

But you can combine your VSTS or GitHub repository with ACR Build through ACR Build tasks. If you need further information about ACR Build or ACR Build tasks, have a look at the Azure documentation.

-> https://docs.microsoft.com/en-us/azure/container-registry/container-registry-build-overview
-> https://docs.microsoft.com/en-us/azure/container-registry/container-registry-tutorial-build-task

WordPress Cookie Notice by Real Cookie Banner