Skip to content

Commit 737b390

Browse files
authored
Merge pull request #1362 from elezar/futher-cleanup-of-distroless
Futher cleanup of distroless
2 parents c87ad40 + 2cbaaf9 commit 737b390

File tree

6 files changed

+21
-65
lines changed

6 files changed

+21
-65
lines changed

deployments/container/Dockerfile

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
ARG GOLANG_VERSION=1.22.6
16-
FROM nvcr.io/nvidia/cuda:12.9.1-base-ubi9 AS build
17-
18-
RUN yum install -y \
19-
wget make git gcc \
20-
&& \
21-
rm -rf /var/cache/yum/*
22-
23-
ARG GOLANG_VERSION=x.x.x
24-
RUN set -eux; \
25-
\
26-
arch="$(uname -m)"; \
27-
case "${arch##*-}" in \
28-
x86_64 | amd64) ARCH='amd64' ;; \
29-
ppc64el | ppc64le) ARCH='ppc64le' ;; \
30-
aarch64) ARCH='arm64' ;; \
31-
*) echo "unsupported architecture" ; exit 1 ;; \
32-
esac; \
33-
wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${ARCH}.tar.gz \
34-
| tar -C /usr/local -xz
35-
36-
ENV GOPATH=/go
37-
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
15+
FROM golang:1.24.6 AS base
16+
17+
# The devel image is used for local development.
18+
FROM base AS devel
19+
20+
WORKDIR /work
21+
COPY * .
22+
23+
RUN make install-tools
24+
25+
# We need to set the /work directory as a safe directory.
26+
# This allows git commands to run in the container.
27+
RUN git config --file=/.gitconfig --add safe.directory /work
28+
29+
# The build image is used to build the device plugin applications.
30+
FROM base AS build
3831

3932
WORKDIR /build
4033
COPY . .
@@ -44,13 +37,7 @@ ARG VERSION="N/A"
4437
ARG GIT_COMMIT="unknown"
4538
RUN make PREFIX=/artifacts cmds
4639

47-
# We use the ubi9-minimal image as a reference image in removing unneeded dependencies.
48-
FROM redhat/ubi9-minimal:latest AS minimal
49-
50-
RUN rpm -qa --queryformat='^%{NAME}-\[0-9\].*\.%{ARCH}$\n' | sort -u > /tmp/package-names.minimal
51-
RUN rpm -qa | sort -u > /tmp/package-list.minimal
52-
53-
FROM nvcr.io/nvidia/distroless/go:v3.1.11-dev
40+
FROM nvcr.io/nvidia/distroless/go:v3.1.11-dev AS application
5441

5542
USER 0:0
5643
SHELL ["/busybox/sh", "-c"]

deployments/container/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ $(IMAGE_TARGETS): image-%:
7676
$(DOCKER_BUILD_OPTIONS) \
7777
$(DOCKER_BUILD_PLATFORM_OPTIONS) \
7878
--tag $(IMAGE) \
79-
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
8079
--build-arg VERSION="$(VERSION)" \
8180
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
8281
$(if $(LABEL_IMAGE_SOURCE),--label "org.opencontainers.image.source=$(LABEL_IMAGE_SOURCE)",) \

deployments/devel/Dockerfile

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

deployments/devel/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ install-tools: download
2424
DOCKER ?= docker
2525
-include $(CURDIR)/versions.mk
2626

27-
DOCKERFILE_DEVEL = deployments/devel/Dockerfile
27+
DOCKERFILE_DEVEL = deployments/container/Dockerfile
2828
DOCKERFILE_CONTEXT = deployments/devel
2929

3030
.PHONY: .build-image
3131
.build-image:
3232
$(DOCKER) build \
3333
--progress=plain \
34-
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \
3534
--tag $(BUILDIMAGE) \
35+
--target=devel \
3636
-f $(DOCKERFILE_DEVEL) \
3737
$(DOCKERFILE_CONTEXT)
3838

hack/golang-version.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1717

18-
DOCKERFILE_ROOT=${SCRIPTS_DIR}/../deployments/devel
18+
DOCKERFILE_ROOT=${SCRIPTS_DIR}/../deployments/container
1919

20-
GOLANG_VERSION=$(grep -E "^FROM golang:.*$" ${DOCKERFILE_ROOT}/Dockerfile | grep -oE "[0-9\.]+")
20+
GOLANG_VERSION=$(grep -E "^FROM golang:.* AS base$" ${DOCKERFILE_ROOT}/Dockerfile | grep -oE "[0-9\.]+")
2121

2222
echo $GOLANG_VERSION

versions.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ REGISTRY ?= nvcr.io/nvidia
1919

2020
VERSION ?= v0.17.1
2121

22-
# vVERSION represents the version with a guaranteed v-prefix
23-
vVERSION := v$(VERSION:v%=%)
24-
2522
GOLANG_VERSION := $(shell ./hack/golang-version.sh)
2623

2724
BUILDIMAGE_TAG ?= devel-go$(GOLANG_VERSION)

0 commit comments

Comments
 (0)