Skip to content
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

Include two stages docker #81

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
FROM scratch
FROM golang:1.15.2-alpine3.12 AS build

ENV GOBIN=$GOPATH/bin

ENV CGO_ENABLED="0" \
GOOS="linux"

ADD . /src/estafette-gke-preemptible-killer

WORKDIR /src/estafette-gke-preemptible-killer

RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
RUN update-ca-certificates

RUN go test ./... \
&& go build -a -installsuffix cgo -ldflags "-X main.version=${ESTAFETTE_BUILD_VERSION} -X main.revision=${ESTAFETTE_GIT_REVISION} -X main.branch=${ESTAFETTE_GIT_BRANCH} -X main.buildDate=${ESTAFETTE_BUILD_DATETIME}" .


FROM debian:buster-slim
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtime image should still be scratch in order to reduce attack surface and size.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not make it run with scratch. I figure out that for some reason does not like the

COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/


LABEL maintainer="estafette.io" \
description="The estafette-gke-preemptible-killer component is a Kubernetes controller that ensures preemptible nodes in a Container Engine cluster don't expire at the same time"

COPY ca-certificates.crt /etc/ssl/certs/
COPY estafette-gke-preemptible-killer /
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /src/estafette-gke-preemptible-killer/estafette-gke-preemptible-killer /estafette-gke-preemptible-killer

ENTRYPOINT ["/estafette-gke-preemptible-killer"]

CMD ["./estafette-gke-preemptible-killer"]