From c0c1f38e6e1b81ef525d8d72f63597c95b9117c0 Mon Sep 17 00:00:00 2001 From: kw1knode Date: Wed, 30 Oct 2024 09:32:33 -0700 Subject: [PATCH] add Dockerfile --- Dockerfile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..86b4259 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# Build stage +FROM golang:1.23-alpine AS builder + +WORKDIR /app + +# Install build dependencies +RUN apk add --no-cache git + +# Copy source code +COPY . . + +# Download dependencies +RUN go mod download + +# Build the application +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . + +# Final stage +FROM alpine:latest + +WORKDIR /root/ + +# Install runtime dependencies +RUN apk --no-cache add ca-certificates + +# Copy the binary from builder +COPY --from=builder /app/main . + +# Expose port (adjust as needed) +EXPOSE 8080 + +# Run the binary +CMD ["./main"] \ No newline at end of file