Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 0 additions & 167 deletions Golang_RHEL_Dockerfile

This file was deleted.

42 changes: 35 additions & 7 deletions RHEL_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +24 to +39
Copy link

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_builder stage uses RUN TARGETARCH=${D_ARCH} TARGETOS=linux make build, but D_ARCH is not declared in that stage (only before the first FROM). In Docker, ARGs must be re-declared in each stage to be available to RUN, so ${D_ARCH} can expand empty and build the entrypoint for the wrong arch.

Suggested change
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
FROM golang:1.24 AS go_builder
ARG D_ARCH

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D_ARCH not declared in this stage - expands to empty string, building for wrong architecture

Suggested change
RUN TARGETARCH=${D_ARCH} TARGETOS=linux make build
ARG D_ARCH
RUN TARGETARCH=${D_ARCH} TARGETOS=linux make build


##################################################################
# Stage: Minimal base image update and install common requirements

FROM $D_BASE_IMAGE AS base

# Inherited global args
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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}
Expand Down Expand Up @@ -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"]
23 changes: 23 additions & 0 deletions THIRD_PARTY_NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
See the License for the specific language governing permissions and
limitations under the License.

---
## go-shellquote

Copyright (C) 2014 Kevin Ballard

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
## entrypoint

Expand Down
12 changes: 12 additions & 0 deletions dtk_nic_driver_build.sh
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourced env overwritten
After sourcing dtk.env (lines 4-7), the script later resets DTK_OCP_START_COMPILE_FLAG, DTK_OCP_DONE_COMPILE_FLAG, and DTK_OCP_COMPILED_DRIVER_VER to empty strings (lines 23-25). This overwrites the values written by dtkSetupDriverBuild, so the bash build path will always hit the “Compilation start/completion flags not set, aborting” check.

Suggested change
# 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
# Only default these when not already set by the environment/dtk.env
: "${DTK_OCP_START_COMPILE_FLAG:=}"
: "${DTK_OCP_DONE_COMPILE_FLAG:=}"
: "${DTK_OCP_COMPILED_DRIVER_VER:=}"


: ${ENTRYPOINT_DEBUG:=false}
: ${DTK_OCP_NIC_SHARED_DIR:=/mnt/shared-nvidia-nic-driver-toolkit}

Expand Down
Loading
Loading