From c2c48f5f9cf0ae0f73db8d1bc4d5e7e59ce3c12d Mon Sep 17 00:00:00 2001 From: valitovgaziz Date: Thu, 25 Sep 2025 03:13:42 +0500 Subject: [PATCH] modified: Dockerfile new file: go.sum add go.sum file in hadle mod --- serv_golang_rest_api/Dockerfile | 27 +++++++++------------------ serv_golang_rest_api/go.sum | 0 2 files changed, 9 insertions(+), 18 deletions(-) create mode 100644 serv_golang_rest_api/go.sum diff --git a/serv_golang_rest_api/Dockerfile b/serv_golang_rest_api/Dockerfile index 9ed3334..d00532f 100644 --- a/serv_golang_rest_api/Dockerfile +++ b/serv_golang_rest_api/Dockerfile @@ -1,23 +1,14 @@ -# Use official Go image with specific version -FROM golang:1.25.1 - -# Set working directory +# Build stage +FROM golang:1.25.1 as builder WORKDIR /app - -# Copy Go module files first COPY go.mod go.sum ./ - -# Download dependencies RUN go mod download - -# Copy source code COPY *.go ./ +RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/app -# Build the binary -RUN CGO_ENABLED=0 GOOS=linux go build -o main . - -# Expose port -EXPOSE 8080 - -# Run the application -CMD ["./main"] \ No newline at end of file +# Final stage +FROM gcr.io/distroless/static-debian12 +WORKDIR / +COPY --from=builder /go/bin/app /app +CMD ["/app"] +EXPOSE 8080 \ No newline at end of file diff --git a/serv_golang_rest_api/go.sum b/serv_golang_rest_api/go.sum new file mode 100644 index 0000000..e69de29