|
| 1 | +# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +ARG BASE_DIST=ubuntu20.04 |
| 16 | +ARG CUDA_VERSION |
| 17 | +ARG GOLANG_VERSION=x.x.x |
| 18 | +ARG VERSION="N/A" |
| 19 | + |
| 20 | +# NOTE: In cases where the libc version is a concern, we would have to use an |
| 21 | +# image based on the target OS to build the golang executables here -- especially |
| 22 | +# if cgo code is included. |
| 23 | +FROM golang:${GOLANG_VERSION} AS build |
| 24 | + |
| 25 | +SHELL ["/bin/bash", "-c"] |
| 26 | + |
| 27 | +ARG TARGETARCH |
| 28 | +WORKDIR /build |
| 29 | +COPY . . |
| 30 | +RUN go build -o /artifacts/nvidia-mig-parted ./cmd |
| 31 | +RUN go build -o /artifacts/nvidia-mig-manager ./deployments/gpu-operator/ |
| 32 | +RUN cp ./deployments/gpu-operator/reconfigure-mig.sh /artifacts/reconfigure-mig.sh |
| 33 | + |
| 34 | +RUN OS_ARCH=${TARGETARCH/x86_64/amd64} && OS_ARCH=${OS_ARCH/aarch64/arm64} && curl -o /artifacts/kubectl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${OS_ARCH}/kubectl"; |
| 35 | +RUN chmod a+x /artifacts/kubectl |
| 36 | + |
| 37 | +FROM nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST} |
| 38 | + |
| 39 | +COPY ./LICENSE ./licenses/LICENSE |
| 40 | +COPY --from=build /artifacts/nvidia-mig-parted /usr/bin/nvidia-mig-parted |
| 41 | +COPY --from=build /artifacts/nvidia-mig-manager /usr/bin/nvidia-mig-manager |
| 42 | +COPY --from=build /artifacts/reconfigure-mig.sh /usr/bin/reconfigure-mig.sh |
| 43 | +COPY --from=build /artifacts/kubectl /usr/bin/kubectl |
| 44 | + |
| 45 | +ENV NVIDIA_DISABLE_REQUIRE="true" |
| 46 | +ENV NVIDIA_VISIBLE_DEVICES=all |
| 47 | +ENV NVIDIA_MIG_CONFIG_DEVICES=all |
| 48 | +ENV NVIDIA_DRIVER_CAPABILITIES=utility |
| 49 | + |
| 50 | +LABEL version="${VERSION}" |
| 51 | +LABEL release="N/A" |
| 52 | +LABEL vendor="NVIDIA" |
| 53 | +LABEL io.k8s.display-name="NVIDIA MIG Manager for Kubernetes" |
| 54 | +LABEL name="NVIDIA MIG Manager for Kubernetes" |
| 55 | +LABEL summary="NVIDIA MIG Manager for Kubernetes" |
| 56 | +LABEL description="See summary" |
| 57 | + |
| 58 | +# Install / upgrade packages here that are required to resolve CVEs |
| 59 | +ARG CVE_UPDATES |
| 60 | +RUN if [ -n "${CVE_UPDATES}" ]; then \ |
| 61 | + apt-get update && apt-get upgrade -y ${CVE_UPDATES} && \ |
| 62 | + rm -rf /var/lib/apt/lists/*; \ |
| 63 | + fi |
| 64 | + |
| 65 | +ENTRYPOINT ["nvidia-mig-manager"] |
0 commit comments