Skip to content

Commit

Permalink
chore(docker): properly handle arm(32) and arm64 (grafana#441)
Browse files Browse the repository at this point in the history
* chore(docker): install Helm from binary

Reverts the previous commits attempt to fix Helm on arm32 by using the
Alpine package, because as it turns out, there is no alpine package for
armhf.

Instead, we now use the offical Helm binaries, and `go env GOOS` and `go
env GOARCH` to pick the correct one.

This should work consistently across all platforms.

* fix(docker): use golang:alpine

Uses the alpine version of golang consistently across the whole
Dockerfile, so no longer need to pull both, the ubuntu and the alpine
variant: use golang:alpine

Uses the alpine version of golang consistently across the whole
Dockerfile, so no longer need to pull both, the ubuntu and the alpine variant

* chore(docker): kubectl on arm
  • Loading branch information
sh0rez authored Dec 11, 2020
1 parent ec5e283 commit 646b8df
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
# download kubectl
FROM alpine as kubectl
FROM golang:alpine as kubectl
RUN apk add --no-cache curl
RUN export VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) &&\
curl -o /usr/local/bin/kubectl -L https://storage.googleapis.com/kubernetes-release/release/${VERSION}/bin/linux/amd64/kubectl &&\
export OS=$(go env GOOS) && \
export ARCH=$(go env GOARCH) &&\
curl -o /usr/local/bin/kubectl -L https://storage.googleapis.com/kubernetes-release/release/${VERSION}/bin/${OS}/${ARCH}/kubectl &&\
chmod +x /usr/local/bin/kubectl

# build jsonnet-bundler
FROM golang as jb
FROM golang:alpine as jb
WORKDIR /tmp
RUN git clone https://github.com/jsonnet-bundler/jsonnet-bundler &&\
RUN apk add --no-cache git make bash &&\
git clone https://github.com/jsonnet-bundler/jsonnet-bundler &&\
cd jsonnet-bundler &&\
make static &&\
mv _output/jb /usr/local/bin/jb

FROM alpine as helm
RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing helm
FROM golang:alpine as helm
WORKDIR /tmp/helm
RUN apk add --no-cache jq curl
RUN export TAG=$(curl --silent "https://api.github.com/repos/helm/helm/releases/latest" | jq -r .tag_name) &&\
export OS=$(go env GOOS) &&\
export ARCH=$(go env GOARCH) &&\
curl -SL "https://get.helm.sh/helm-${TAG}-${OS}-${ARCH}.tar.gz" > helm.tgz && \
tar -xvf helm.tgz --strip-components=1

# assemble final container
FROM alpine
RUN apk add --no-cache coreutils diffutils less git openssh-client
COPY tk /usr/local/bin/tk
COPY --from=kubectl /usr/local/bin/kubectl /usr/local/bin/kubectl
COPY --from=jb /usr/local/bin/jb /usr/local/bin/jb
COPY --from=helm /usr/bin/helm /usr/local/bin/helm
COPY --from=helm /tmp/helm/helm /usr/local/bin/helm
WORKDIR /app
ENTRYPOINT ["/usr/local/bin/tk"]

0 comments on commit 646b8df

Please sign in to comment.