From bcb3fde05217f0f4cd283d88232e1effde09fd61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20N=C3=BA=C3=B1ez-Cacho=20Solans?= Date: Sat, 17 Oct 2020 19:49:13 +0200 Subject: [PATCH 1/3] Include ca certificates generation in the docker build as stages --- Dockerfile | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 147720c..165adfd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,26 @@ +FROM golang:1.14-buster AS build + +ENV GOBIN=$GOPATH/bin + +ADD . /src/estafette-gke-preemptible-killer + +WORKDIR /src/estafette-gke-preemptible-killer + +RUN apt-get -qqq update \ + && apt-get -qqq -y install ca-certificates\ + && update-ca-certificates + +RUN go mod download \ + && go build ./... + FROM scratch 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"] From bc2ae4816cbb63676a79a293a25a4908303fdc30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20N=C3=BA=C3=B1ez-Cacho=20Solans?= Date: Sat, 17 Oct 2020 20:16:11 +0200 Subject: [PATCH 2/3] use debian slim --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 165adfd..9b14348 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ RUN apt-get -qqq update \ RUN go mod download \ && go build ./... -FROM scratch +FROM debian:buster-slim 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" @@ -23,4 +23,3 @@ COPY --from=build /src/estafette-gke-preemptible-killer/estafette-gke-preemptibl ENTRYPOINT ["/estafette-gke-preemptible-killer"] -CMD ["./estafette-gke-preemptible-killer"] From 3cd846644944d52347a98822d53c45356f211e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20N=C3=BA=C3=B1ez-Cacho=20Solans?= Date: Mon, 19 Oct 2020 11:07:14 +0200 Subject: [PATCH 3/3] modify build and multistage builder image version --- Dockerfile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9b14348..f70f839 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,20 @@ -FROM golang:1.14-buster AS build +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 apt-get -qqq update \ - && apt-get -qqq -y install ca-certificates\ - && update-ca-certificates +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}" . -RUN go mod download \ - && go build ./... FROM debian:buster-slim