modified: Dockerfile

change docker file, simplifiy it
This commit is contained in:
2025-09-25 03:10:50 +05:00
parent 05ef0009bd
commit 61c5a70534
+21 -12
View File
@@ -1,14 +1,23 @@
# Build stage # Use official Go image with specific version
FROM golang:1.25.1 as builder FROM golang:1.25.1
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
# Final stage # Set working directory
FROM gcr.io/distroless/static-debian12 WORKDIR /app
WORKDIR /
COPY --from=builder /go/bin/app /app # Copy Go module files first
CMD ["/app"] 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 EXPOSE 8080
# Run the application
CMD ["./main"]