Skip to content

Commit 4ef9d1b

Browse files
committed
Add support for arm64 image
1 parent 8effe29 commit 4ef9d1b

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

.github/workflows/build-docker-image.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ jobs:
3737
if: github.repository == 'apache/cloudstack-kubernetes-provider' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
3838
runs-on: ubuntu-22.04
3939
steps:
40-
- name: Login to Docker Registry
41-
uses: docker/login-action@v3
42-
with:
43-
registry: ${{ secrets.DOCKER_REGISTRY }}
44-
username: ${{ secrets.DOCKERHUB_USER }}
45-
password: ${{ secrets.DOCKERHUB_TOKEN }}
46-
4740
- name: Set Docker repository name
4841
run: echo "DOCKER_REPOSITORY=apache" >> $GITHUB_ENV
4942

@@ -57,8 +50,23 @@ jobs:
5750
- name: Set Docker image FULL TAG
5851
run: echo "FULL_TAG=$(if [ "${{ secrets.DOCKER_REGISTRY }}" = "" ];then echo ${DOCKER_REPOSITORY}/cloudstack-kubernetes-provider:${TAG};else echo ${{ secrets.DOCKER_REGISTRY }}/${DOCKER_REPOSITORY}/cloudstack-kubernetes-provider:${TAG};fi)" >> $GITHUB_ENV
5952

60-
- name: Build the Docker image for cloudstack-kubernetes-provider
61-
run: docker build . --file Dockerfile --tag ${FULL_TAG}
53+
- name: Set up Docker Buildx
54+
uses: docker/setup-buildx-action@v3
6255

63-
- name: Push Docker image to Docker Registry
64-
run: docker push ${FULL_TAG}
56+
- name: Login to Docker Registry
57+
uses: docker/login-action@v3
58+
with:
59+
registry: ${{ secrets.DOCKER_REGISTRY }}
60+
username: ${{ secrets.DOCKERHUB_USER }}
61+
password: ${{ secrets.DOCKERHUB_TOKEN }}
62+
63+
- name: Build and push Docker image for cloudstack-kubernetes-provider (multi-arch)
64+
uses: docker/build-push-action@v5
65+
with:
66+
context: .
67+
file: ./Dockerfile
68+
platforms: linux/amd64,linux/arm64
69+
push: true
70+
tags: ${{ env.FULL_TAG }}
71+
cache-from: type=registry,ref=${{ env.FULL_TAG }}-cache
72+
cache-to: type=registry,ref=${{ env.FULL_TAG }}-cache,mode=max

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
FROM golang:1.21 as builder
18+
FROM --platform=$BUILDPLATFORM golang:1.21 AS builder
19+
ARG TARGETPLATFORM
20+
ARG BUILDPLATFORM
21+
ARG TARGETOS
22+
ARG TARGETARCH
1923
COPY . /go/src/github.com/apache/cloudstack-kubernetes-provider
2024
WORKDIR /go/src/github.com/apache/cloudstack-kubernetes-provider
21-
RUN make clean && CGO_ENABLED=0 GOOS=linux make
25+
RUN make clean && CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} make
2226

2327
FROM gcr.io/distroless/static:nonroot
2428
COPY --from=builder /go/src/github.com/apache/cloudstack-kubernetes-provider/cloudstack-ccm /app/cloudstack-ccm

0 commit comments

Comments
 (0)