Skip to content

Commit

Permalink
feat: add slim image
Browse files Browse the repository at this point in the history
Build two images full size and slim.

Signed-off-by: Serge Logvinov <[email protected]>
  • Loading branch information
sergelogvinov committed Aug 8, 2024
1 parent 821dc3e commit 37b10e9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
32 changes: 27 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Using the builder this way keeps us from having to install wget and adding an extra
## fat step that just does a chmod on the kubelet binary

FROM alpine:latest as builder-amd64
FROM alpine:latest AS builder-amd64

ARG TARGETARCH
ARG KUBELET_VER
Expand All @@ -13,7 +13,7 @@ RUN wget -q -O /kubelet ${KUBELET_URL} \
&& echo "${KUBELET_SHA512_AMD64} /kubelet" | sha512sum -cw \
&& chmod +x /kubelet

FROM alpine:latest as builder-arm64
FROM alpine:latest AS builder-arm64

ARG TARGETARCH
ARG KUBELET_VER
Expand All @@ -26,9 +26,11 @@ RUN wget -q -O /kubelet ${KUBELET_URL} \
&& chmod +x /kubelet

ARG TARGETARCH
FROM builder-${TARGETARCH} as builder
FROM builder-${TARGETARCH} AS builder

FROM registry.k8s.io/build-image/debian-iptables:bookworm-v1.0.0 as container
########################

FROM registry.k8s.io/build-image/debian-iptables:bookworm-v1.0.0 AS container

RUN clean-install \
--allow-change-held-packages \
Expand All @@ -55,6 +57,26 @@ COPY --from=builder /kubelet /usr/local/bin/kubelet
# Add wrapper for iscsiadm
COPY files/iscsiadm /usr/local/sbin/iscsiadm

LABEL org.opencontainers.image.source https://github.com/siderolabs/kubelet
LABEL org.opencontainers.image.source="https://github.com/siderolabs/kubelet"

ENTRYPOINT ["/usr/local/bin/kubelet"]

########################

FROM registry.k8s.io/build-image/debian-iptables:bookworm-v1.0.0 AS container-slim

RUN clean-install \
--allow-change-held-packages \
ca-certificates \
libcap2 \
ethtool \
iproute2 \
nfs-common \
socat \
util-linux

COPY --from=builder /kubelet /usr/local/bin/kubelet

LABEL org.opencontainers.image.source="https://github.com/siderolabs/kubelet"

ENTRYPOINT ["/usr/local/bin/kubelet"]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ local-%: ## Builds the specified target defined in the Dockerfile using the loca

docker-%: ## Builds the specified target defined in the Dockerfile using the default output type.
@$(MAKE) target-$* TARGET_ARGS="--tag $(REGISTRY_AND_USERNAME)/$(NAME):$(TAG) $(TARGET_ARGS)"
@$(MAKE) target-$*-slim TARGET_ARGS="--tag $(REGISTRY_AND_USERNAME)/$(NAME):$(TAG)-slim $(TARGET_ARGS)"

.PHONY: container
container:
Expand Down

0 comments on commit 37b10e9

Please sign in to comment.