From e0bd4fdeadf1891f6dc7376a04f62b55078d3995 Mon Sep 17 00:00:00 2001 From: Yadunand Prem Date: Tue, 19 Nov 2024 16:37:45 -0500 Subject: [PATCH] feat: add dockerfile --- Dockerfile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..830daf5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM golang:1.23-alpine as builder + +# Set the working directory +WORKDIR /app + +# Copy and download dependencies +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the source code +COPY . . + +# Build the Go application +RUN go build -o server . + +# Create a minimal runtime image +FROM alpine:latest + +# Set the working directory +WORKDIR /root/ + +# Copy the compiled binary from the builder +COPY --from=builder /app/server . + +# Expose the application port (e.g., 8080) +EXPOSE 8080 + +# Run the application +CMD ["./server"]