feat: add dockerfile

This commit is contained in:
2024-11-19 16:37:45 -05:00
parent 8e345ffa44
commit e0bd4fdead

29
Dockerfile Normal file
View File

@@ -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"]