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 19, 2023
1 parent 645bb1e commit 647a2aa
Show file tree
Hide file tree
Showing 5 changed files with 60 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
40 changes: 40 additions & 0 deletions package/Dockerfile.riscv64
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM riscv64/alpine:edge as extract
RUN apk add -U curl ca-certificates
# ARG ARCH
# RUN curl https://get.helm.sh/helm-v3.11.3-linux-${ARCH}.tar.gz | tar xvzf - --strip-components=1 -C /usr/bin
# RUN mv /usr/bin/helm /usr/bin/helm_v3
RUN apk add -U bash build-base go
RUN mkdir -p /go/src/github.com/helm/helm && \
curl -sL https://github.com/helm/helm/archive/refs/tags/v3.12.2.tar.gz | tar xvzf - --strip-components=1 -C /go/src/github.com/helm/helm && \
make -C /go/src/github.com/helm/helm && \
cp -v /go/src/github.com/helm/helm/bin/helm /usr/bin/helm_v3
COPY entry /usr/bin/

FROM riscv64/alpine:edge as plugins
RUN apk add -U curl ca-certificates build-base go
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 && \
make -C /go/src/github.com/k3s-io/helm-set-status install
RUN mkdir -p /go/src/github.com/helm/helm-mapkubeapis && \
curl -sL https://github.com/helm/helm-mapkubeapis/archive/refs/tags/v0.4.1.tar.gz | tar xvzf - --strip-components=1 -C /go/src/github.com/helm/helm-mapkubeapis && \
make -C /go/src/github.com/helm/helm-mapkubeapis && \
mkdir -p /root/.local/share/helm/plugins/helm-mapkubeapis && \
cp -vr /go/src/github.com/helm/helm-mapkubeapis/plugin.yaml \
/go/src/github.com/helm/helm-mapkubeapis/bin \
/go/src/github.com/helm/helm-mapkubeapis/config \
/root/.local/share/helm/plugins/helm-mapkubeapis/

FROM riscv64/alpine:edge
ARG BUILDDATE
LABEL buildDate=$BUILDDATE
RUN apk --no-cache upgrade && \
apk add -U --no-cache ca-certificates jq bash git && \
adduser -D -u 1000 -s /bin/bash klipper-helm
WORKDIR /home/klipper-helm
COPY --chown=1000:1000 --from=plugins /root/.local/share/helm/plugins/ /home/klipper-helm/.local/share/helm/plugins/
COPY --from=extract /usr/bin/helm_v3 /usr/bin/entry /usr/bin/
ENTRYPOINT ["entry"]
ENV STABLE_REPO_URL=https://charts.helm.sh/stable/
ENV TIMEOUT=
USER 1000
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 647a2aa

Please sign in to comment.