Skip to content

Commit f95fbfc

Browse files
committed
GitHub Actions: multi-platform container builder
1 parent 06cc986 commit f95fbfc

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎.github/workflows/publish-container.yml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,20 @@ jobs:
2727
packages: write
2828
steps:
2929
- name: Checkout repository
30-
uses: actions/checkout@v2
30+
uses: actions/checkout@v4
31+
32+
# Set up QEMU for multi-platform build
33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v3
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
3138

3239
# Login against a Docker registry except on PR
3340
# https://github.com/docker/login-action
3441
- name: Log into registry ${{ env.REGISTRY }}
3542
if: github.event_name != 'pull_request'
36-
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
43+
uses: docker/login-action@v3
3744
with:
3845
registry: ${{ env.REGISTRY }}
3946
username: ${{ github.actor }}
@@ -43,16 +50,17 @@ jobs:
4350
# https://github.com/docker/metadata-action
4451
- name: Extract Docker metadata
4552
id: meta
46-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
53+
uses: docker/metadata-action@v5
4754
with:
4855
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4956

5057
# Build and push Docker image with Buildx (don't push on PR)
5158
# https://github.com/docker/build-push-action
5259
- name: Build and push Docker image
53-
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
60+
uses: docker/build-push-action@v5
5461
with:
5562
context: .
63+
platforms: linux/amd64,linux/arm64
5664
push: ${{ github.event_name != 'pull_request' }}
5765
tags: ${{ steps.meta.outputs.tags }}
5866
labels: ${{ steps.meta.outputs.labels }}

‎Dockerfile‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ FROM ubuntu:22.04
44
# https://pythonspeed.com/articles/alpine-docker-python/
55
# https://pythonspeed.com/articles/base-image-python-docker-images/
66

7-
ARG build_date=unspecified
7+
ARG build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
88
# After releasing 1.5.5, Hashicorp changed the license from MPL to BSL.
99
# Unless OSPO/Cisco Legal confirms that we can keep using Terraform under the
1010
# new license, we shouldn't update this version.
1111
ARG terraform_version=1.5.5
12-
ARG arch=amd64
12+
ARG TARGETARCH
1313

1414
LABEL org.opencontainers.image.title="Cisco SD-WAN" \
1515
org.opencontainers.image.description="Cisco SD-WAN DevOps" \
@@ -24,10 +24,10 @@ RUN apt update && \
2424
apt clean && \
2525
rm -rf /var/lib/apt/lists/*
2626

27-
RUN curl -#O https://releases.hashicorp.com/terraform/${terraform_version}/terraform_${terraform_version}_linux_${arch}.zip
28-
RUN unzip terraform_${terraform_version}_linux_${arch}.zip
27+
RUN curl -#O https://releases.hashicorp.com/terraform/${terraform_version}/terraform_${terraform_version}_linux_${TARGETARCH}.zip
28+
RUN unzip terraform_${terraform_version}_linux_${TARGETARCH}.zip
2929
RUN mv terraform /usr/bin
30-
RUN rm terraform_${terraform_version}_linux_${arch}.zip
30+
RUN rm terraform_${terraform_version}_linux_${TARGETARCH}.zip
3131

3232
# This adds almost 1GB to the container size. Installing the .deb package has
3333
# similar results, and it doesn't support arm64. We really need to find a way

0 commit comments

Comments
 (0)