From a896ff30111e20569339c7801b030dc7dd088083 Mon Sep 17 00:00:00 2001 From: rmr-silicom <77667725+rmr-silicom@users.noreply.github.com> Date: Tue, 20 Apr 2021 09:42:33 +0200 Subject: [PATCH] Add support for configurable runtime full and minimal images. (#513) * Add support for configurable runtime full and minimal images. * Fixups and renamings. * Change variables *_IMG_* to *_IMAGE_* * Fix args in Dockerfile also. --- Dockerfile | 7 +++++-- Makefile | 6 ++++++ docs/advanced/developer-guide.md | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b68659ff..8bc909354 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,6 @@ +ARG BASE_IMAGE_FULL +ARG BASE_IMAGE_MINIMAL + # Build node feature discovery FROM golang:1.16.2-buster as builder @@ -20,7 +23,7 @@ RUN make test # Create full variant of the production image -FROM debian:buster-slim as full +FROM ${BASE_IMAGE_FULL} as full # Run as unprivileged user USER 65534:65534 @@ -32,7 +35,7 @@ COPY --from=builder /go/node-feature-discovery/nfd-worker.conf.example /etc/kube COPY --from=builder /go/bin/* /usr/bin/ # Create minimal variant of the production image -FROM gcr.io/distroless/base as minimal +FROM ${BASE_IMAGE_MINIMAL} as minimal # Run as unprivileged user USER 65534:65534 diff --git a/Makefile b/Makefile index 9ce76b663..eb27cfe32 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ IMAGE_BUILD_CMD ?= docker build IMAGE_BUILD_EXTRA_OPTS ?= IMAGE_PUSH_CMD ?= docker push CONTAINER_RUN_CMD ?= docker run +BASE_IMAGE_FULL ?= debian:buster-slim +BASE_IMAGE_MINIMAL ?= gcr.io/distroless/base MDL ?= mdl @@ -74,12 +76,16 @@ image: yamls $(IMAGE_BUILD_CMD) --build-arg VERSION=$(VERSION) \ --target full \ --build-arg HOSTMOUNT_PREFIX=$(CONTAINER_HOSTMOUNT_PREFIX) \ + --build-arg BASE_IMAGE_FULL=$(BASE_IMAGE_FULL) \ + --build-arg BASE_IMAGE_MINIMAL=$(BASE_IMAGE_MINIMAL) \ -t $(IMAGE_TAG) \ $(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)) \ $(IMAGE_BUILD_EXTRA_OPTS) ./ $(IMAGE_BUILD_CMD) --build-arg VERSION=$(VERSION) \ --target minimal \ --build-arg HOSTMOUNT_PREFIX=$(CONTAINER_HOSTMOUNT_PREFIX) \ + --build-arg BASE_IMAGE_FULL=$(BASE_IMAGE_FULL) \ + --build-arg BASE_IMAGE_MINIMAL=$(BASE_IMAGE_MINIMAL) \ -t $(IMAGE_TAG)-minimal \ $(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)-minimal) \ $(IMAGE_BUILD_EXTRA_OPTS) ./ diff --git a/docs/advanced/developer-guide.md b/docs/advanced/developer-guide.md index 5912f5a5b..d6f222232 100644 --- a/docs/advanced/developer-guide.md +++ b/docs/advanced/developer-guide.md @@ -111,6 +111,8 @@ makefile overrides. | KUBECONFIG | Kubeconfig for running e2e-tests | *empty* | E2E_TEST_CONFIG | Parameterization file of e2e-tests (see [example][e2e-config-sample]) | *empty* | OPENSHIFT | Non-empty value enables OpenShift specific support (currently only effective in e2e tests) | *empty* +| BASE_IMAGE_FULL | Container base image for target image full (--target full) | debian:buster-slim +| BASE_IMAGE_MINIMAL | Container base image for target image minimal (--target minimal) | gcr.io/distroless/base For example, to use a custom registry: