build: use defacto image, build module for buildinfo

Building specific file doesn't appear to embed buildinfo into the static
binary for some reason.
This commit is contained in:
Trong Huu Nguyen
2023-11-28 16:15:51 +01:00
parent 70a45e1522
commit acede833c8
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -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"]
+1 -1
View File
@@ -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