File tree Expand file tree Collapse file tree 2 files changed +41
-6
lines changed Expand file tree Collapse file tree 2 files changed +41
-6
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,44 @@ ARG BUILDER_IMAGE
18
18
FROM ${BUILDER_IMAGE} as builder
19
19
WORKDIR /workspace
20
20
21
+ # Install dependencies for building Go from source
22
+ RUN apt-get update && apt-get install -y \
23
+ build-essential \
24
+ curl \
25
+ git \
26
+ ca-certificates \
27
+ && rm -rf /var/lib/apt/lists/*
28
+
29
+ # Download and build Go from source
30
+ ARG GO_VERSION
31
+
32
+ # Download and install bootstrap Go (binary)
33
+ ARG BOOTSTRAP_GO_VERSION=1.24.7
34
+ ARG TARGETARCH
35
+ RUN echo "Installing bootstrap Go version: ${BOOTSTRAP_GO_VERSION} (${TARGETARCH})" && \
36
+ curl -fsSL "https://go.dev/dl/go${BOOTSTRAP_GO_VERSION}.linux-${TARGETARCH}.tar.gz" -o /tmp/go-bootstrap.tar.gz && \
37
+ tar -xzf /tmp/go-bootstrap.tar.gz -C /usr/local && \
38
+ mv /usr/local/go /usr/local/go-bootstrap && \
39
+ rm /tmp/go-bootstrap.tar.gz
40
+
41
+ # Download Go source
42
+ RUN echo "Downloading Go source version: ${GO_VERSION}" && \
43
+ curl -fsSL "https://go.dev/dl/go${GO_VERSION}.src.tar.gz" -o /tmp/go.src.tar.gz && \
44
+ tar -xzf /tmp/go.src.tar.gz -C /usr/local && \
45
+ rm /tmp/go.src.tar.gz
46
+
47
+ # Build Go from source with bootstrap
48
+ WORKDIR /usr/local/go/src
49
+ ENV GOROOT_BOOTSTRAP=/usr/local/go-bootstrap
50
+ RUN ./make.bash
51
+
52
+ # Set up Go environment
53
+ ENV PATH=/usr/local/go/bin:$PATH
54
+ ENV GOROOT=/usr/local/go
55
+ ENV GOPATH=/workspace/gopath
56
+
21
57
# Copy the sources
58
+ WORKDIR /workspace
22
59
COPY ./go-runner.go ./
23
60
COPY ./go.* ./
24
61
@@ -38,11 +75,8 @@ ENV GOPROXY="https://proxy.golang.org|direct"
38
75
39
76
# Build
40
77
ARG package=.
41
- ARG ARCH
42
78
43
79
ENV CGO_ENABLED=0
44
- ENV GOOS=linux
45
- ENV GOARCH=${ARCH}
46
80
47
81
RUN go env
48
82
Original file line number Diff line number Diff line change @@ -20,12 +20,12 @@ APP_VERSION = $(shell cat VERSION)
20
20
GO_MAJOR_VERSION ?= 1.24
21
21
REVISION ?= 0
22
22
GO_VERSION ?= 1.24.6
23
- OS_CODENAME ?= bookworm
23
+ OS_CODENAME ?= bookworm-slim
24
24
25
25
# Build args
26
26
DISTROLESS_REGISTRY ?= gcr.io/distroless
27
27
DISTROLESS_IMAGE ?= static-debian12
28
- BUILDER_IMAGE ?= golang: $( GO_VERSION ) - $(OS_CODENAME )
28
+ BUILDER_IMAGE ?= debian: $(OS_CODENAME )
29
29
30
30
# Configuration
31
31
CONFIG = go$(GO_MAJOR_VERSION ) -$(OS_CODENAME )
53
53
rm go-runner
54
54
55
55
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 )
You can’t perform that action at this time.
0 commit comments