diff --git a/images/build/go-runner/Dockerfile b/images/build/go-runner/Dockerfile index 0ac4c3ed83d..b228e083d53 100644 --- a/images/build/go-runner/Dockerfile +++ b/images/build/go-runner/Dockerfile @@ -12,13 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Build the manager binary -ARG DISTROLESS_IMAGE +# Build args that need to be available for FROM statements +ARG GO_VERSION ARG BUILDER_IMAGE +ARG DISTROLESS_IMAGE + +# Get Go from official Alpine image +FROM golang:${GO_VERSION}-alpine as go-source + +# Build the manager binary FROM ${BUILDER_IMAGE} as builder WORKDIR /workspace +# Copy Go installation from official image +COPY --from=go-source /usr/local/go /usr/local/go + +# Set up Go environment +ENV PATH=/usr/local/go/bin:$PATH +ENV GOROOT=/usr/local/go + # Copy the sources +WORKDIR /workspace COPY ./go-runner.go ./ COPY ./go.* ./ @@ -38,11 +52,8 @@ ENV GOPROXY="https://proxy.golang.org|direct" # Build ARG package=. -ARG ARCH ENV CGO_ENABLED=0 -ENV GOOS=linux -ENV GOARCH=${ARCH} RUN go env diff --git a/images/build/go-runner/Makefile b/images/build/go-runner/Makefile index 69987a44bd2..33cb8b7ece6 100644 --- a/images/build/go-runner/Makefile +++ b/images/build/go-runner/Makefile @@ -20,12 +20,12 @@ APP_VERSION = $(shell cat VERSION) GO_MAJOR_VERSION ?= 1.24 REVISION ?= 0 GO_VERSION ?= 1.24.6 -OS_CODENAME ?= bookworm +OS_CODENAME ?= bookworm-slim # Build args DISTROLESS_REGISTRY ?= gcr.io/distroless DISTROLESS_IMAGE ?= static-debian12 -BUILDER_IMAGE ?= golang:$(GO_VERSION)-$(OS_CODENAME) +BUILDER_IMAGE ?= debian:$(OS_CODENAME) # Configuration CONFIG = go$(GO_MAJOR_VERSION)-$(OS_CODENAME) @@ -53,4 +53,5 @@ clean: rm go-runner BUILD_ARGS = --build-arg=BUILDER_IMAGE=$(BUILDER_IMAGE) \ - --build-arg=DISTROLESS_IMAGE=$(DISTROLESS_REGISTRY)/$(DISTROLESS_IMAGE) + --build-arg=DISTROLESS_IMAGE=$(DISTROLESS_REGISTRY)/$(DISTROLESS_IMAGE) \ + --build-arg=GO_VERSION=$(GO_VERSION) diff --git a/images/build/go-runner/cloudbuild.yaml b/images/build/go-runner/cloudbuild.yaml index aceb654a8ba..d96ab53fc78 100644 --- a/images/build/go-runner/cloudbuild.yaml +++ b/images/build/go-runner/cloudbuild.yaml @@ -1,13 +1,13 @@ # See https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md for more details on image pushing process # this must be specified in seconds. If omitted, defaults to 600s (10 mins) -timeout: 3600s +timeout: 28800s # this prevents errors if you don't use both _GIT_TAG and _PULL_BASE_REF, # or any new substitutions added in the future. options: substitutionOption: ALLOW_LOOSE - machineType: 'N1_HIGHCPU_8' + machineType: E2_HIGHCPU_32 steps: - name: 'ghcr.io/sigstore/cosign/cosign:v2.5.3-dev@sha256:fe84ab87222b60d2d87f5efcb8ef3cfd895897c088fbeb973280689c81aedff1'