-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker+CI: More efficient build #939
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
# download kubectl | ||
FROM golang:1.21.3-alpine as kubectl | ||
RUN apk add --no-cache curl | ||
FROM golang:1.21.3 as kubectl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since none of these stages are building code any more, you could drop the |
||
RUN export VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) &&\ | ||
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:1.21.3-alpine as jb | ||
WORKDIR /tmp | ||
RUN apk add --no-cache git make bash &&\ | ||
git clone https://github.com/jsonnet-bundler/jsonnet-bundler &&\ | ||
ls /bin &&\ | ||
cd jsonnet-bundler &&\ | ||
make static &&\ | ||
mv _output/jb /usr/local/bin/jb | ||
FROM golang:1.21.3 as jb | ||
RUN export OS=$(go env GOOS) &&\ | ||
export ARCH=$(go env GOARCH) &&\ | ||
curl -o /usr/local/bin/jb -L "https://github.com/jsonnet-bundler/jsonnet-bundler/releases/download/v0.5.1/jb-${OS}-${ARCH}" &&\ | ||
chmod +x /usr/local/bin/jb | ||
|
||
FROM golang:1.21.3-alpine as helm | ||
WORKDIR /tmp/helm | ||
|
@@ -39,15 +35,11 @@ RUN export TAG=$(curl --silent "https://api.github.com/repos/kubernetes-sigs/kus | |
curl -SL "https://github.com/kubernetes-sigs/kustomize/releases/download/${TAG}/kustomize_${VERSION_TAG}_${OS}_${ARCH}.tar.gz" > kustomize.tgz && \ | ||
tar -xvf kustomize.tgz | ||
|
||
FROM golang:1.21.3 as build | ||
WORKDIR /app | ||
COPY . . | ||
RUN make static | ||
Comment on lines
-42
to
-45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Be nicer if this could be kept, so a It should be possible to do this with |
||
|
||
# assemble final container | ||
FROM alpine:3.18 | ||
RUN apk add --no-cache coreutils diffutils less git openssh-client | ||
COPY --from=build /app/tk /usr/local/bin/tk | ||
# Need to `make static` before building the container | ||
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 /tmp/helm/helm /usr/local/bin/helm | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The downside of this approach is that there is now a place for specifying the Go version that is not updated by dependabot. Should we perhaps update the Makefile to read the Go version from the Dockerfile or something like that?