diff --git a/Dockerfile b/Dockerfile index e8ac62c1e..a019a9f69 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,10 @@ +# Dockerfile has specific requirement to put this ARG at the beginning: +# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact +ARG BUILDER_IMAGE +ARG BASE_IMAGE + ## Multistage build -FROM golang:1.23-alpine AS build +FROM ${BUILDER_IMAGE} as builder ENV CGO_ENABLED=0 ENV GOOS=linux ENV GOARCH=amd64 @@ -9,12 +14,11 @@ COPY . . WORKDIR /src/pkg/ext-proc RUN go mod download RUN go build -o /ext-proc -FROM alpine:latest + ## Multistage deploy -FROM gcr.io/distroless/base-debian10 -# Install bash +FROM ${BASE_IMAGE} WORKDIR / -COPY --from=build /ext-proc /ext-proc +COPY --from=builder /ext-proc /ext-proc ENTRYPOINT ["/ext-proc"] \ No newline at end of file diff --git a/Makefile b/Makefile index 0dd478d6f..44759e457 100644 --- a/Makefile +++ b/Makefile @@ -31,10 +31,11 @@ IMAGE_NAME := epp IMAGE_REPO ?= $(IMAGE_REGISTRY)/$(IMAGE_NAME) IMAGE_TAG ?= $(IMAGE_REPO):$(GIT_TAG) -# Use distroless as minimal base image to package the manager binary -# Refer to https://github.com/GoogleContainerTools/distroless for more details -BASE_IMAGE ?= gcr.io/distroless/static:nonroot -BUILDER_IMAGE ?= golang:$(GO_VERSION) +BASE_IMAGE ?= gcr.io/distroless/base-debian10 +BUILDER_IMAGE ?= golang:1.23-alpine +ifdef GO_VERSION +BUILDER_IMAGE = golang:$(GO_VERSION) +endif ifdef EXTRA_TAG IMAGE_EXTRA_TAG ?= $(IMAGE_REPO):$(EXTRA_TAG)