Skip to content

Commit dd44d4e

Browse files
committed
chore: Update go version
- update Go version - update lint version - Revert Docker files and add new one for integration phase Signed-off-by: Fred Rolland <[email protected]>
1 parent 4231821 commit dd44d4e

File tree

6 files changed

+167
-45
lines changed

6 files changed

+167
-45
lines changed

Golang_Ubuntu_Dockerfile

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Common (multistage) args
2+
ARG D_OS="ubuntu22.04"
3+
ARG D_ARCH="x86_64"
4+
ARG D_CONTAINER_VER="0"
5+
ARG D_DOCA_VERSION="2.9.1"
6+
ARG D_OFED_VERSION="24.10-1.1.4.0"
7+
ARG D_KERNEL_VER="5.15.0-25-generic"
8+
ARG D_OFED_SRC_DOWNLOAD_PATH="/run/mellanox/src"
9+
ARG OFED_SRC_LOCAL_DIR=${D_OFED_SRC_DOWNLOAD_PATH}/MLNX_OFED_SRC-${D_OFED_VERSION}
10+
11+
# Common for build and final clean image of precompiled driver container
12+
ARG D_BASE_IMAGE="ubuntu:22.04"
13+
14+
##################################################################
15+
# Stage: build go binary for entrypoint
16+
FROM golang:1.24 AS go_builder
17+
18+
WORKDIR /workspace
19+
20+
COPY entrypoint/go.mod go.mod
21+
COPY entrypoint/go.sum go.sum
22+
23+
RUN go mod download
24+
25+
COPY entrypoint/ .
26+
27+
RUN TARGETARCH=${D_ARCH} TARGETOS=linux make build
28+
29+
##################################################################
30+
# Stage: Minimal base image update and install common requirements
31+
FROM $D_BASE_IMAGE AS base
32+
33+
ARG D_APT_REMOVE=""
34+
ARG D_OFED_VERSION
35+
ARG D_CONTAINER_VER
36+
ARG D_OFED_SRC_DOWNLOAD_PATH
37+
38+
ENV NVIDIA_NIC_DRIVER_VER=${D_OFED_VERSION}
39+
ENV NVIDIA_NIC_CONTAINER_VER=${D_CONTAINER_VER}
40+
41+
WORKDIR /root
42+
RUN set -x && \
43+
for source in ${D_APT_REMOVE}; do rm -f /etc/apt/sources.list.d/${source}.list; done && \
44+
# Perform distro update and install prerequirements
45+
apt-get -yq update && \
46+
DEBIAN_FRONTEND=noninteractive apt-get -yq upgrade && \
47+
DEBIAN_FRONTEND=noninteractive apt-get -yq install apt-utils \
48+
# Driver build / install script requirements
49+
perl pciutils kmod lsof python3 dh-python \
50+
# Container functional requirements
51+
jq iproute2 udev ethtool ca-certificates
52+
53+
COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint
54+
ADD ./entrypoint.sh /root/entrypoint.sh
55+
ADD ./loader.sh /root/loader.sh
56+
57+
ENTRYPOINT ["/root/loader.sh"]
58+
59+
##############################################################################################
60+
# Stage: Download NVIDIA driver sources and install src driver container packages requirements
61+
62+
FROM base AS driver-src
63+
64+
# Inherited global args
65+
ARG D_OS
66+
ARG D_DOCA_VERSION
67+
ARG D_OFED_VERSION
68+
ARG D_OFED_SRC_DOWNLOAD_PATH
69+
70+
# Stage args
71+
ARG D_OFED_BASE_URL="https://linux.mellanox.com/public/repo/doca/${D_DOCA_VERSION}/SOURCES/MLNX_OFED"
72+
ARG D_OFED_SRC_TYPE="debian-"
73+
74+
ARG D_OFED_SRC_ARCHIVE="MLNX_OFED_SRC-${D_OFED_SRC_TYPE}${D_OFED_VERSION}.tgz"
75+
ARG D_OFED_URL_PATH="${D_OFED_BASE_URL}/${D_OFED_SRC_ARCHIVE}" # although argument name says URL, local `*.tgz` compressed files may also be used (intended for internal use)
76+
ENV NVIDIA_NIC_DRIVER_PATH="${D_OFED_SRC_DOWNLOAD_PATH}/MLNX_OFED_SRC-${D_OFED_VERSION}"
77+
78+
WORKDIR /root
79+
RUN set -x && \
80+
echo $D_OS | grep "ubuntu20.04" || GCC_VER="-12" && \
81+
# Install prerequirements \
82+
DEBIAN_FRONTEND=noninteractive apt-get -yq install curl \
83+
dkms make autoconf autotools-dev chrpath automake hostname debhelper gcc$GCC_VER quilt libc6-dev build-essential pkg-config && \
84+
# Cleanup \
85+
apt-get clean autoclean && \
86+
rm -rf /var/lib/apt/lists/*
87+
88+
RUN echo $D_OS | grep "ubuntu20.04" || ln -fs gcc-12 /usr/bin/gcc # 'build-essential' installs `gcc`, however (if above ubuntu 20.04) we need `gcc-12`, so we overwrite it with this link
89+
90+
# Download NVIDIA NIC driver
91+
RUN mkdir -p ${D_OFED_SRC_DOWNLOAD_PATH}
92+
WORKDIR ${D_OFED_SRC_DOWNLOAD_PATH}
93+
ADD ${D_OFED_URL_PATH} ${D_OFED_SRC_ARCHIVE}
94+
RUN if file ${D_OFED_SRC_ARCHIVE} | grep compressed; then \
95+
tar -xzf ${D_OFED_SRC_ARCHIVE}; \
96+
else \
97+
mv ${D_OFED_SRC_ARCHIVE}/MLNX_OFED_SRC-${D_OFED_VERSION} . ; \
98+
fi
99+
100+
WORKDIR /root
101+
102+
CMD ["sources"]
103+
104+
LABEL doca-version=${D_DOCA_VERSION}
105+
LABEL ofed-version=${D_OFED_VERSION}
106+
107+
#####################
108+
# Stage: Build driver
109+
110+
FROM driver-src AS driver-builder
111+
112+
# Inherited global args
113+
ARG D_OS
114+
ARG D_KERNEL_VER
115+
ARG OFED_SRC_LOCAL_DIR
116+
# Additional local arg (for precompiled CI)
117+
ARG D_BUILD_EXTRA_ARGS
118+
119+
# Driver build manadatory packages
120+
RUN set -x && \
121+
apt-get update && \
122+
DEBIAN_FRONTEND=noninteractive apt-get -yq install linux-image-${D_KERNEL_VER} linux-headers-${D_KERNEL_VER}
123+
124+
# Build driver
125+
RUN set -x && \
126+
${OFED_SRC_LOCAL_DIR}/install.pl --without-depcheck --distro ${D_OS} --without-dkms --kernel ${D_KERNEL_VER} --kernel-only --build-only --copy-ifnames-udev --with-mlnx-tools --without-knem-modules --without-srp-modules --without-kernel-mft-modules --without-iser-modules --without-isert-modules ${D_BUILD_EXTRA_ARGS}
127+
128+
###################################
129+
# Stage: Install precompiled driver
130+
131+
FROM base AS precompiled
132+
133+
# Inherited global args
134+
ARG D_OS
135+
ARG D_ARCH
136+
ARG D_KERNEL_VER
137+
ARG OFED_SRC_LOCAL_DIR
138+
139+
ENV NVIDIA_NIC_DRIVER_PATH=""
140+
141+
RUN set -x && \
142+
apt-get install -y lsb-release && \
143+
test -n "${D_KERNEL_VER}" && apt-get install -y linux-modules-extra-${D_KERNEL_VER} || true # only install this package when kernel variable defined
144+
# Cleanup
145+
RUN set -x && \
146+
apt-get clean autoclean && \
147+
rm -rf /var/lib/apt/lists/*
148+
149+
# Install driver
150+
COPY --from=driver-builder ${OFED_SRC_LOCAL_DIR}/DEBS/${D_OS}/*/*.deb /root/
151+
152+
RUN apt-get install -y /root/*.deb
153+
154+
# Prevent modprobe from giving a WARNING about missing files
155+
RUN touch /lib/modules/${D_KERNEL_VER}/modules.order /lib/modules/${D_KERNEL_VER}/modules.builtin && \
156+
# Introduce installed kernel modules
157+
depmod ${D_KERNEL_VER}
158+
159+
CMD ["precompiled"]

RHEL_Dockerfile

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@ ARG OFED_SRC_LOCAL_DIR=${D_OFED_SRC_DOWNLOAD_PATH}/MLNX_OFED_SRC-${D_OFED_VERSIO
1111
# Final clean image of precompiled driver container
1212
ARG D_FINAL_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi:latest
1313

14-
##################################################################
15-
# Stage: build go binary for entrypoint
16-
FROM golang:1.23 AS go_builder
17-
18-
WORKDIR /workspace
19-
20-
COPY entrypoint/go.mod go.mod
21-
COPY entrypoint/go.sum go.sum
22-
23-
RUN go mod download
24-
25-
COPY entrypoint/ .
26-
27-
RUN TARGETARCH=${D_ARCH} TARGETOS=linux make build
28-
2914
##################################################################
3015
# Stage: Minimal base image update and install common requirements
3116

@@ -92,13 +77,10 @@ RUN if file ${D_OFED_SRC_ARCHIVE} | grep compressed; then \
9277
fi
9378

9479
WORKDIR /
95-
96-
COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint
9780
ADD ./entrypoint.sh /root/entrypoint.sh
9881
ADD ./dtk_nic_driver_build.sh /root/dtk_nic_driver_build.sh
99-
ADD ./loader.sh /root/loader.sh
10082

101-
ENTRYPOINT ["/root/loader.sh"]
83+
ENTRYPOINT ["/root/entrypoint.sh"]
10284
CMD ["sources"]
10385

10486
LABEL doca-version=${D_DOCA_VERSION}
@@ -156,10 +138,8 @@ RUN touch /lib/modules/${D_KERNEL_VER}/modules.order /lib/modules/${D_KERNEL_VER
156138
depmod ${D_KERNEL_VER}
157139

158140
WORKDIR /
159-
COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint
160141
ADD ./entrypoint.sh /root/entrypoint.sh
161142
ADD ./dtk_nic_driver_build.sh /root/dtk_nic_driver_build.sh
162-
ADD ./loader.sh /root/loader.sh
163143

164-
ENTRYPOINT ["/root/loader.sh"]
165-
CMD ["precompiled"]
144+
ENTRYPOINT ["/root/entrypoint.sh"]
145+
CMD ["precompiled"]

Ubuntu_Dockerfile

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@ ARG OFED_SRC_LOCAL_DIR=${D_OFED_SRC_DOWNLOAD_PATH}/MLNX_OFED_SRC-${D_OFED_VERSIO
1111
# Common for build and final clean image of precompiled driver container
1212
ARG D_BASE_IMAGE="ubuntu:22.04"
1313

14-
##################################################################
15-
# Stage: build go binary for entrypoint
16-
FROM golang:1.23 AS go_builder
17-
18-
WORKDIR /workspace
19-
20-
COPY entrypoint/go.mod go.mod
21-
COPY entrypoint/go.sum go.sum
22-
23-
RUN go mod download
24-
25-
COPY entrypoint/ .
26-
27-
RUN TARGETARCH=${D_ARCH} TARGETOS=linux make build
28-
2914
##################################################################
3015
# Stage: Minimal base image update and install common requirements
3116
FROM $D_BASE_IMAGE AS base
@@ -50,11 +35,10 @@ RUN set -x && \
5035
# Container functional requirements
5136
jq iproute2 udev ethtool ca-certificates
5237

53-
COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint
38+
WORKDIR /
5439
ADD ./entrypoint.sh /root/entrypoint.sh
55-
ADD ./loader.sh /root/loader.sh
5640

57-
ENTRYPOINT ["/root/loader.sh"]
41+
ENTRYPOINT ["/root/entrypoint.sh"]
5842

5943
##############################################################################################
6044
# Stage: Download NVIDIA driver sources and install src driver container packages requirements
@@ -156,4 +140,4 @@ RUN touch /lib/modules/${D_KERNEL_VER}/modules.order /lib/modules/${D_KERNEL_VER
156140
# Introduce installed kernel modules
157141
depmod ${D_KERNEL_VER}
158142

159-
CMD ["precompiled"]
143+
CMD ["precompiled"]

entrypoint/.golangci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ linters:
7272
- staticcheck
7373
- stylecheck
7474
- tagalign
75-
- tenv
7675
- thelper
7776
- tparallel
7877
- typecheck

entrypoint/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ $(MOCKERY): | $(LOCALBIN)
4747
GOBIN=$(LOCALBIN) go install github.com/vektra/mockery/v2@$(MOCKERY_VERSION)
4848

4949
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
50-
GOLANGCI_LINT_VERSION ?= v1.62.0
50+
GOLANGCI_LINT_VERSION ?= v1.64.8
5151
.PHONY: golangci-lint ## Download golangci-lint locally if necessary.
5252
golangci-lint:
5353
@[ -f $(GOLANGCI_LINT) ] || { \

entrypoint/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/Mellanox/doca-driver-build/entrypoint
22

3-
go 1.23.2
3+
go 1.24.0
44

55
require (
66
github.com/go-logr/logr v1.4.2

0 commit comments

Comments
 (0)