From 4e073ddd2d80be24c237364a7b5b08a7da6286b9 Mon Sep 17 00:00:00 2001 From: Antony Chazapis Date: Mon, 23 Oct 2023 17:23:42 +0300 Subject: [PATCH] build: Add support for RISC-V Signed-off-by: Antony Chazapis --- .github/workflows/release.yaml | 18 +++++++++++++----- Dockerfile | 23 ++++++++++++++++------- Makefile | 7 ++++--- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3b49e56f5733..dab3048d3904 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - platform: [ linux/amd64, linux/arm64 ] + platform: [ linux/amd64, linux/arm64, linux/riscv64 ] target: [ workflow-controller, argocli, argoexec ] steps: - uses: actions/checkout@v4 @@ -79,6 +79,13 @@ jobs: tag_suffix=$(echo $PLATFORM | sed -r "s/\//-/g") image_name="${DOCKERIO_ORG}/${TARGET}:${tag}-${tag_suffix}" + extra_build_args="" + if [ $PLATFORM = "linux/riscv64" ]; then + extra_build_args="--build-arg BUILDER_IMAGE=riscv64/alpine:edge \ + --build-arg UI_IMAGE=riscv64/alpine:edge \ + --build-arg DISTROLESS_IMAGE=ghcr.io/go-riscv/distroless/static-unstable" + fi + docker buildx build \ --cache-from "type=local,src=/tmp/.buildx-cache" \ --cache-to "type=local,dest=/tmp/.buildx-cache" \ @@ -86,6 +93,7 @@ jobs: --build-arg GIT_COMMIT=$GIT_COMMIT \ --build-arg GIT_TAG=$GIT_TAG \ --build-arg GIT_TREE_STATE=$GIT_TREE_STATE \ + $extra_build_args \ --platform="${PLATFORM}" \ --target $TARGET \ --provenance=false \ @@ -186,11 +194,11 @@ jobs: image_name="${docker_org}/${target}:${tag}" if [ $target = "argoexec" ]; then - docker manifest create $image_name ${image_name}-linux-arm64 ${image_name}-linux-amd64 ${image_name}-windows - docker manifest create quay.io/$image_name quay.io/${image_name}-linux-arm64 quay.io/${image_name}-linux-amd64 quay.io/${image_name}-windows + docker manifest create $image_name ${image_name}-linux-riscv64 ${image_name}-linux-arm64 ${image_name}-linux-amd64 ${image_name}-windows + docker manifest create quay.io/$image_name quay.io/${image_name}-linux-riscv64 quay.io/${image_name}-linux-arm64 quay.io/${image_name}-linux-amd64 quay.io/${image_name}-windows else - docker manifest create $image_name ${image_name}-linux-arm64 ${image_name}-linux-amd64 - docker manifest create quay.io/$image_name quay.io/${image_name}-linux-arm64 quay.io/${image_name}-linux-amd64 + docker manifest create $image_name ${image_name}-linux-riscv64 ${image_name}-linux-arm64 ${image_name}-linux-amd64 + docker manifest create quay.io/$image_name quay.io/${image_name}-linux-riscv64 quay.io/${image_name}-linux-arm64 quay.io/${image_name}-linux-amd64 fi docker manifest push $image_name diff --git a/Dockerfile b/Dockerfile index 8bf862bed9a1..0a63fe697ba2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,15 @@ ARG GIT_COMMIT=unknown ARG GIT_TAG=unknown ARG GIT_TREE_STATE=unknown +ARG BUILDER_IMAGE=golang:1.21-alpine3.18 +ARG UI_IMAGE=node:20-alpine +ARG DISTROLESS_IMAGE=gcr.io/distroless/static -FROM golang:1.21-alpine3.18 as builder +FROM $BUILDER_IMAGE as builder -RUN apk update && apk add --no-cache \ +RUN apk update && \ + (command -v go >/dev/null 2>&1 || apk add --no-cache go) && \ + apk add --no-cache \ git \ make \ ca-certificates \ @@ -24,9 +29,13 @@ COPY . . #################################################################################################### -FROM node:20-alpine as argo-ui +FROM $UI_IMAGE as argo-ui -RUN apk update && apk add --no-cache git +RUN apk update && \ + (command -v node >/dev/null 2>&1 || apk add --no-cache nodejs-current) && \ + (command -v yarn >/dev/null 2>&1 || apk add --no-cache yarn) && \ + apk add --no-cache \ + git COPY ui/package.json ui/yarn.lock ui/ @@ -76,7 +85,7 @@ RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache #################################################################################################### -FROM gcr.io/distroless/static as argoexec +FROM $DISTROLESS_IMAGE as argoexec COPY --from=argoexec-build /go/src/github.com/argoproj/argo-workflows/dist/argoexec /bin/ COPY --from=argoexec-build /etc/mime.types /etc/mime.types @@ -87,7 +96,7 @@ ENTRYPOINT [ "argoexec" ] #################################################################################################### -FROM gcr.io/distroless/static as workflow-controller +FROM $DISTROLESS_IMAGE as workflow-controller USER 8737 @@ -99,7 +108,7 @@ ENTRYPOINT [ "workflow-controller" ] #################################################################################################### -FROM gcr.io/distroless/static as argocli +FROM $DISTROLESS_IMAGE as argocli USER 8737 diff --git a/Makefile b/Makefile index e1a93a2fbed7..f5a557571e72 100644 --- a/Makefile +++ b/Makefile @@ -184,6 +184,7 @@ dist/argo-linux-amd64: GOARGS = GOOS=linux GOARCH=amd64 dist/argo-linux-arm64: GOARGS = GOOS=linux GOARCH=arm64 dist/argo-linux-ppc64le: GOARGS = GOOS=linux GOARCH=ppc64le dist/argo-linux-s390x: GOARGS = GOOS=linux GOARCH=s390x +dist/argo-linux-riscv64: GOARGS = GOOS=linux GOARCH=riscv64 dist/argo-darwin-amd64: GOARGS = GOOS=darwin GOARCH=amd64 dist/argo-darwin-arm64: GOARGS = GOOS=darwin GOARCH=arm64 dist/argo-windows-amd64: GOARGS = GOOS=windows GOARCH=amd64 @@ -211,7 +212,7 @@ endif argocli-image: .PHONY: clis -clis: dist/argo-linux-amd64.gz dist/argo-linux-arm64.gz dist/argo-linux-ppc64le.gz dist/argo-linux-s390x.gz dist/argo-darwin-amd64.gz dist/argo-darwin-arm64.gz dist/argo-windows-amd64.gz +clis: dist/argo-linux-amd64.gz dist/argo-linux-arm64.gz dist/argo-linux-ppc64le.gz dist/argo-linux-s390x.gz dist/argo-linux-riscv64.gz dist/argo-darwin-amd64.gz dist/argo-darwin-arm64.gz dist/argo-windows-amd64.gz # controller @@ -487,7 +488,7 @@ argosay: ifeq ($(DOCKER_PUSH),true) cd test/e2e/images/argosay/v2 && \ docker buildx build \ - --platform linux/amd64,linux/arm64 \ + --platform linux/amd64,linux/arm64,linux/riscv64 \ -t argoproj/argosay:v2 \ --push \ . @@ -504,7 +505,7 @@ argosayv1: ifeq ($(DOCKER_PUSH),true) cd test/e2e/images/argosay/v1 && \ docker buildx build \ - --platform linux/amd64,linux/arm64 \ + --platform linux/amd64,linux/arm64,linux/riscv64 \ -t argoproj/argosay:v1 \ --push \ .