feat: add dockerfile
This commit is contained in:
29
Dockerfile
Normal file
29
Dockerfile
Normal 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"]
|
||||
Reference in New Issue
Block a user