From 61c5a7053433646e2b4f60c59a3d16c13f2eac74 Mon Sep 17 00:00:00 2001 From: valitovgaziz Date: Thu, 25 Sep 2025 03:10:50 +0500 Subject: [PATCH] modified: Dockerfile change docker file, simplifiy it --- serv_golang_rest_api/Dockerfile | 35 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/serv_golang_rest_api/Dockerfile b/serv_golang_rest_api/Dockerfile index d00532f..9ed3334 100644 --- a/serv_golang_rest_api/Dockerfile +++ b/serv_golang_rest_api/Dockerfile @@ -1,14 +1,23 @@ -# Build stage -FROM golang:1.25.1 as builder -WORKDIR /app -COPY go.mod go.sum ./ -RUN go mod download -COPY *.go ./ -RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/app +# Use official Go image with specific version +FROM golang:1.25.1 -# 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 +# Set working directory +WORKDIR /app + +# Copy Go module files first +COPY go.mod go.sum ./ + +# Download dependencies +RUN go mod download + +# Copy source code +COPY *.go ./ + +# 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