From 3bdd7ece4667d10be6ba2624cff3eebdaf27a05c Mon Sep 17 00:00:00 2001 From: Antony Chazapis Date: Mon, 17 Jul 2023 10:35:57 +0300 Subject: [PATCH] Add support for RISC-V Since Helm does not provide riscv64 binaries yet, we use a separate Dockerfile that builds from source. The entry script has also been modified to function without Helm v2. Signed-off-by: Antony Chazapis --- Dockerfile.dapper | 4 ++-- entry | 21 +++++++++++++-------- package/Dockerfile | 1 - scripts/package | 6 +++++- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 1eec1ac..3c3e49b 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -1,14 +1,14 @@ FROM golang:1.20-alpine3.17 ARG DAPPER_HOST_ARCH -ENV ARCH $DAPPER_HOST_ARCH +ENV HOST_ARCH $DAPPER_HOST_ARCH RUN apk -U add bash git gcc musl-dev docker vim less file curl wget ca-certificates RUN if [ "$(go env GOARCH)" = "amd64" ]; then \ curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.2; \ fi -ENV DAPPER_ENV REPO TAG DRONE_TAG +ENV DAPPER_ENV REPO TAG DRONE_TAG ARCH ENV DAPPER_SOURCE /go/src/github.com/k3s-io/klipper-helm/ ENV DAPPER_OUTPUT ./bin ./dist ENV DAPPER_DOCKER_SOCKET true diff --git a/entry b/entry index 7854da0..11860c6 100755 --- a/entry +++ b/entry @@ -170,7 +170,7 @@ fi set +v -x -if [[ "${BOOTSTRAP}" != "true" ]]; then +if [[ "${BOOTSTRAP}" != "true" ]] && [[ -x "$(command -v helm_v2)" ]]; then tiller --listen=127.0.0.1:44134 --storage=secret & export HELM_HOST=127.0.0.1:44134 @@ -179,14 +179,19 @@ if [[ "${BOOTSTRAP}" != "true" ]]; then fi if [[ "${V2_CHART_EXISTS}" == "1" ]] || [[ "${HELM_VERSION}" == "v2" ]]; then - if [[ "${BOOTSTRAP}" == "true" ]]; then - echo "Can't bootstrap ${HELM} chart" >> ${TERM_LOG} - echo "Error: bootstrap flag can't be set with helm version 2 charts, please remove the bootstrap flag and update the chart" - exit 1 + if ! [[ -x "$(command -v helm_v2)" ]]; then + echo "Helm v2 requested for this command, but it is not available, trying with v3" >> ${TERM_LOG} + echo "Helm v2 requested for this command, but it is not available, trying with v3" + else + if [[ "${BOOTSTRAP}" == "true" ]]; then + echo "Can't bootstrap ${HELM} chart" >> ${TERM_LOG} + echo "Error: bootstrap flag can't be set with helm version 2 charts, please remove the bootstrap flag and update the chart" + exit 1 + fi + HELM="helm_v2" + NAME_ARG="--name" + JQ_CMD='"\(.Releases[0].AppVersion),\(.Releases[0].Status)"' fi - HELM="helm_v2" - NAME_ARG="--name" - JQ_CMD='"\(.Releases[0].AppVersion),\(.Releases[0].Status)"' fi shopt -s nullglob diff --git a/package/Dockerfile b/package/Dockerfile index 5e6c942..9807f97 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -9,7 +9,6 @@ COPY entry /usr/bin/ FROM golang:1.20-alpine3.17 as plugins RUN apk add -U curl ca-certificates build-base binutils-gold -ARG ARCH COPY --from=extract /usr/bin/helm_v3 /usr/bin/helm RUN mkdir -p /go/src/github.com/k3s-io/helm-set-status && \ curl -sL https://github.com/k3s-io/helm-set-status/archive/refs/tags/v0.1.3.tar.gz | tar xvzf - --strip-components=1 -C /go/src/github.com/k3s-io/helm-set-status && \ diff --git a/scripts/package b/scripts/package index 26f5b54..2a3eb80 100755 --- a/scripts/package +++ b/scripts/package @@ -21,5 +21,9 @@ if [ -e ${DOCKERFILE}.${ARCH} ]; then DOCKERFILE=${DOCKERFILE}.${ARCH} fi -docker build --build-arg ARCH=${ARCH} --build-arg BUILDDATE=$(date +%Y%m%d) -f ${DOCKERFILE} -t ${IMAGE} . +if [ "$ARCH" = "riscv64" ]; then + export DOCKER_BUILDKIT=1 + DOCKER_ARGS="--platform=$ARCH" +fi +docker build ${DOCKER_ARGS} --build-arg ARCH=${ARCH} --build-arg BUILDDATE=$(date +%Y%m%d) -f ${DOCKERFILE} -t ${IMAGE} . echo Built ${IMAGE}