diff --git a/deployments/container/Dockerfile.ubi8 b/deployments/container/Dockerfile.ubi8 new file mode 100644 index 00000000..01950042 --- /dev/null +++ b/deployments/container/Dockerfile.ubi8 @@ -0,0 +1,32 @@ +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# We use the ubi8-minimal image as a reference image in removing unneeded dependencies. +FROM redhat/ubi8-minimal:latest AS minimal + +RUN rpm -qa --queryformat='^%{NAME}-\[0-9\].*\.%{ARCH}$\n' | sort -u > /tmp/minimal-list.txt +RUN rpm -qa | sort -u > /tmp/minimal-list.versions + +# We define the following image as a base image and remove unneeded packages. +FROM nvcr.io/nvidia/cuda:12.5.0-base-ubi8 AS base + +WORKDIR /cleanup + +COPY --from=minimal /tmp/minimal-list.txt minimal-list.txt +COPY --from=minimal /tmp/minimal-list.versions minimal-list.versions +COPY deployments/container/cleanup/* . + +RUN ./cleanup.sh + +WORKDIR / diff --git a/deployments/container/cleanup/cleanup.sh b/deployments/container/cleanup/cleanup.sh new file mode 100755 index 00000000..fd921369 --- /dev/null +++ b/deployments/container/cleanup/cleanup.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied. +# See the License for the specific language governing permissions and +# limitations under the License. + +echo "install_weak_deps=False" >> /etc/dnf/dnf.conf +rm -f /etc/dnf/protected.d/*.conf + +rm -f /etc/yum.repos.d/cuda.repo +rm -f /etc/ld.so.conf.d/nvidia.conf + +dnf remove -y \ + cuda* \ + systemd + +dnf clean all +rm -rf /var/cache/dnf + +dnf install -y microdnf + +microdnf remove $(rpm -q --whatrequires dnf) +rpm -e dnf + +microdnf remove \ + $(rpm -q --whatrequires /usr/libexec/platform-python) \ + $(rpm -q --whatrequires 'python(abi)') \ + python* \ + dnf* + +microdnf remove \ + $(rpm -qa | sort | grep -v -f minimal-list.txt -e gpg-pubkey) + +microdnf update + +rpm -qa | sort -u > package-list.versions + +microdnf clean all +rm -rf /var/cache/dnf