2121###############################################################################
2222# Create the develop, test, and build environment
2323###############################################################################
24+ ARG GOLANG_VERSION=1.21
25+ FROM registry.access.redhat.com/ubi8/go-toolset:$GOLANG_VERSION
2426
25- # TODO: replace the "go_toolset" build stage once ubi8/go-toolset:1.21 is available
26- # the go-toolset 1.21 is based on ubi9, we need to update it in the base image as well.
27- FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as go-toolset
28-
29- # https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
30- # We need TARGETOS and TARGETARCH (not BUILDOS and BUILDARCH) since the developer
31- # image should be built for the OS of the developer using it (this is not a "builder image")
32- ARG TARGETOS
33- ARG TARGETARCH
34-
35- ARG GOLANG_VERSION=1.21.6
36-
37- USER root
38-
39- ENV HOME=/root \
40- PATH=/usr/local/go/bin:$PATH:
41-
42- WORKDIR /workspace
43-
44- # install necessary tools that are included in the ubi/go-toolset image that we are temporarily replacing
45- RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
46- microdnf --setopt=cachedir=/root/.cache/microdnf --nodocs install \
47- diffutils \
48- gcc-c++ \
49- make \
50- wget \
51- tar \
52- git \
53- which \
54- && microdnf update --nodocs \
55- && true
56-
57- # install go
58- RUN true \
59- && wget -qO go.tgz "https://golang.org/dl/go${GOLANG_VERSION}.${TARGETOS:-linux}-${TARGETARCH:-amd64}.tar.gz" \
60- && tar -C /usr/local -xzf go.tgz \
61- && go version \
62- && rm go.tgz \
63- && true
64-
65-
66- ####################################################################################
67- # TODO: replace "go-toolset" build stage with ubi/go-toolset:1.21 once available #
68- # and swap `microdnf` commands for `dnf` #
69- ####################################################################################
70- FROM go-toolset
7127
7228# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
7329# don't provide "default" values (e.g. 'ARG TARGETARCH=amd64') for non-buildx environments,
@@ -90,7 +46,7 @@ WORKDIR /workspace
9046# Install build and dev tools
9147# NOTE: Require python38 to install pre-commit
9248RUN --mount=type=cache,target=/root/.cache/dnf:rw \
93- microdnf install --setopt=cachedir=/root/.cache/dnf -y --nodocs \
49+ dnf install --setopt=cachedir=/root/.cache/dnf -y --nodocs \
9450 nodejs \
9551 jq \
9652 python38 \
@@ -160,8 +116,9 @@ RUN true \
160116 && true
161117
162118# Use setup-envtest for kubebuilder to use K8s version 1.23+ for autoscaling/v2 (HPA)
119+ # Pin envtest to specific version until update to go 1.22
163120RUN true \
164- && go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest \
121+ && go install sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20240320141353-395cfc7486e6 \
165122 && setup-envtest use 1.26 \
166123 && true
167124
0 commit comments