Skip to content

Commit 1120e12

Browse files
author
Sean Sundberg
committed
Adds workflow to build and push multi-arch image
- Adds workflow with support for amd64 and arm64 architectures - Updates Dockerfile to support multiple architectures through TARGETPLATFORM arg closes #47 Signed-off-by: Sean Sundberg <seansund@us.ibm.com>
1 parent 4ce871e commit 1120e12

2 files changed

Lines changed: 74 additions & 20 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Docker build
2+
3+
# Controls when the workflow will run
4+
on:
5+
push:
6+
branches:
7+
- 'v*.*'
8+
tags:
9+
- 'v*.*.*-v*.*'
10+
pull_request:
11+
branches:
12+
- 'v*.*'
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@v2
23+
24+
# https://github.com/docker/setup-buildx-action
25+
- name: Set up Docker Buildx
26+
id: buildx
27+
uses: docker/setup-buildx-action@v2
28+
29+
- name: Login to Docker Hub
30+
uses: docker/login-action@v2
31+
with:
32+
username: ${{ secrets.DOCKER_USER }}
33+
password: ${{ secrets.DOCKER_TOKEN }}
34+
35+
- name: Login to CNTK Quay
36+
uses: docker/login-action@v2
37+
with:
38+
registry: quay.io
39+
username: ${{ secrets.QUAY_CNTK_USERNAME }}
40+
password: ${{ secrets.QUAY_CNTK_TOKEN }}
41+
42+
- name: Docker CNTK meta
43+
id: cntk-meta
44+
uses: docker/metadata-action@v4
45+
with:
46+
# list of Docker images to use as base name for tags
47+
images: |
48+
quay.io/cloudnativetoolkit/cli-tools
49+
# Docker tags based on the following events/attributes
50+
tags: |
51+
type=semver,pattern={{version}}
52+
type=ref,event=branch
53+
type=raw,value=latest,enable={{is_default_branch}}
54+
55+
- name: Build and push
56+
uses: docker/build-push-action@v3
57+
with:
58+
context: .
59+
push: ${{ github.event_name != 'pull_request' }}
60+
platforms: linux/amd64,linux/arm64
61+
tags: ${{ steps.cntk-meta.outputs.tags }}
62+
labels: ${{ steps.cntk-meta.outputs.labels }}

Dockerfile

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM docker.io/hashicorp/terraform:1.1.9
22

3+
ARG TARGETPLATFORM
34
ENV OPENSHIFT_CLI_VERSION 4.10
45

56
RUN apk add --update-cache \
@@ -13,6 +14,7 @@ RUN apk add --update-cache \
1314
perl \
1415
openvpn \
1516
gcompat \
17+
jq \
1618
&& rm -rf /var/cache/apk/*
1719

1820

@@ -80,18 +82,12 @@ RUN curl -L https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-${O
8082
mkdir tmp && \
8183
cd tmp && \
8284
tar xzf ../oc-client.tar.gz && \
83-
sudo mkdir -p /usr/local/fix && \
84-
sudo chmod a+rwx /usr/local/fix && \
85-
sudo cp ./oc /usr/local/fix && \
86-
sudo chmod +x /usr/local/fix/oc && \
85+
sudo mv ./oc /usr/local/bin && \
8786
cd .. && \
8887
rm -rf tmp && \
89-
rm oc-client.tar.gz && \
90-
echo '/lib/ld-musl-x86_64.so.1 --library-path /lib /usr/local/fix/oc $@' > ./oc && \
91-
sudo mv ./oc /usr/local/bin && \
92-
sudo chmod +x /usr/local/bin/oc
88+
rm oc-client.tar.gz
9389

94-
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
90+
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/$(if [[ "$TARGETPLATFORM" == "linux/arm64" ]]; then echo "arm64"; else echo "amd64"; fi)/kubectl" && \
9591
chmod +x ./kubectl && \
9692
sudo mv ./kubectl /usr/local/bin
9793

@@ -100,25 +96,21 @@ RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/s
10096

10197
#RUN sudo chown -R devops ${HOME} && sudo chgrp -R 0 ${HOME} && sudo chmod -R g=u ${HOME}
10298

103-
RUN curl -LO https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && \
104-
chmod a+x jq-linux64 && \
105-
sudo mv jq-linux64 /usr/local/bin/jq
106-
107-
RUN wget -q -O ./yq $(wget -q -O - https://api.github.com/repos/mikefarah/yq/releases/tags/3.4.1 | jq -r '.assets[] | select(.name == "yq_linux_amd64") | .browser_download_url') && \
99+
RUN wget -q -O ./yq $(wget -q -O - https://api.github.com/repos/mikefarah/yq/releases/tags/3.4.1 | jq -r --arg NAME "yq_linux_$(if [[ "$TARGETPLATFORM" == "linux/arm64" ]]; then echo "arm64"; else echo "amd64"; fi)" '.assets[] | select(.name == $NAME) | .browser_download_url') && \
108100
chmod +x ./yq && \
109101
sudo mv ./yq /usr/bin/yq
110102

111-
RUN wget -q -O ./yq4 $(wget -q -O - https://api.github.com/repos/mikefarah/yq/releases/tags/v4.16.1 | jq -r '.assets[] | select(.name == "yq_linux_amd64") | .browser_download_url') && \
103+
RUN wget -q -O ./yq4 $(wget -q -O - https://api.github.com/repos/mikefarah/yq/releases/tags/v4.16.1 | jq -r --arg NAME "yq_linux_$(if [[ "$TARGETPLATFORM" == "linux/arm64" ]]; then echo "arm64"; else echo "amd64"; fi)" '.assets[] | select(.name == $NAME) | .browser_download_url') && \
112104
chmod +x ./yq4 && \
113105
sudo mv ./yq4 /usr/bin/yq4
114106

115-
RUN wget -q -O ./helm.tar.gz https://get.helm.sh/helm-v3.8.2-linux-amd64.tar.gz && \
116-
tar xzf ./helm.tar.gz linux-amd64/helm && \
117-
sudo mv ./linux-amd64/helm /usr/bin/helm && \
118-
rmdir ./linux-amd64 && \
107+
RUN wget -q -O ./helm.tar.gz https://get.helm.sh/helm-v3.8.2-linux-$(if [[ "$TARGETPLATFORM" == "linux/arm64" ]]; then echo "arm64"; else echo "amd64"; fi).tar.gz && \
108+
tar xzf ./helm.tar.gz linux-$(if [[ "$TARGETPLATFORM" == "linux/arm64" ]]; then echo "arm64"; else echo "amd64"; fi)/helm && \
109+
sudo mv ./linux-$(if [[ "$TARGETPLATFORM" == "linux/arm64" ]]; then echo "arm64"; else echo "amd64"; fi)/helm /usr/bin/helm && \
110+
rmdir ./linux-$(if [[ "$TARGETPLATFORM" == "linux/arm64" ]]; then echo "arm64"; else echo "amd64"; fi) && \
119111
rm ./helm.tar.gz
120112

121-
RUN wget -q -O ./terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v0.36.10/terragrunt_linux_amd64 && \
113+
RUN wget -q -O ./terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v0.36.10/terragrunt_linux_$(if [[ "$TARGETPLATFORM" == "linux/arm64" ]]; then echo "arm64"; else echo "amd64"; fi) && \
122114
chmod +x ./terragrunt && \
123115
sudo mv ./terragrunt /usr/bin/terragrunt
124116

0 commit comments

Comments
 (0)