Skip to content

Commit

Permalink
Properly install grep and kubectl into the SUC image (#196)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Kim <oats87g@gmail.com>
  • Loading branch information
Oats87 authored Sep 4, 2024
1 parent 7c3ac14 commit 0d64f6e
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions package/Dockerfile.suc
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
ARG IMG_VERSION=15.6
FROM registry.suse.com/bci/bci-base:${IMG_VERSION} as kubectl

FROM registry.suse.com/bci/bci-micro:${IMG_VERSION} AS final

# Temporary build stage image
FROM registry.suse.com/bci/bci-base:${IMG_VERSION} AS builder

# Install system packages using builder image that has zypper
COPY --from=final / /chroot/

RUN zypper refresh && \
zypper --installroot /chroot -n in --no-recommends \
openssl patterns-base-fips grep && \
zypper --installroot /chroot clean -a && \
rm -rf /chroot/var/cache/zypp/* /chroot/var/log/zypp/* /chroot/tmp/* /chroot/var/tmp/* /chroot/usr/share/doc/packages/*

ARG KUBECTL_VERSION=v1.29.7

Expand All @@ -14,11 +27,15 @@ RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then ARCH=amd64; fi && \
if [ "$ARCH" = "aarch64" ]; then ARCH=arm64; fi && \
curl -L -f -o kubectl "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl" && \
install -o root -g root -m 0755 kubectl /usr/bin/kubectl && \
KUBECTL_SUM="KUBECTL_SUM_${ARCH}" && echo "${!KUBECTL_SUM} /usr/bin/kubectl" | sha256sum -c -
RUN /usr/bin/kubectl version --client
install -o root -g root -m 0755 kubectl /chroot/usr/bin/kubectl && \
KUBECTL_SUM="KUBECTL_SUM_${ARCH}" && echo "${!KUBECTL_SUM} /chroot/usr/bin/kubectl" | sha256sum -c -
RUN /chroot/usr/bin/kubectl version --client

# Main stage using bci-micro as the base image
FROM final

FROM registry.suse.com/bci/bci-micro:${IMG_VERSION}
# Copy binaries and configuration files from builder to micro
COPY --from=builder /chroot/ /

ENV CATTLE_AGENT_VAR_DIR="/var/lib/rancher/agent"

Expand All @@ -28,7 +45,6 @@ COPY install.sh /opt/rancher-system-agent-suc/install.sh
COPY system-agent-uninstall.sh /opt/rancher-system-agent-suc/system-agent-uninstall.sh
COPY bin/rancher-system-agent /opt/rancher-system-agent-suc
COPY package/suc/run.sh /opt/rancher-system-agent-suc/run.sh
COPY --from=kubectl /usr/bin/kubectl /usr/bin/
RUN chmod +x /opt/rancher-system-agent-suc/rancher-system-agent

ENTRYPOINT ["/opt/rancher-system-agent-suc/run.sh"]

0 comments on commit 0d64f6e

Please sign in to comment.