File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed
Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change 11# syntax=docker/dockerfile:1
22
3+ FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.6.1 AS xx
4+
35FROM --platform=$BUILDPLATFORM golang:1.24.0-alpine AS build
46WORKDIR /app
57
8+ COPY --from=xx / /
9+
610COPY go.mod go.sum ./
711RUN go mod download
812
913COPY . .
1014
11- # Set Golang build envs based on Docker platform string
1215ARG TARGETPLATFORM
13- RUN --mount=type=cache,target=/root/.cache <<EOT
14- set -eux
15- case "$TARGETPLATFORM" in
16- 'linux/amd64' ) export GOARCH=amd64 ;;
17- 'linux/arm/v6' ) export GOARCH=arm GOARM=6 ;;
18- 'linux/arm/v7' ) export GOARCH=arm GOARM=7 ;;
19- 'linux/arm64' ) export GOARCH=arm64 ;;
20- *) echo "Unsupported target: $TARGETPLATFORM" && exit 1 ;;
21- esac
22- go build -ldflags='-w -s' -trimpath
23- EOT
16+ RUN --mount=type=cache,target=/root/.cache \
17+ CGO_ENABLED=0 xx-go build -ldflags='-w -s' -trimpath
2418
2519
2620FROM gcr.io/distroless/static:nonroot
You can’t perform that action at this time.
0 commit comments