From b9425c3eaf7686c72dba7eab9f1a2ffe968b1abb Mon Sep 17 00:00:00 2001 From: Achsan Date: Tue, 10 Sep 2024 03:51:27 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20fix:=20update=20builder=20step?= =?UTF-8?q?=20in=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go/gin/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/go/gin/Dockerfile b/go/gin/Dockerfile index 66a2d7e..c6269e4 100644 --- a/go/gin/Dockerfile +++ b/go/gin/Dockerfile @@ -1,7 +1,10 @@ FROM golang:1.22 as build WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download COPY . . -RUN go build -o /server . +ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 +RUN go build -ldflags="-s -w" -o /server . FROM scratch COPY --from=build /server /server