Skip to content

Commit 076cbb9

Browse files
committed
feat: support DTK with Go
Signed-off-by: Fred Rolland <frolland@nvidia.com>
1 parent a9badf3 commit 076cbb9

File tree

15 files changed

+697
-203
lines changed

15 files changed

+697
-203
lines changed

Golang_RHEL_Dockerfile

Lines changed: 0 additions & 167 deletions
This file was deleted.

RHEL_Dockerfile

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,35 @@ ARG STIG_COMPLIANT=false
1212
# Final clean image of precompiled driver container
1313
ARG D_FINAL_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi:latest
1414

15-
##################################################################
16-
# Stage: Minimal base image update and install common requirements
17-
1815
# DTK base image (below example for specific kernel headers version)
1916
ARG D_BASE_IMAGE="registry.redhat.io/openshift4/driver-toolkit-rhel9:v4.13.0-202309112001.p0.gd719bdc.assembly.stream"
2017
# Standart: registry.access.redhat.com/ubi9:latest
2118

2219
ARG D_PYTHON_VERSION="36"
2320
ARG D_PYTHON="python${D_PYTHON_VERSION}"
2421

22+
##################################################################
23+
# Stage: build go binary for entrypoint
24+
FROM golang:1.24 AS go_builder
25+
26+
# Set GOPROXY if provided
27+
ARG GOPROXY
28+
ENV GOPROXY=$GOPROXY
29+
30+
WORKDIR /workspace
31+
32+
COPY entrypoint/go.mod go.mod
33+
COPY entrypoint/go.sum go.sum
34+
35+
RUN go mod download
36+
37+
COPY entrypoint/ .
38+
39+
RUN TARGETARCH=${D_ARCH} TARGETOS=linux make build
40+
41+
##################################################################
42+
# Stage: Minimal base image update and install common requirements
43+
2544
FROM $D_BASE_IMAGE AS base
2645

2746
# Inherited global args
@@ -38,6 +57,13 @@ RUN set -x && \
3857
# Container functional requirements
3958
jq iproute kmod procps-ng udev
4059

60+
COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint
61+
WORKDIR /root
62+
ADD ./entrypoint.sh /root/entrypoint.sh
63+
ADD ./loader.sh /root/loader.sh
64+
65+
ENTRYPOINT ["/root/loader.sh"]
66+
4167
##############################################################################################
4268
# Stage: Download NVIDIA driver sources and install src driver container packages requirements
4369

@@ -78,7 +104,7 @@ RUN if file ${D_OFED_SRC_ARCHIVE} | grep compressed; then \
78104
mv ${D_OFED_SRC_ARCHIVE}/MLNX_OFED_SRC-${D_OFED_VERSION} . ; \
79105
fi
80106

81-
WORKDIR /
107+
WORKDIR /root
82108
ADD ./entrypoint.sh /root/entrypoint.sh
83109
ADD ./dtk_nic_driver_build.sh /root/dtk_nic_driver_build.sh
84110

@@ -92,7 +118,7 @@ RUN set -x && \
92118
fi && \
93119
rm -f /tmp/stig-fixer.sh
94120

95-
ENTRYPOINT ["/root/entrypoint.sh"]
121+
ENTRYPOINT ["/root/loader.sh"]
96122
CMD ["sources"]
97123

98124
LABEL doca-version=${D_DOCA_VERSION}
@@ -151,7 +177,9 @@ RUN touch /lib/modules/${D_KERNEL_VER}/modules.order /lib/modules/${D_KERNEL_VER
151177

152178
WORKDIR /
153179
ADD ./entrypoint.sh /root/entrypoint.sh
180+
ADD ./loader.sh /root/loader.sh
181+
COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint
154182
ADD ./dtk_nic_driver_build.sh /root/dtk_nic_driver_build.sh
155183

156-
ENTRYPOINT ["/root/entrypoint.sh"]
184+
ENTRYPOINT ["/root/loader.sh"]
157185
CMD ["precompiled"]

THIRD_PARTY_NOTICES

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
720720
See the License for the specific language governing permissions and
721721
limitations under the License.
722722

723+
---
724+
## go-shellquote
725+
726+
Copyright (C) 2014 Kevin Ballard
727+
728+
Permission is hereby granted, free of charge, to any person obtaining
729+
a copy of this software and associated documentation files (the "Software"),
730+
to deal in the Software without restriction, including without limitation
731+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
732+
and/or sell copies of the Software, and to permit persons to whom the
733+
Software is furnished to do so, subject to the following conditions:
734+
735+
The above copyright notice and this permission notice shall be included
736+
in all copies or substantial portions of the Software.
737+
738+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
739+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
740+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
741+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
742+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
743+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
744+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
745+
723746
---
724747
## entrypoint
725748

dtk_nic_driver_build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
#!/bin/bash
22
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33

4+
# Load environment variables if file exists
5+
if [ -f "$(dirname "$0")/dtk.env" ]; then
6+
source "$(dirname "$0")/dtk.env"
7+
fi
8+
9+
: ${USE_NEW_ENTRYPOINT:=false}
10+
11+
if [ "$USE_NEW_ENTRYPOINT" = "true" ]; then
12+
echo "Using Go entrypoint for DTK build"
13+
exec "$(dirname "$0")/entrypoint" dtk-build
14+
fi
15+
416
: ${ENTRYPOINT_DEBUG:=false}
517
: ${DTK_OCP_NIC_SHARED_DIR:=/mnt/shared-nvidia-nic-driver-toolkit}
618

0 commit comments

Comments
 (0)