From acede833c854821a2000968d90f70824f5eb0047 Mon Sep 17 00:00:00 2001 From: Trong Huu Nguyen Date: Tue, 28 Nov 2023 16:11:12 +0100 Subject: [PATCH] build: use defacto image, build module for buildinfo Building specific file doesn't appear to embed buildinfo into the static binary for some reason. --- Dockerfile | 7 ++++--- Makefile | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b5d14a1..d696065 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM --platform=$BUILDPLATFORM golang:1.21-alpine as builder +FROM --platform=$BUILDPLATFORM golang:1.21 as builder +ENV CGO_ENABLED=0 WORKDIR /src COPY go.mod go.sum ./ @@ -7,9 +8,9 @@ RUN go mod download COPY . . ARG TARGETOS ARG TARGETARCH -RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath -ldflags "-s -w" -a -o bin/wonderwall cmd/wonderwall/main.go +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make wonderwall -FROM gcr.io/distroless/static-debian11:nonroot +FROM gcr.io/distroless/static-debian12:nonroot WORKDIR /app COPY --from=builder /src/bin/wonderwall /app/wonderwall ENTRYPOINT ["/app/wonderwall"] diff --git a/Makefile b/Makefile index 1d38705..b678ae7 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ wonderwall: - go build -trimpath -ldflags "-s -w" -a -o bin/wonderwall cmd/wonderwall/main.go + go build -trimpath -ldflags "-s -w" -a -o bin/wonderwall ./cmd/wonderwall run: fmt go run cmd/wonderwall/main.go