File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- FROM golang:1.24.2 AS builder
1+ # syntax=docker/dockerfile:1.4
2+ FROM --platform=$BUILDPLATFORM golang:1.24.2 AS builder
3+
4+ ARG BUILDPLATFORM
5+ ARG TARGETPLATFORM
6+ ARG TARGETARCH
7+ ARG TARGETOS=linux
28
39WORKDIR /workspace
10+
411# Copy the Go Modules manifests
5- COPY go.mod go.mod
6- COPY go.sum go.sum
12+ COPY go.mod go.sum ./
713
814# Copy the go source
915COPY main.go main.go
1016COPY plugin/ plugin/
1117COPY vendor/ vendor/
1218
13- ARG TARGETPLATFORM
14- ARG TARGETARCH
15- ARG TARGETOS
16-
17- # Build
18- RUN go env -w GOPRIVATE=github.org/kubeslice && \
19- CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on go build -mod=vendor -a -o coredns main.go
19+ # Build with cross-compilation
20+ RUN --mount=type=cache,target=/root/.cache/go-build \
21+ --mount=type=cache,target=/go/pkg \
22+ CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on \
23+ go build -mod=vendor -ldflags="-w -s" -trimpath -o coredns main.go
2024
2125FROM gcr.io/distroless/static:nonroot
2226
You can’t perform that action at this time.
0 commit comments