diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e386c13 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# Use Go 1.25.6 or newer +FROM golang:1.25.6-alpine AS builder + +# Enable Go modules +ENV GO111MODULE=on + +# Set working directory +WORKDIR /app + +# Install git (for go get) and build tools +RUN apk add --no-cache git + +# Copy go.mod and go.sum first for better cache +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the rest of the source code +COPY . . + +# Build the Go app +RUN go build -o app . + +# Stage 2: Create a minimal runtime image +FROM alpine:latest + +# Set working directory +WORKDIR /root/ + +# Copy binary and .env file from builder +COPY --from=builder /app/app . +COPY .env . + +# Expose the port (optional, for documentation) +EXPOSE 8080 + +# Run the binary +CMD ["./app"]