Skip to content

Commit

Permalink
Add minimal image
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
  • Loading branch information
ArangoGutierrez committed Aug 19, 2021
1 parent c0901cf commit 7be86c8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ COPY . .
RUN make build

# Create production image for running the operator
FROM ${BASE_IMAGE_FULL}
FROM ${BASE_IMAGE_FULL} as full
COPY --from=builder /workspace/node-feature-discovery-operator /

RUN mkdir -p /opt/nfd
COPY build/assets /opt/nfd
COPY --from=builder /workspace/build/assets /opt/nfd

RUN useradd nfd-operator
USER nfd-operator

ENTRYPOINT ["/node-feature-discovery-operator"]
LABEL io.k8s.display-name="node-feature-discovery-operator"

# Create a minimal image for running the operator
FROM ${BASE_IMAGE_MINIMAL} as minimal
COPY --from=builder /workspace/node-feature-discovery-operator /
COPY --from=builder /workspace/build/assets /opt/nfd

ENTRYPOINT ["/node-feature-discovery-operator"]
LABEL io.k8s.display-name="node-feature-discovery-operator"

21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ 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))
BASE_IMAGE_FULL ?= debian:buster-slim
BASE_IMAGE_MINIMAL ?= gcr.io/distroless/base

IMAGE_TAG_RBAC_PROXY ?= gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0

Expand Down Expand Up @@ -161,18 +162,32 @@ clean-labels:
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="utils/boilerplate.go.txt" paths="./..."

# Build the docker image
# Build the container image
image:
$(IMAGE_BUILD_CMD) -t $(IMAGE_TAG) \
--target full \
--build-arg BASE_IMAGE_FULL=$(BASE_IMAGE_FULL) \
--build-arg BASE_IMAGE_MINIMAL=$(BASE_IMAGE_MINIMAL) \
$(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)) \
$(IMAGE_BUILD_EXTRA_OPTS) ./

# Push the docker image
push:
image-minimal:
$(IMAGE_BUILD_CMD) -t $(IMAGE_TAG)-minimal \
--target minimal \
--build-arg BASE_IMAGE_FULL=$(BASE_IMAGE_FULL) \
--build-arg BASE_IMAGE_MINIMAL=$(BASE_IMAGE_MINIMAL) \
$(foreach tag,$(IMAGE_EXTRA_TAGS),-t $(tag)-minimal) \
$(IMAGE_BUILD_EXTRA_OPTS) ./

# Push the container image
push:
$(IMAGE_PUSH_CMD) $(IMAGE_TAG)
for tag in $(IMAGE_EXTRA_TAGS); do $(IMAGE_PUSH_CMD) $$tag; done

push-minimal:
$(IMAGE_PUSH_CMD) $(IMAGE_TAG)-minimal
for tag in $(IMAGE_EXTRA_TAGS); do $(IMAGE_PUSH_CMD) $$tag; done

site-build:
@mkdir -p docs/vendor/bundle
$(SITE_BUILD_CMD) sh -c '/usr/local/bin/bundle install && "$$BUNDLE_BIN/jekyll" build $(JEKYLL_OPTS)'
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-infra/build-image.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash -e

make image
make image image-minimal
4 changes: 2 additions & 2 deletions scripts/test-infra/push-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# container image tag
VERSION_OVERRIDE=${_GIT_TAG+VERSION=${_GIT_TAG:10}}

make image $VERSION_OVERRIDE
make push $VERSION_OVERRIDE
make image image-minimal $VERSION_OVERRIDE
make push push-minimal $VERSION_OVERRIDE

0 comments on commit 7be86c8

Please sign in to comment.