Skip to content

Commit 0b0e806

Browse files
committed
Use a local development image and define golang version in a Dockerfile
Signed-off-by: Christopher Desiniotis <[email protected]>
1 parent bcfff6d commit 0b0e806

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

.github/workflows/golang.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Get Golang version
4646
id: vars
4747
run: |
48-
GOLANG_VERSION=$( grep "GOLANG_VERSION ?=" versions.mk )
48+
GOLANG_VERSION=$(./hack/golang-version.sh)
4949
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV
5050
- name: Install Go
5151
uses: actions/setup-go@v6

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,19 @@ CONTROLLER_GEN ?= controller-gen
103103
.generate-api:
104104
$(CONTROLLER_GEN) object object:headerFile="hack/boilerplate.go.txt" paths="./api/..."
105105

106-
$(DOCKER_TARGETS): docker-%:
106+
# Generate an image for containerized builds
107+
# Note: This image is local only
108+
.PHONY: .build-image
109+
.build-image: deployments/devel/Dockerfile
110+
if [ x"$(SKIP_IMAGE_BUILD)" = x"" ]; then \
111+
$(DOCKER) build \
112+
--progress=plain \
113+
--tag $(BUILDIMAGE) \
114+
-f $(^) \
115+
deployments/devel; \
116+
fi
117+
118+
$(DOCKER_TARGETS): docker-%: .build-image
107119
@echo "Running 'make $(*)' in container image $(BUILDIMAGE)"
108120
$(DOCKER) run \
109121
--rm \
@@ -117,7 +129,7 @@ $(DOCKER_TARGETS): docker-%:
117129

118130
# Start an interactive shell using the development image.
119131
PHONY: .shell
120-
.shell:
132+
.shell: .build-image
121133
$(DOCKER) run \
122134
--rm \
123135
-ti \

deployments/devel/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This Dockerfile is also used to define the golang version used in this project
16+
# This allows dependabot to manage this version in addition to other images.
17+
FROM golang:1.25.3

hack/golang-version.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# Copyright 2025 NVIDIA CORPORATION
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../hack && pwd )"
17+
18+
DOCKERFILE_ROOT=${SCRIPTS_DIR}/../deployments/devel
19+
20+
GOLANG_VERSION=$(grep -E "^FROM golang:.*$" ${DOCKERFILE_ROOT}/Dockerfile | grep -oE "[0-9\.]+")
21+
22+
echo $GOLANG_VERSION

versions.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ REGISTRY ?= nvcr.io/nvidia
2020

2121
vVERSION := v$(VERSION:v%=%)
2222

23-
GOLANG_VERSION ?= 1.25.3
23+
GOLANG_VERSION ?= $(shell ./hack/golang-version.sh)
2424

2525
BUILDIMAGE_TAG ?= devel-go$(GOLANG_VERSION)
26-
BUILDIMAGE ?= ghcr.io/nvidia/k8s-test-infra:$(BUILDIMAGE_TAG)
26+
BUILDIMAGE ?= $(NAME):$(BUILDIMAGE_TAG)
2727

2828
GIT_COMMIT ?= $(shell git describe --match="" --dirty --long --always --abbrev=40 2> /dev/null || echo "")

0 commit comments

Comments
 (0)