Skip to content

dev: respect the IMAGE args in Makefile #205

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

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
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
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down