Skip to content

Commit 7a69aca

Browse files
committed
Install packages without docs to reduce image size
The UBI base images do not set tsflags in /etc/dnf/dnf.conf, so every dnf install and dnf update we run installs documentation and man pages into the layers we ship. They grow the image for no runtime benefit and get picked up by CI scanners; #772 hit this when the perl docs pulled in by git were flagged for containing sample secrets. Set tsflags=nodocs once per RHEL image, before the first dnf transaction, so every later call inherits it. That covers the installs in install.sh and the CVE_UPDATES blocks, and also the ones nvidia-driver and ocp_dtk_entrypoint run when the container starts, which passing --nodocs per command would have missed. The bases differ in what they provide, so the value is written through dnf's own config writer rather than by editing the file directly: rockylinux 9.8-ubi and 10.2-ubi already ship tsflags=nodocs, so nothing is done; ubi8, ubi9, ubi10 and the CUDA UBI bases have config-manager preinstalled; rockylinux 8.10-ubi has neither and installs it first. Installing config-manager costs about 4 MiB and only happens on rockylinux 8, which is close to end of life. Everywhere else it is free. Signed-off-by: Abrar Shivani <ashivani@nvidia.com>
1 parent 344c1e3 commit 7a69aca

5 files changed

Lines changed: 30 additions & 0 deletions

File tree

rhel10/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ENV TARGETARCH=$TARGETARCH
3535

3636
SHELL ["/bin/bash", "-c"]
3737

38+
RUN if ! grep -qE '^tsflags=.*nodocs' /etc/dnf/dnf.conf; then \
39+
dnf config-manager --help >/dev/null 2>&1 || \
40+
dnf install -y --nodocs 'dnf-command(config-manager)'; \
41+
dnf config-manager --save --setopt=tsflags=nodocs; \
42+
fi
43+
3844
RUN dnf update -y && dnf clean all
3945

4046
#ARG BASE_URL=http://us.download.nvidia.com/XFree86/Linux-x86_64

rhel8/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ ENV TARGETARCH=$TARGETARCH
3434

3535
SHELL ["/bin/bash", "-c"]
3636

37+
RUN if ! grep -qE '^tsflags=.*nodocs' /etc/dnf/dnf.conf; then \
38+
dnf config-manager --help >/dev/null 2>&1 || \
39+
dnf install -y --nodocs 'dnf-command(config-manager)'; \
40+
dnf config-manager --save --setopt=tsflags=nodocs; \
41+
fi
42+
3743
RUN dnf update -y && dnf clean all
3844

3945
#ARG BASE_URL=http://us.download.nvidia.com/XFree86/Linux-x86_64

rhel9/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ ENV TARGETARCH=$TARGETARCH
3434

3535
SHELL ["/bin/bash", "-c"]
3636

37+
RUN if ! grep -qE '^tsflags=.*nodocs' /etc/dnf/dnf.conf; then \
38+
dnf config-manager --help >/dev/null 2>&1 || \
39+
dnf install -y --nodocs 'dnf-command(config-manager)'; \
40+
dnf config-manager --save --setopt=tsflags=nodocs; \
41+
fi
42+
3743
RUN dnf update -y && dnf clean all
3844

3945
#ARG BASE_URL=http://us.download.nvidia.com/XFree86/Linux-x86_64

vgpu-manager/rhel8/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ RUN chmod +x NVIDIA-Linux-${DRIVER_ARCH}-${DRIVER_VERSION}-vgpu-kvm.run
2323
COPY nvidia-driver /usr/local/bin
2424
COPY ocp_dtk_entrypoint /usr/local/bin
2525

26+
RUN if ! grep -qE '^tsflags=.*nodocs' /etc/dnf/dnf.conf; then \
27+
dnf config-manager --help >/dev/null 2>&1 || \
28+
dnf install -y --nodocs 'dnf-command(config-manager)'; \
29+
dnf config-manager --save --setopt=tsflags=nodocs; \
30+
fi
31+
2632
RUN dnf install -y pciutils && \
2733
dnf clean all && \
2834
rm -rf /var/cache/dnf/*

vgpu-manager/rhel9/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ RUN chmod +x NVIDIA-Linux-${DRIVER_ARCH}-${DRIVER_VERSION}-vgpu-kvm.run
3636
COPY nvidia-driver /usr/local/bin
3737
COPY ocp_dtk_entrypoint /usr/local/bin
3838

39+
RUN if ! grep -qE '^tsflags=.*nodocs' /etc/dnf/dnf.conf; then \
40+
dnf config-manager --help >/dev/null 2>&1 || \
41+
dnf install -y --nodocs 'dnf-command(config-manager)'; \
42+
dnf config-manager --save --setopt=tsflags=nodocs; \
43+
fi
44+
3945
RUN dnf install -y pciutils && \
4046
dnf clean all && \
4147
rm -rf /var/cache/dnf/*

0 commit comments

Comments
 (0)