1+ # Base image upgrade to UBI 9 with CUDA 12.6.3
2+ ARG GOLANG_VERSION=1.22.6
3+ FROM nvcr.io/nvidia/cuda:12.6.3-base-ubi9 AS build
4+
5+ # Install essential build tools
6+ RUN yum install -y \
7+ wget make git gcc \
8+ && \
9+ rm -rf /var/cache/yum/*
10+
11+ # Install Go manually for better version control
12+ RUN set -eux; \
13+ arch="$(uname -m)"; \
14+ case "${arch##*-}" in \
15+ x86_64 | amd64) ARCH='amd64' ;; \
16+ aarch64) ARCH='arm64' ;; \
17+ *) echo "unsupported architecture" ; exit 1 ;; \
18+ esac; \
19+ wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${ARCH}.tar.gz \
20+ | tar -C /usr/local -xz
21+
22+ ENV GOPATH /go
23+ ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
24+
25+ # Main build process
26+ WORKDIR /build
27+ COPY . .
28+ RUN mkdir /artifacts
29+ ARG VERSION="N/A"
30+ ARG GIT_COMMIT="unknown"
31+
32+ # Core components build
33+ RUN cd /k8s-vgpu && make all VERSION=$VERSION PREFIX=/artifacts
34+
35+ # Install NVIDIA MIG tool
36+ RUN go install github.com/NVIDIA/mig-parted/cmd/
[email protected] 37+
38+ # GPU library build stage
39+ FROM nvidia/cuda:12.2.0-devel-ubuntu20.04 AS nvbuild
40+ COPY ./libvgpu /libvgpu
41+ WORKDIR /libvgpu
42+ ENV DEBIAN_FRONTEND=noninteractive
43+ RUN apt-get -y update && apt-get -y install cmake
44+ RUN bash ./build.sh
45+
46+ # Image cleanup stage
47+ FROM redhat/ubi9-minimal:latest AS minimal
48+ RUN rpm -qa --queryformat='^%{NAME}-\[0-9\].*\.%{ARCH}$\n' | sort -u > /tmp/package-names.minimal
49+
50+ FROM nvcr.io/nvidia/cuda:12.6.3-base-ubi9 AS base
51+ WORKDIR /cleanup
52+ COPY --from=minimal /tmp/package-names.minimal .
53+ COPY deployments/container/cleanup/* .
54+ RUN ./cleanup.sh
55+
56+ # Final image composition
57+ FROM base
58+ ENV NVIDIA_DISABLE_REQUIRE="true" \
59+ NVIDIA_VISIBLE_DEVICES=all \
60+ NVIDIA_DRIVER_CAPABILITIES=compute,utility
61+
62+ # Metadata labels
63+ LABEL version="$VERSION" \
64+ 65+ io.k8s.display-name="HAMi vGPU Plugin" \
66+ vendor="4paradigm" \
67+ com.nvidia.git-commit=${GIT_COMMIT}
68+
69+ # File system organization
70+ COPY ./LICENSE /k8s-vgpu/LICENSE
71+ COPY --from=build /artifacts/ /k8s-vgpu/bin/
72+ COPY --from=build /go/bin/nvidia-mig-parted /k8s-vgpu/bin/
73+ COPY --from=nvbuild /libvgpu/build/libvgpu.so /k8s-vgpu/lib/nvidia/libvgpu.so."$VERSION"
74+ COPY ./docker/*.sh /k8s-vgpu/bin/
75+ COPY ./lib /k8s-vgpu/lib
76+
77+ # Runtime configuration
78+ ENV PATH="/k8s-vgpu/bin:${PATH}"
79+ ENTRYPOINT ["entrypoint.sh"]
0 commit comments