Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add multi-platform image build for karmada-dashboard #174

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions .github/workflows/push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,41 @@ jobs:
env:
IMAGE_NAME: karmada/karmada-dashboard-web
BINARY_NAME: karmada-dashboard-web
PLATFORMS: linux/amd64,linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Detect misc info
id: misc
run: |
echo "os=$(go env GOHOSTOS)" >> $GITHUB_OUTPUT
echo "arch=$(go env GOHOSTARCH)" >> $GITHUB_OUTPUT
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "binary_name=$BINARY_NAME" >> $GITHUB_OUTPUT
echo "platforms=$PLATFORMS" >> $GITHUB_OUTPUT
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build karmada-dashboard-web binary
run: make karmada-dashboard-web
run: BUILD_PLATFORMS=${{ steps.misc.outputs.platforms }} make karmada-dashboard-web
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: dashboard_artifact
path: _output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}/dist
path: _output/bin/dist
- name: Display artifact
run: |
ls -al _output/bin
ls -al _output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}/dist
ls -al _output/bin/dist
- name: Extract metadata for the Docker image
id: meta
uses: docker/metadata-action@v5
Expand All @@ -77,13 +83,12 @@ jobs:
uses: docker/build-push-action@v6
with:
file: "cluster/images/build-web.Dockerfile"
context: "_output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}"
context: "_output/bin/"
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: ${{ steps.misc.outputs.platforms }}
build-args: |
BINARY=${{ steps.misc.outputs.binary_name }}
BUILD_PLATFORMS=${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}



build-and-push-api:
Expand All @@ -92,19 +97,25 @@ jobs:
env:
IMAGE_NAME: karmada/karmada-dashboard-api
BINARY_NAME: karmada-dashboard-api
PLATFORMS: linux/amd64,linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Detect misc info
id: misc
run: |
echo "os=$(go env GOHOSTOS)" >> $GITHUB_OUTPUT
echo "arch=$(go env GOHOSTARCH)" >> $GITHUB_OUTPUT
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "binary_name=$BINARY_NAME" >> $GITHUB_OUTPUT
echo "platforms=$PLATFORMS" >> $GITHUB_OUTPUT
- name: Login to DockerHub
uses: docker/login-action@v3
with:
Expand All @@ -116,14 +127,14 @@ jobs:
with:
images: ${{ steps.misc.outputs.image_name }}
- name: Build karmada-dashboard-api binary
run: make karmada-dashboard-api
run: BUILD_PLATFORMS=${{ steps.misc.outputs.platforms }} make karmada-dashboard-api
- name: Build and push image
uses: docker/build-push-action@v6
with:
file: "cluster/images/Dockerfile"
context: "_output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}"
context: "_output/bin/"
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: ${{ steps.misc.outputs.platforms }}
build-args: |
BINARY=${{ steps.misc.outputs.binary_name }}
BUILD_PLATFORMS=${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ build: $(TARGETS)
# Build specific binary
.PHONY: $(TARGETS)
$(TARGETS):
BUILD_PLATFORMS=$(GOOS)/$(GOARCH) hack/build.sh $@
hack/build.sh $@

###################
# Docker Images #
Expand Down
3 changes: 2 additions & 1 deletion cluster/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
FROM alpine:3.21.2

ARG BINARY
ARG TARGETPLATFORM
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache ca-certificates
#tzdata is used to parse the time zone information when using CronFederatedHPA
RUN apk add --no-cache tzdata

COPY ${BINARY} /bin/${BINARY}
COPY ${TARGETPLATFORM}/${BINARY} /bin/${BINARY}
2 changes: 1 addition & 1 deletion cluster/images/build-web.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ RUN apk add --no-cache ca-certificates
#tzdata is used to parse the time zone information when using CronFederatedHPA
RUN apk add --no-cache tzdata
COPY dist /static
COPY ${BINARY} /bin/${BINARY}
COPY ${TARGETPLATFORM}/${BINARY} /bin/${BINARY}
2 changes: 1 addition & 1 deletion cluster/images/buildx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ RUN apk add --no-cache ca-certificates
#tzdata is used to parse the time zone information when using CronFederatedHPA
RUN apk add --no-cache tzdata

COPY ${BINARY} /bin/${BINARY}
COPY ${TARGETPLATFORM}/${BINARY} /bin/${BINARY}