From a25aef4b7ad11f30a2100098f0aba35bbd39f819 Mon Sep 17 00:00:00 2001 From: Ann Taraday Date: Fri, 24 Feb 2023 13:22:30 +0100 Subject: [PATCH] Use distroless image for operator image To avoid security issues switch to usage of distroless image. Also bumped go version to 1.19 Fixes: #508 Signed-off-by: Ann Taraday --- Dockerfile | 8 ++------ go.mod | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index a30e213c..eaa5eaea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG DOCKER_REGISTRY ARG ALPINE_VERSION=3.15 -FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}golang:1.18-alpine${ALPINE_VERSION} as go-builder +FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}golang:1.19-alpine${ALPINE_VERSION} as go-builder ARG PROJECT_NAME=zookeeper-operator ARG REPO_PATH=github.com/pravega/$PROJECT_NAME @@ -28,14 +28,10 @@ COPY controllers/ controllers/ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /src/${PROJECT_NAME} \ -ldflags "-X ${REPO_PATH}/pkg/version.Version=${VERSION} -X ${REPO_PATH}/pkg/version.GitSHA=${GIT_SHA}" main.go -FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}alpine:${ALPINE_VERSION} AS final - +FROM gcr.io/distroless/static:nonroot AS final ARG PROJECT_NAME=zookeeper-operator COPY --from=go-builder /src/${PROJECT_NAME} /usr/local/bin/${PROJECT_NAME} -RUN adduser -D ${PROJECT_NAME} -USER ${PROJECT_NAME} - ENTRYPOINT ["/usr/local/bin/zookeeper-operator"] diff --git a/go.mod b/go.mod index 1f60fd17..41059a9d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pravega/zookeeper-operator -go 1.18 +go 1.19 require ( github.com/ghodss/yaml v1.0.0