Skip to content

Commit 2f1fb9b

Browse files
committed
TOFIX: packages in image
Signed-off-by: Evan Lezar <[email protected]>
1 parent f959c0d commit 2f1fb9b

File tree

2 files changed

+76
-18
lines changed

2 files changed

+76
-18
lines changed

deployments/container/Dockerfile.ubi8

Lines changed: 67 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,83 @@ COPY . .
4747
# and not `cmd`.
4848
RUN GOPATH=/artifacts go install -ldflags="-s -w -X 'main.Version=${VERSION}'" ./tools/...
4949

50-
51-
FROM nvidia/cuda:12.6.0-base-ubi8
52-
53-
ENV NVIDIA_DISABLE_REQUIRE="true"
54-
ENV NVIDIA_VISIBLE_DEVICES=void
55-
ENV NVIDIA_DRIVER_CAPABILITIES=utility
50+
FROM nvidia/cuda:12.5.0-base-ubi8 AS packaging
5651

5752
ARG ARTIFACTS_ROOT
58-
ARG PACKAGE_DIST
59-
COPY ${ARTIFACTS_ROOT}/${PACKAGE_DIST} /artifacts/packages/${PACKAGE_DIST}
53+
COPY ${ARTIFACTS_ROOT} /artifacts/packages/
6054

6155
WORKDIR /artifacts/packages
6256

57+
# build-args are added to the manifest.txt file below.
58+
ARG PACKAGE_DIST
6359
ARG PACKAGE_VERSION
60+
ARG GIT_BRANCH
61+
ARG GIT_COMMIT
62+
ARG GIT_COMMIT_SHORT
63+
ARG SOURCE_DATE_EPOCH
64+
ARG VERSION
65+
66+
# Create a manifest.txt file with the absolute paths of all deb and rpm packages in the container
67+
RUN echo "#IMAGE_EPOCH=$(date '+%s')" > /artifacts/manifest.txt && \
68+
env | sed 's/^/#/g' >> /artifacts/manifest.txt && \
69+
find /artifacts/packages -iname '*.deb' -o -iname '*.rpm' >> /artifacts/manifest.txt
70+
71+
RUN mkdir /licenses && mv /NGC-DL-CONTAINER-LICENSE /licenses/NGC-DL-CONTAINER-LICENSE
72+
73+
FROM nvidia/cuda:12.5.0-base-ubi8 AS rpmpackages
74+
RUN dnf install -y cpio
75+
6476
ARG TARGETARCH
65-
ENV PACKAGE_ARCH ${TARGETARCH}
66-
RUN PACKAGE_ARCH=${PACKAGE_ARCH/amd64/x86_64} && PACKAGE_ARCH=${PACKAGE_ARCH/arm64/aarch64} && \
67-
yum localinstall -y \
68-
${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container1-1.*.rpm \
69-
${PACKAGE_DIST}/${PACKAGE_ARCH}/libnvidia-container-tools-1.*.rpm \
70-
${PACKAGE_DIST}/${PACKAGE_ARCH}/nvidia-container-toolkit*-${PACKAGE_VERSION}*.rpm
77+
ARG PACKAGE_DIST_RPM=centos7
7178

72-
WORKDIR /work
79+
COPY --from=packaging /artifacts/packages/${PACKAGE_DIST_RPM} /rpm-packages
80+
81+
RUN mkdir -p /artifacts/rpm
82+
RUN set -eux; \
83+
\
84+
case "${TARGETARCH}" in \
85+
x86_64 | amd64) ARCH='x86_64' ;; \
86+
ppc64el | ppc64le) ARCH='ppc64le' ;; \
87+
aarch64 | arm64) ARCH='aarch64' ;; \
88+
*) echo "unsupported architecture" ; exit 1 ;; \
89+
esac; \
90+
for p in $(ls /rpm-packages/${ARCH}/*.rpm); do rpm2cpio $p | cpio -idmv -D /artifacts/rpm; done
7391

74-
COPY --from=build /artifacts/bin /work
92+
FROM nvidia/cuda:12.5.0-base-ubuntu20.04 AS debpackages
7593

94+
ARG TARGETARCH
95+
ARG PACKAGE_DIST_DEB=ubuntu18.04
96+
97+
COPY --from=packaging /artifacts/packages/${PACKAGE_DIST_DEB} /deb-packages
98+
99+
RUN mkdir -p /artifacts/deb
100+
RUN set -eux; \
101+
\
102+
case "${TARGETARCH}" in \
103+
x86_64 | amd64) ARCH='amd64' ;; \
104+
ppc64el | ppc64le) ARCH='ppc64le' ;; \
105+
aarch64 | arm64) ARCH='arm64' ;; \
106+
*) echo "unsupported architecture" ; exit 1 ;; \
107+
esac; \
108+
for p in $(ls /deb-packages/${ARCH}/*.deb); do dpkg-deb -xv $p /artifacts/deb/; done
109+
110+
FROM nvidia/cuda:12.5.0-base-ubi8 AS artifacts
111+
112+
COPY --from=rpmpackages /artifacts/rpm /artifacts/rpm
113+
COPY --from=debpackages /artifacts/deb /artifacts/deb
114+
COPY --from=build /artifacts/bin /artifacts/build
115+
116+
FROM nvidia/cuda:12.6.0-base-ubi8
117+
118+
ENV NVIDIA_DISABLE_REQUIRE="true"
119+
ENV NVIDIA_VISIBLE_DEVICES=void
120+
ENV NVIDIA_DRIVER_CAPABILITIES=utility
121+
122+
COPY --from=artifacts /artifacts/rpm /artifacts/rpm
123+
COPY --from=artifacts /artifacts/deb /artifacts/deb
124+
COPY --from=artifacts /artifacts/build /work
125+
126+
WORKDIR /work
76127
ENV PATH=/work:$PATH
77128

78129
LABEL io.k8s.display-name="NVIDIA Container Runtime Config"

deployments/container/Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,13 @@ $(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
9595
--provenance=false --sbom=false \
9696
$(DOCKER_BUILD_OPTIONS) \
9797
$(DOCKER_BUILD_PLATFORM_OPTIONS) \
98+
$(INTERMEDIATE_TARGET) \
9899
--tag $(IMAGE) \
99100
--build-arg ARTIFACTS_ROOT="$(ARTIFACTS_ROOT)" \
100101
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
101102
--build-arg PACKAGE_DIST="$(PACKAGE_DIST)" \
103+
--build-arg PACKAGE_DIST_DEB="$(PACKAGE_DIST_DEB)" \
104+
--build-arg PACKAGE_DIST_RPM="$(PACKAGE_DIST_RPM)" \
102105
--build-arg PACKAGE_VERSION="$(PACKAGE_VERSION)" \
103106
--build-arg VERSION="$(VERSION)" \
104107
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
@@ -109,14 +112,18 @@ $(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
109112
$(CURDIR)
110113

111114

115+
PACKAGE_DIST_DEB = ubuntu18.04
116+
# TODO: This needs to be set to centos8 for ppc64le builds
117+
PACKAGE_DIST_RPM = centos7
118+
112119
build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu
113120
build-ubuntu%: PACKAGE_DIST = ubuntu18.04
114121

115122
build-ubi8: DOCKERFILE_SUFFIX := ubi8
116123
build-ubi8: PACKAGE_DIST = centos7
117124

118-
build-packaging: DOCKERFILE_SUFFIX := packaging
119-
build-packaging: PACKAGE_ARCH := amd64
125+
build-packaging: DOCKERFILE_SUFFIX := ubi8
126+
build-packaging: INTERMEDIATE_TARGET := --target=packaging
120127
build-packaging: PACKAGE_DIST = all
121128

122129
# Test targets

0 commit comments

Comments
 (0)