Files
yadunut.dev/Dockerfile
2024-11-19 18:05:52 -05:00

30 lines
504 B
Docker

FROM golang:1.23-alpine as builder
# Set the working directory
WORKDIR /app
# Copy and download dependencies
COPY go.mod ./
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"]