Skip to content
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

Add entrypoint Go binary #11

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
24 changes: 22 additions & 2 deletions RHEL_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ ARG OFED_SRC_LOCAL_DIR=${D_OFED_SRC_DOWNLOAD_PATH}/MLNX_OFED_SRC-${D_OFED_VERSIO
# Final clean image of precompiled driver container
ARG D_FINAL_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi:latest

##################################################################
# Stage: build go binary for entrypoint
FROM golang:1.23 AS go_builder

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

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

Expand Down Expand Up @@ -70,10 +85,13 @@ RUN set -x && \
cd ${D_OFED_SRC_DOWNLOAD_PATH} && (curl -sL ${D_OFED_URL_PATH} | tar -xzf -)

WORKDIR /

COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint
ADD ./entrypoint.sh /root/entrypoint.sh
ADD ./dtk_nic_driver_build.sh /root/dtk_nic_driver_build.sh
ADD ./loader.sh /root/loader.sh

ENTRYPOINT ["/root/entrypoint.sh"]
ENTRYPOINT ["/root/loader.sh"]
CMD ["sources"]

#####################
Expand Down Expand Up @@ -135,8 +153,10 @@ RUN touch /lib/modules/${D_KERNEL_VER}/modules.order /lib/modules/${D_KERNEL_VER
depmod ${D_KERNEL_VER}

WORKDIR /
COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint
ADD ./entrypoint.sh /root/entrypoint.sh
ADD ./dtk_nic_driver_build.sh /root/dtk_nic_driver_build.sh
ADD ./loader.sh /root/loader.sh

ENTRYPOINT ["/root/entrypoint.sh"]
ENTRYPOINT ["/root/loader.sh"]
CMD ["precompiled"]
20 changes: 18 additions & 2 deletions Ubuntu_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ ARG OFED_SRC_LOCAL_DIR=${D_OFED_SRC_DOWNLOAD_PATH}/MLNX_OFED_SRC-${D_OFED_VERSIO
# Common for build and final clean image of precompiled driver container
ARG D_BASE_IMAGE="ubuntu:22.04"

##################################################################
# Stage: build go binary for entrypoint
FROM golang:1.23 AS go_builder

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

##################################################################
# Stage: Minimal base image update and install common requirements
FROM $D_BASE_IMAGE AS base
Expand All @@ -34,10 +49,11 @@ RUN set -x && \
# Container functional requirements
jq iproute2 udev ethtool

WORKDIR /
COPY --from=go_builder /workspace/build/entrypoint /root/entrypoint
ADD ./entrypoint.sh /root/entrypoint.sh
ADD ./loader.sh /root/loader.sh

ENTRYPOINT ["/root/entrypoint.sh"]
ENTRYPOINT ["/root/loader.sh"]

##############################################################################################
# Stage: Download NVIDIA driver sources and install src driver container packages requirements
Expand Down
3 changes: 3 additions & 0 deletions entrypoint/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
bin/
cover.out
133 changes: 133 additions & 0 deletions entrypoint/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
run:
timeout: 10m
# If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
#
# Allowed values: readonly|vendor|mod
# By default, it isn't set.
modules-download-mode: readonly
tests: false

linters:
disable-all: true
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- decorder
- dogsled
- durationcheck
- errcheck
- errchkjson
- errname
- copyloopvar
- fatcontext
- funlen
- ginkgolinter
- goconst
- gocritic
- gocyclo
- gofmt
- gofumpt
- goimports
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- importas
- ineffassign
- interfacebloat
- intrange
- lll
- loggercheck
- maintidx
- makezero
- misspell
- nakedret
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- prealloc
- predeclared
- promlinter
- reassign
- revive
- rowserrcheck
- sloglint
- staticcheck
- stylecheck
- tagalign
- tenv
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace

linters-settings:
funlen:
lines: 120
statements: 55
goconst:
min-len: 2
min-occurrences: 2
gocyclo:
min-complexity: 30
goimports:
local-prefixes: github.com/Mellanox/doca-driver-build
lll:
line-length: 140
misspell:
locale: US
stylecheck:
checks: ["all", "-ST1000"]
dot-import-whitelist:
- github.com/onsi/ginkgo/v2
- github.com/onsi/ginkgo/v2/extensions/table
- github.com/onsi/gomega
- github.com/onsi/gomega/gstruct
gocritic:
disabled-checks:
- appendAssign
ireturn:
allow:
- anon
- error
- empty
- stdlib
revive:
rules:
- name: package-comments
severity: warning
disabled: true
exclude: [""]
- name: import-shadowing
severity: warning
disabled: false
exclude: [""]
- name: exported
severity: warning
disabled: false
exclude: [""]
arguments:
- "checkPrivateReceivers"
- "checkPublicInterface"
10 changes: 10 additions & 0 deletions entrypoint/.mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
with-expecter: True
dir: "{{.InterfaceDir}}/mocks"
mockname: "{{.InterfaceName}}"
outpkg: "{{.PackageName}}"
filename: "{{.InterfaceName}}.go"
all: True
packages:
github.com/Mellanox/doca-driver-build/entrypoint/internal:
config:
recursive: True
Loading
Loading