Files
yadunut.dev/Dockerfile
2024-11-22 15:02:29 -05:00

30 lines
511 B
Docker

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