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

dockerfile: builder image configurable through a Makefile variable. #173

Merged
merged 2 commits into from
Jan 19, 2023
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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ARG BUILDER_IMAGE
ARG BASE_IMAGE_FULL
ARG BASE_IMAGE_MINIMAL
# Build the manager biinary
FROM golang:1.19.5-buster as builder
FROM ${BUILDER_IMAGE} as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

GO_CMD ?= go
GO_FMT ?= gofmt
GO_VERSION := $(shell awk '/^go /{print $$2}' go.mod|head -n1)
CONTAINER_RUN_CMD ?= docker run -u "`id -u`:`id -g`"

# Docker base command for working with html documentation.
Expand Down Expand Up @@ -62,6 +63,7 @@ IMAGE_EXTRA_TAG_NAMES ?=
IMAGE_REPO ?= $(IMAGE_REGISTRY)/$(IMAGE_NAME)
IMAGE_TAG ?= $(IMAGE_REPO):$(IMAGE_TAG_NAME)
IMAGE_EXTRA_TAGS := $(foreach tag,$(IMAGE_EXTRA_TAG_NAMES),$(IMAGE_REPO):$(tag))
BUILDER_IMAGE ?= golang:$(GO_VERSION)-buster
BASE_IMAGE_FULL ?= debian:buster-slim
BASE_IMAGE_MINIMAL ?= gcr.io/distroless/base

Expand Down Expand Up @@ -173,6 +175,7 @@ generate: controller-gen
image:
$(IMAGE_BUILD_CMD) -t $(IMAGE_TAG) \
--target full \
--build-arg BUILDER_IMAGE=$(BUILDER_IMAGE) \
--build-arg BASE_IMAGE_FULL=$(BASE_IMAGE_FULL) \
--build-arg BASE_IMAGE_MINIMAL=$(BASE_IMAGE_MINIMAL) \
$(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)) \
Expand All @@ -181,6 +184,7 @@ image:
image-minimal:
$(IMAGE_BUILD_CMD) -t $(IMAGE_TAG)-minimal \
--target minimal \
--build-arg BUILDER_IMAGE=$(BUILDER_IMAGE) \
--build-arg BASE_IMAGE_FULL=$(BASE_IMAGE_FULL) \
--build-arg BASE_IMAGE_MINIMAL=$(BASE_IMAGE_MINIMAL) \
$(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)-minimal) \
Expand Down