Skip to content

Commit f1de27e

Browse files
committed
build: update Dockerfiles from network-operator-25.10.x branch
Signed-off-by: Fred Rolland <frolland@nvidia.com>
1 parent 6b8ef70 commit f1de27e

7 files changed

+63
-14
lines changed

Dockerfile.nvidia

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,23 @@
1616

1717
ARG BASE_IMAGE_GO_DISTROLESS_DEV
1818

19-
FROM golang:1.23 AS builder
19+
FROM golang:1.25 AS builder
20+
21+
ARG GOPROXY
22+
ENV GOPROXY=$GOPROXY
23+
2024
WORKDIR /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator
2125
COPY . .
2226
RUN make _build-manager BIN_PATH=build/_output/cmd
2327
RUN make _build-sriov-network-operator-config-cleanup BIN_PATH=build/_output/cmd
2428

2529
FROM ${BASE_IMAGE_GO_DISTROLESS_DEV:-nvcr.io/nvidia/distroless/go:v3.2.1-dev}
30+
USER 65532:65532
2631
COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/build/_output/cmd/manager /usr/bin/sriov-network-operator
2732
COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/build/_output/cmd/sriov-network-operator-config-cleanup /usr/bin/sriov-network-operator-config-cleanup
2833
COPY bindata /bindata
2934
# copy project sources into the container
3035
COPY . /src
3136
ENV OPERATOR_NAME=sriov-network-operator
37+
WORKDIR /
3238
CMD ["/usr/bin/sriov-network-operator"]

Dockerfile.sriov-network-config-daemon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ FROM quay.io/centos/centos:stream9
77
ARG MSTFLINT=mstflint
88
# We have to ensure that pciutils is installed. This package is needed for mstfwreset to succeed.
99
# xref pkg/vendors/mellanox/mellanox.go#L150
10-
RUN if [ "$(uname -m)" = "s390x" ]; then yum -y install hwdata pciutils; else yum -y install hwdata pciutils "${MSTFLINT}"; fi && yum clean all
10+
RUN ARCH_DEP_PKGS=$(if [ "$(uname -m)" != "s390x" ]; then echo -n ${MSTFLINT} ; fi) \
11+
&& yum -y install hwdata pciutils $ARCH_DEP_PKGS \
12+
&& yum clean all
1113
LABEL io.k8s.display-name="sriov-network-config-daemon" \
1214
io.k8s.description="This is a daemon that manage and config sriov network devices in Kubernetes cluster"
1315
COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/build/_output/cmd/sriov-network-config-daemon /usr/bin/

Dockerfile.sriov-network-config-daemon-stig

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1-
FROM golang:1.23 AS builder
1+
FROM golang:1.25 AS builder
2+
3+
ARG GOPROXY
4+
ENV GOPROXY=$GOPROXY
5+
26
WORKDIR /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator
37
COPY . .
48
RUN make _build-sriov-network-config-daemon BIN_PATH=build/_output/cmd
59

610
FROM nvcr.io/nvstaging/mellanox/ubuntu-pro-stig:24.04
7-
ARG MSTFLINT=mstflint
8-
# We have to ensure that pciutils is installed. This package is needed for mstfwreset to succeed.
11+
# We have to ensure that pciutils is installed. These packages are needed for mstfwreset to succeed.
912
# xref pkg/vendors/mellanox/mellanox.go#L150
10-
RUN apt update && apt -y install hwdata pciutils mstflint
13+
RUN apt update && apt -y install hwdata pciutils curl
14+
15+
ARG TARGETARCH
16+
ENV MFT_VERSION=4.33.0-169
17+
RUN case ${TARGETARCH} in \
18+
amd64) ARCH=x86_64 ;; \
19+
arm64) ARCH=arm64 ;; \
20+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
21+
esac && \
22+
curl -fsSL https://www.mellanox.com/downloads/MFT/mft-${MFT_VERSION}-${ARCH}-deb.tgz | tar -xz -C /tmp && \
23+
cd /tmp/mft-${MFT_VERSION}-${ARCH}-deb && \
24+
./install.sh --without-kernel
25+
26+
RUN ln -s $(which mlxconfig) /usr/bin/mstconfig
27+
RUN ln -s $(which mlxfwreset) /usr/bin/mstfwreset
28+
1129
LABEL io.k8s.display-name="sriov-network-config-daemon" \
1230
io.k8s.description="This is a daemon that manage and config sriov network devices in Kubernetes cluster"
1331
COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/build/_output/cmd/sriov-network-config-daemon /usr/bin/

Dockerfile.sriov-network-config-daemon.nvidia

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,33 @@
1717
ARG BASE_IMAGE_DOCA_BASE_RT_HOST
1818

1919
FROM golang:1.23 AS builder
20+
21+
ARG GOPROXY
22+
ENV GOPROXY=$GOPROXY
23+
2024
WORKDIR /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator
2125
COPY . .
2226
RUN make _build-sriov-network-config-daemon BIN_PATH=build/_output/cmd
2327

2428
FROM ${BASE_IMAGE_DOCA_BASE_RT_HOST:-nvcr.io/nvidia/doca/doca:3.1.0-base-rt-host}
25-
ARG MSTFLINT=mstflint
26-
# We have to ensure that pciutils is installed. This package is needed for mstfwreset to succeed.
29+
# We have to ensure that pciutils is installed. These packages are needed for mstfwreset to succeed.
2730
# xref pkg/vendors/mellanox/mellanox.go#L150
28-
RUN ARCH_DEP_PKGS=$(if [ "$(uname -m)" != "s390x" ]; then echo -n ${MSTFLINT} ; fi) && apt-get update && apt-get install -y hwdata pciutils $ARCH_DEP_PKGS && apt-get clean && rm -rf /var/lib/apt/lists/*
31+
RUN apt-get update && apt-get install -y hwdata pciutils curl && apt-get clean && rm -rf /var/lib/apt/lists/*
32+
33+
ARG TARGETARCH
34+
ENV MFT_VERSION=4.33.0-169
35+
RUN case ${TARGETARCH} in \
36+
amd64) ARCH=x86_64 ;; \
37+
arm64) ARCH=arm64 ;; \
38+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
39+
esac && \
40+
curl -fsSL https://www.mellanox.com/downloads/MFT/mft-${MFT_VERSION}-${ARCH}-deb.tgz | tar -xz -C /tmp && \
41+
cd /tmp/mft-${MFT_VERSION}-${ARCH}-deb && \
42+
./install.sh --without-kernel
43+
44+
RUN ln -s $(which mlxconfig) /usr/bin/mstconfig
45+
RUN ln -s $(which mlxfwreset) /usr/bin/mstfwreset
46+
2947
LABEL io.k8s.display-name="sriov-network-config-daemon" \
3048
io.k8s.description="This is a daemon that manage and config sriov network devices in Kubernetes cluster"
3149
COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/build/_output/cmd/sriov-network-config-daemon /usr/bin/

Dockerfile.webhook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.25 AS builder
1+
FROM golang:1.23 AS builder
22
WORKDIR /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator
33
COPY . .
44
RUN make _build-webhook BIN_PATH=build/_output/cmd

Dockerfile.webhook.nvidia

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@
1717
ARG BASE_IMAGE_GO_DISTROLESS_DEV
1818

1919
FROM golang:1.23 AS builder
20+
21+
ARG GOPROXY
22+
ENV GOPROXY=$GOPROXY
23+
2024
WORKDIR /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator
2125
COPY . .
2226
RUN make _build-webhook BIN_PATH=build/_output/cmd
2327

2428
FROM ${BASE_IMAGE_GO_DISTROLESS_DEV:-nvcr.io/nvidia/distroless/go:v3.2.1-dev}
29+
USER 65532:65532
2530
LABEL io.k8s.display-name="sriov-network-webhook" \
2631
io.k8s.description="This is an admission controller webhook that mutates and validates customer resources of sriov network operator."
27-
USER 1001
2832
# copy project sources into the container
2933
COPY . /src
3034
COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/build/_output/cmd/webhook /usr/bin/webhook

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export WATCH_NAMESPACE?=openshift-sriov-network-operator
3232
export HOME?=$(PWD)
3333
export GOPATH?=$(shell go env GOPATH)
3434
export GO111MODULE=on
35+
GOPROXY ?= $(shell go env GOPROXY)
3536
PKGS=$(shell go list ./... | grep -v -E '/vendor/|/test|/examples')
3637
TESTPKGS?=./...
3738

@@ -71,9 +72,9 @@ clean:
7172
@rm -rf $(BIN_DIR)
7273

7374
image: ; $(info Building images...)
74-
$(IMAGE_BUILDER) build -f $(DOCKERFILE) -t $(IMAGE_TAG) $(CURPATH) $(IMAGE_BUILD_OPTS)
75-
$(IMAGE_BUILDER) build -f $(DOCKERFILE_CONFIG_DAEMON) -t $(CONFIG_DAEMON_IMAGE_TAG) $(CURPATH) $(IMAGE_BUILD_OPTS)
76-
$(IMAGE_BUILDER) build -f $(DOCKERFILE_WEBHOOK) -t $(WEBHOOK_IMAGE_TAG) $(CURPATH) $(IMAGE_BUILD_OPTS)
75+
$(IMAGE_BUILDER) build -f $(DOCKERFILE) -t $(IMAGE_TAG) $(CURPATH) GOPROXY="$(GOPROXY)" $(IMAGE_BUILD_OPTS)
76+
$(IMAGE_BUILDER) build -f $(DOCKERFILE_CONFIG_DAEMON) -t $(CONFIG_DAEMON_IMAGE_TAG) $(CURPATH) GOPROXY="$(GOPROXY)" $(IMAGE_BUILD_OPTS)
77+
$(IMAGE_BUILDER) build -f $(DOCKERFILE_WEBHOOK) -t $(WEBHOOK_IMAGE_TAG) $(CURPATH) GOPROXY="$(GOPROXY)" $(IMAGE_BUILD_OPTS)
7778

7879
# Run tests
7980
test: generate lint manifests envtest

0 commit comments

Comments
 (0)