Skip to content

Commit e0f17b8

Browse files
committed
added multiarch support
1 parent 54fee81 commit e0f17b8

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

.github/workflows/build_util.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build Util Container
33

44
on:
55
push:
6-
branches: ['release']
6+
branches: ['release', 'multiarch']
77
workflow_dispatch:
88

99
jobs:
@@ -38,8 +38,8 @@ jobs:
3838
- name: Checkout code
3939
uses: actions/checkout@v3
4040

41-
# - name: Set up QEMU
42-
# uses: docker/setup-qemu-action@v2
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v2
4343

4444
- name: Set up Docker Buildx
4545
uses: docker/setup-buildx-action@v2
@@ -56,13 +56,15 @@ jobs:
5656
uses: docker/metadata-action@v4
5757
with:
5858
images: ghcr.io/${{ github.actor }}/util
59+
tags: test-latest
5960

6061
- name: Build and push Docker image
6162
uses: docker/build-push-action@v3
6263
with:
6364
context: ./utility-pod
6465
file: ./utility-pod/Dockerfile
6566
push: true
67+
platforms: linux/amd64,linux/arm64
6668
tags: ${{ steps.meta.outputs.tags }}
6769
labels: ${{ steps.meta.outputs.labels }}
6870

@@ -72,4 +74,5 @@ jobs:
7274
run: |
7375
docker images
7476
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
75-
grype ghcr.io/${{ github.actor }}/util:release
77+
grype ghcr.io/${{ github.actor }}/util:release --platform linux/amd64
78+
grype ghcr.io/${{ github.actor }}/util:release --platform linux/arm64

utility-pod/Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ RUN apt-get -y update && \
66
apt-get -y upgrade
77

88
ARG DEBIAN_FRONTEND=noninteractive
9+
ARG TARGETPLATFORM
10+
911
RUN apt-get -y install \
1012
build-essential \
1113
curl \
@@ -46,8 +48,12 @@ RUN mkdir /test2 && \
4648
chgrp 0 /test2 && \
4749
chmod g=u /test2
4850

49-
50-
RUN curl -sfL https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip && unzip awscliv2.zip -d awscliv2 && ./awscliv2/aws/install && rm awscliv2.zip
51+
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
52+
curl -sfL https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip ; \
53+
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
54+
curl -sfL https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip -o awscliv2.zip ; \
55+
fi && \
56+
unzip awscliv2.zip -d awscliv2 && ./awscliv2/aws/install && rm awscliv2.zip
5157

5258
RUN curl https://rclone.org/install.sh | bash
5359
# manually run 'rclone config' to setup the environment for each remote.
@@ -56,7 +62,12 @@ RUN curl https://rclone.org/install.sh | bash
5662
RUN curl -sfL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz | tar -zxvf - -C /usr/local/bin/
5763

5864
# install Github CLI tool gh
59-
RUN curl -sfL https://github.com/cli/cli/releases/download/v2.60.0/gh_2.60.0_linux_amd64.tar.gz | tar -zxvf - gh_2.60.0_linux_amd64/bin/gh --strip-components=1
65+
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
66+
curl -sfL https://github.com/cli/cli/releases/download/v2.60.0/gh_2.60.0_linux_amd64.tar.gz | tar -zxvf - gh_2.60.0_linux_amd64/bin/gh --strip-components=1 \
67+
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
68+
curl -sfL https://github.com/cli/cli/releases/download/v2.60.0/gh_2.60.0_linux_arm64.tar.gz | tar -zxvf - gh_2.60.0_linux_arm64/bin/gh --strip-components=1 \
69+
fi
70+
6071

6172
# Set the default shell on openshift to use bash rather than sh
6273
RUN /bin/sed -i 's/SHELL=\/bin\/sh/SHELL=\/bin\/bash/g' /etc/default/useradd

0 commit comments

Comments
 (0)