1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

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.
This commit is contained in:
rmr-silicom 2021-04-20 09:42:33 +02:00 committed by GitHub
parent 348d319816
commit a896ff3011
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -1,3 +1,6 @@
ARG BASE_IMAGE_FULL
ARG BASE_IMAGE_MINIMAL
# Build node feature discovery # Build node feature discovery
FROM golang:1.16.2-buster as builder FROM golang:1.16.2-buster as builder
@ -20,7 +23,7 @@ RUN make test
# Create full variant of the production image # Create full variant of the production image
FROM debian:buster-slim as full FROM ${BASE_IMAGE_FULL} as full
# Run as unprivileged user # Run as unprivileged user
USER 65534:65534 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/ COPY --from=builder /go/bin/* /usr/bin/
# Create minimal variant of the production image # Create minimal variant of the production image
FROM gcr.io/distroless/base as minimal FROM ${BASE_IMAGE_MINIMAL} as minimal
# Run as unprivileged user # Run as unprivileged user
USER 65534:65534 USER 65534:65534

View file

@ -8,6 +8,8 @@ IMAGE_BUILD_CMD ?= docker build
IMAGE_BUILD_EXTRA_OPTS ?= IMAGE_BUILD_EXTRA_OPTS ?=
IMAGE_PUSH_CMD ?= docker push IMAGE_PUSH_CMD ?= docker push
CONTAINER_RUN_CMD ?= docker run CONTAINER_RUN_CMD ?= docker run
BASE_IMAGE_FULL ?= debian:buster-slim
BASE_IMAGE_MINIMAL ?= gcr.io/distroless/base
MDL ?= mdl MDL ?= mdl
@ -74,12 +76,16 @@ image: yamls
$(IMAGE_BUILD_CMD) --build-arg VERSION=$(VERSION) \ $(IMAGE_BUILD_CMD) --build-arg VERSION=$(VERSION) \
--target full \ --target full \
--build-arg HOSTMOUNT_PREFIX=$(CONTAINER_HOSTMOUNT_PREFIX) \ --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) \ -t $(IMAGE_TAG) \
$(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)) \ $(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)) \
$(IMAGE_BUILD_EXTRA_OPTS) ./ $(IMAGE_BUILD_EXTRA_OPTS) ./
$(IMAGE_BUILD_CMD) --build-arg VERSION=$(VERSION) \ $(IMAGE_BUILD_CMD) --build-arg VERSION=$(VERSION) \
--target minimal \ --target minimal \
--build-arg HOSTMOUNT_PREFIX=$(CONTAINER_HOSTMOUNT_PREFIX) \ --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 \ -t $(IMAGE_TAG)-minimal \
$(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)-minimal) \ $(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)-minimal) \
$(IMAGE_BUILD_EXTRA_OPTS) ./ $(IMAGE_BUILD_EXTRA_OPTS) ./

View file

@ -111,6 +111,8 @@ makefile overrides.
| KUBECONFIG | Kubeconfig for running e2e-tests | *empty* | KUBECONFIG | Kubeconfig for running e2e-tests | *empty*
| E2E_TEST_CONFIG | Parameterization file of e2e-tests (see [example][e2e-config-sample]) | *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* | 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: For example, to use a custom registry: