Skip to content

Commit 2586f7e

Browse files
cpanatodims
authored andcommitted
golang: Build 1.25.0 images
Co-Authored-by: Carlos Panato <[email protected]> [WIP] Copy golang binaries using alpine image
1 parent 9621a4d commit 2586f7e

File tree

11 files changed

+70
-21
lines changed

11 files changed

+70
-21
lines changed

dependencies.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ dependencies:
144144
- path: images/build/go-runner/VERSION
145145

146146
- name: "registry.k8s.io/build-image/go-runner (go1.25-bookworm)"
147-
version: v2.4.0-go1.25rc2-bookworm.0
147+
version: v2.4.0-go1.25.1-bookworm.0
148148
refPaths:
149149
- path: images/build/go-runner/variants.yaml
150150
match: v((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)
@@ -195,7 +195,7 @@ dependencies:
195195
match: "CONFIG: 'go\\d+.\\d+-bullseye'"
196196

197197
- name: "registry.k8s.io/build-image/kube-cross (v1.34-go1.25)"
198-
version: v1.34.0-go1.25rc2-bullseye.0
198+
version: v1.34.0-go1.25.1-bullseye.0
199199
refPaths:
200200
- path: images/build/cross/variants.yaml
201201
match: "IMAGE_VERSION: 'v((([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)'"

images/build/cross/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ REVISION ?= 0
3535
TYPE ?= default
3636

3737
# Build args
38-
BASEIMAGE ?= golang:$(GO_VERSION)-$(OS_CODENAME)
38+
BASEIMAGE ?= debian:$(OS_CODENAME)-slim
3939
PROTOBUF_VERSION ?= 3.19.4
4040

4141
IMAGE = $(REGISTRY)/$(IMGNAME)
@@ -83,6 +83,8 @@ container: check-env init-docker-buildx
8383
--tag $(IMAGE)-$${platform##*/}:latest-$(CONFIG)-$(TYPE) \
8484
--build-arg=BASEIMAGE=$(BASEIMAGE) \
8585
--build-arg=PROTOBUF_VERSION=$(PROTOBUF_VERSION) \
86+
--build-arg=TARGETPLATFORM=$${platform} \
87+
--build-arg=GO_VERSION=$(GO_VERSION) \
8688
--file $(TYPE)/Dockerfile \
8789
.; \
8890
done

images/build/cross/default/Dockerfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# platform go binary for the architecture kubernetes cares about.
1717

1818
ARG BASEIMAGE
19+
ARG GO_VERSION
20+
FROM golang:${GO_VERSION}-alpine as go-source
1921
FROM ${BASEIMAGE}
2022

2123
##------------------------------------------------------------
@@ -40,7 +42,9 @@ ENV KUBE_CROSSPLATFORMS \
4042
windows/amd64 windows/386
4143

4244
##------------------------------------------------------------
43-
45+
COPY --from=go-source /usr/local/go /usr/local/go
46+
ENV PATH=/usr/local/go/bin:$PATH
47+
ENV GOROOT=/usr/local/go
4448
# Pre-compile the standard go library when cross-compiling. This is much easier now when we have go1.5+
4549
RUN targetArch=$(echo $TARGETPLATFORM | cut -f2 -d '/') \
4650
&& if [ ${targetArch} = "amd64" ]; then \
@@ -52,12 +56,17 @@ fi
5256
RUN apt-get -q update \
5357
&& apt-get install -qqy \
5458
apt-utils \
59+
curl \
5560
file \
61+
git \
62+
gnupg2 \
63+
iproute2 \
5664
jq \
65+
openssh-client \
5766
patch \
5867
rsync \
5968
unzip \
60-
iproute2
69+
wget
6170

6271
# Use dynamic cgo linking for architectures other than amd64 for the server platforms
6372
# To install crossbuild essential for other architectures add the following repository.

images/build/cross/variants.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ variants:
22
v1.34-go1.25-bullseye:
33
CONFIG: 'go1.25-bullseye'
44
TYPE: 'default'
5-
IMAGE_VERSION: 'v1.34.0-go1.25rc2-bullseye.0'
5+
IMAGE_VERSION: 'v1.34.0-go1.25.1-bullseye.0'
66
KUBERNETES_VERSION: 'v1.34.0'
7-
GO_VERSION: '1.25rc2'
7+
GO_VERSION: '1.25.1'
88
GO_MAJOR_VERSION: '1.25'
99
OS_CODENAME: 'bullseye'
1010
REVISION: '0'

images/build/go-runner/Dockerfile

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

15-
# Build the manager binary
15+
ARG GO_VERSION
1616
ARG DISTROLESS_IMAGE
1717
ARG BUILDER_IMAGE
18+
19+
# Get Go from official Alpine image
20+
FROM golang:${GO_VERSION}-alpine as go-source
21+
22+
# Build the manager binary
1823
FROM ${BUILDER_IMAGE} as builder
1924
WORKDIR /workspace
2025

26+
# Copy Go installation from official image
27+
COPY --from=go-source /usr/local/go /usr/local/go
28+
29+
# Set up Go environment
30+
ENV PATH=/usr/local/go/bin:$PATH
31+
ENV GOROOT=/usr/local/go
32+
2133
# Copy the sources
2234
COPY ./go-runner.go ./
2335
COPY ./go.* ./
@@ -38,11 +50,8 @@ ENV GOPROXY="https://proxy.golang.org|direct"
3850

3951
# Build
4052
ARG package=.
41-
ARG ARCH
4253

4354
ENV CGO_ENABLED=0
44-
ENV GOOS=linux
45-
ENV GOARCH=${ARCH}
4655

4756
RUN go env
4857

images/build/go-runner/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ APP_VERSION = $(shell cat VERSION)
2020
GO_MAJOR_VERSION ?= 1.24
2121
REVISION ?= 0
2222
GO_VERSION ?= 1.24.6
23-
OS_CODENAME ?= bookworm
23+
OS_CODENAME ?= bookworm-slim
2424

2525
# Build args
2626
DISTROLESS_REGISTRY ?= gcr.io/distroless
2727
DISTROLESS_IMAGE ?= static-debian12
28-
BUILDER_IMAGE ?= golang:$(GO_VERSION)-$(OS_CODENAME)
28+
BUILDER_IMAGE ?= debian:$(OS_CODENAME)
2929

3030
# Configuration
3131
CONFIG = go$(GO_MAJOR_VERSION)-$(OS_CODENAME)
@@ -53,4 +53,5 @@ clean:
5353
rm go-runner
5454

5555
BUILD_ARGS = --build-arg=BUILDER_IMAGE=$(BUILDER_IMAGE) \
56-
--build-arg=DISTROLESS_IMAGE=$(DISTROLESS_REGISTRY)/$(DISTROLESS_IMAGE)
56+
--build-arg=DISTROLESS_IMAGE=$(DISTROLESS_REGISTRY)/$(DISTROLESS_IMAGE) \
57+
--build-arg=GO_VERSION=$(GO_VERSION)

images/build/go-runner/variants.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
variants:
22
go1.25-bookworm:
33
CONFIG: 'go1.25-bookworm'
4-
IMAGE_VERSION: 'v2.4.0-go1.25rc2-bookworm.0'
4+
IMAGE_VERSION: 'v2.4.0-go1.25.1-bookworm.0'
55
GO_MAJOR_VERSION: '1.25'
66
OS_CODENAME: 'bookworm'
77
REVISION: '0'
8-
GO_VERSION: '1.25rc2'
8+
GO_VERSION: '1.25.1'
99
DISTROLESS_IMAGE: 'static-debian12'
1010
go1.24-bookworm:
1111
CONFIG: 'go1.24-bookworm'

images/releng/ci/Dockerfile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,22 @@
1414

1515
ARG GO_VERSION
1616
ARG OS_CODENAME
17-
FROM golang:${GO_VERSION}-${OS_CODENAME} as builder
17+
18+
# Get Go from official Alpine image
19+
FROM golang:${GO_VERSION}-alpine as go-source
20+
21+
FROM debian:${OS_CODENAME}-slim
22+
23+
# Copy Go installation from official image
24+
COPY --from=go-source /usr/local/go /usr/local/go
25+
26+
# Set up Go environment
27+
ENV PATH=/usr/local/go/bin:$PATH
28+
ENV GOROOT=/usr/local/go
29+
30+
# Install required packages for adding Google Cloud SDK repository
31+
RUN apt-get update && \
32+
apt-get install -y curl gnupg
1833

1934
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | \
2035
tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
@@ -26,9 +41,11 @@ RUN apt-get update && \
2641
apt-get install -y \
2742
bsdmainutils \
2843
build-essential \
44+
git \
2945
google-cloud-sdk \
3046
jq \
3147
rpmlint \
48+
wget \
3249
&& rm -rf /var/lib/apt/lists/*
3350

3451
# install goreleaser

images/releng/ci/variants.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
variants:
22
go1.25-bookworm:
33
CONFIG: 'go1.25-bookworm'
4-
GO_VERSION: '1.25rc2'
4+
GO_VERSION: '1.25.1'
55
OS_CODENAME: 'bookworm'
66
REVISION: '0'
77
go1.24-bookworm:

images/releng/k8s-ci-builder/Dockerfile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ ARG OS_CODENAME
1717

1818
# The Release Tooling can be compiled with a different version of Go than the
1919
# the Go version used in the kubernetes/kubernetes active development branch.
20-
FROM golang:${GO_VERSION_TOOLING}-${OS_CODENAME} AS builder
20+
FROM golang:${GO_VERSION_TOOLING}-alpine as go-source
21+
FROM debian:${OS_CODENAME}-slim AS builder
22+
23+
# Install CA certificates for TLS verification
24+
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
25+
26+
# Copy Go installation from official image
27+
COPY --from=go-source /usr/local/go /go
28+
29+
# Set up Go environment
30+
ENV PATH=/go/bin:$PATH
31+
ENV GOROOT=/go
2132

2233
WORKDIR /go/src/k8s.io/release
2334

0 commit comments

Comments
 (0)