Skip to content

Commit

Permalink
Add support for RISC-V
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
chazapis committed Jul 17, 2023
1 parent 645bb1e commit 3bdd7ec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 13 additions & 8 deletions entry
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
6 changes: 5 additions & 1 deletion scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 3bdd7ec

Please sign in to comment.