-
Notifications
You must be signed in to change notification settings - Fork 13
[DNM] feat: support DTK with Go #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,16 +12,35 @@ ARG STIG_COMPLIANT=false | |||||||
| # Final clean image of precompiled driver container | ||||||||
| ARG D_FINAL_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi:latest | ||||||||
|
|
||||||||
| ################################################################## | ||||||||
| # Stage: Minimal base image update and install common requirements | ||||||||
|
|
||||||||
| # DTK base image (below example for specific kernel headers version) | ||||||||
| ARG D_BASE_IMAGE="registry.redhat.io/openshift4/driver-toolkit-rhel9:v4.13.0-202309112001.p0.gd719bdc.assembly.stream" | ||||||||
| # Standart: registry.access.redhat.com/ubi9:latest | ||||||||
|
|
||||||||
| ARG D_PYTHON_VERSION="36" | ||||||||
| ARG D_PYTHON="python${D_PYTHON_VERSION}" | ||||||||
|
|
||||||||
| ################################################################## | ||||||||
| # Stage: build go binary for entrypoint | ||||||||
| FROM golang:1.24 AS go_builder | ||||||||
|
|
||||||||
| # Set GOPROXY if provided | ||||||||
| ARG GOPROXY | ||||||||
| ENV GOPROXY=$GOPROXY | ||||||||
|
|
||||||||
| WORKDIR /workspace | ||||||||
|
|
||||||||
| COPY entrypoint/go.mod go.mod | ||||||||
| COPY entrypoint/go.sum go.sum | ||||||||
|
|
||||||||
| RUN go mod download | ||||||||
|
|
||||||||
| COPY entrypoint/ . | ||||||||
|
|
||||||||
| RUN TARGETARCH=${D_ARCH} TARGETOS=linux make build | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| ################################################################## | ||||||||
| # Stage: Minimal base image update and install common requirements | ||||||||
|
|
||||||||
| FROM $D_BASE_IMAGE AS base | ||||||||
|
|
||||||||
| # Inherited global args | ||||||||
|
|
@@ -38,6 +57,13 @@ RUN set -x && \ | |||||||
| # Container functional requirements | ||||||||
| jq iproute kmod procps-ng udev | ||||||||
|
|
||||||||
| COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint | ||||||||
| WORKDIR /root | ||||||||
| ADD ./entrypoint.sh /root/entrypoint.sh | ||||||||
| ADD ./loader.sh /root/loader.sh | ||||||||
|
|
||||||||
| ENTRYPOINT ["/root/loader.sh"] | ||||||||
|
|
||||||||
| ############################################################################################## | ||||||||
| # Stage: Download NVIDIA driver sources and install src driver container packages requirements | ||||||||
|
|
||||||||
|
|
@@ -78,7 +104,7 @@ RUN if file ${D_OFED_SRC_ARCHIVE} | grep compressed; then \ | |||||||
| mv ${D_OFED_SRC_ARCHIVE}/MLNX_OFED_SRC-${D_OFED_VERSION} . ; \ | ||||||||
| fi | ||||||||
|
|
||||||||
| WORKDIR / | ||||||||
| WORKDIR /root | ||||||||
| ADD ./entrypoint.sh /root/entrypoint.sh | ||||||||
| ADD ./dtk_nic_driver_build.sh /root/dtk_nic_driver_build.sh | ||||||||
|
|
||||||||
|
|
@@ -92,7 +118,7 @@ RUN set -x && \ | |||||||
| fi && \ | ||||||||
| rm -f /tmp/stig-fixer.sh | ||||||||
|
|
||||||||
| ENTRYPOINT ["/root/entrypoint.sh"] | ||||||||
| ENTRYPOINT ["/root/loader.sh"] | ||||||||
| CMD ["sources"] | ||||||||
|
|
||||||||
| LABEL doca-version=${D_DOCA_VERSION} | ||||||||
|
|
@@ -149,9 +175,11 @@ RUN touch /lib/modules/${D_KERNEL_VER}/modules.order /lib/modules/${D_KERNEL_VER | |||||||
| # Introduce installed kernel modules | ||||||||
| depmod ${D_KERNEL_VER} | ||||||||
|
|
||||||||
| WORKDIR / | ||||||||
| WORKDIR /root | ||||||||
| ADD ./entrypoint.sh /root/entrypoint.sh | ||||||||
| ADD ./loader.sh /root/loader.sh | ||||||||
| COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint | ||||||||
| ADD ./dtk_nic_driver_build.sh /root/dtk_nic_driver_build.sh | ||||||||
|
|
||||||||
| ENTRYPOINT ["/root/entrypoint.sh"] | ||||||||
| ENTRYPOINT ["/root/loader.sh"] | ||||||||
| CMD ["precompiled"] | ||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,18 @@ | ||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||
| # Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Load environment variables if file exists | ||||||||||||||||||||||||||||||||
| if [ -f "$(dirname "$0")/dtk.env" ]; then | ||||||||||||||||||||||||||||||||
| source "$(dirname "$0")/dtk.env" | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| : ${USE_NEW_ENTRYPOINT:=false} | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if [ "$USE_NEW_ENTRYPOINT" = "true" ]; then | ||||||||||||||||||||||||||||||||
| echo "Using Go entrypoint for DTK build" | ||||||||||||||||||||||||||||||||
| exec "$(dirname "$0")/entrypoint" dtk-build | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sourced env overwritten
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| : ${ENTRYPOINT_DEBUG:=false} | ||||||||||||||||||||||||||||||||
| : ${DTK_OCP_NIC_SHARED_DIR:=/mnt/shared-nvidia-nic-driver-toolkit} | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ARG in stage
The
go_builderstage usesRUN TARGETARCH=${D_ARCH} TARGETOS=linux make build, butD_ARCHis not declared in that stage (only before the firstFROM). In Docker, ARGs must be re-declared in each stage to be available toRUN, so${D_ARCH}can expand empty and build the entrypoint for the wrong arch.