# Multi-stage Dockerfile for mkcert
FROM golang:bookworm AS builder
WORKDIR /src
# Cache dependencies
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Build with CGO disabled for a static binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o mkcert
FROM debian:bookworm-slim
# Install CA certificates for TLS trust
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Copy the pre-built binary from builder
COPY --from=builder /src/mkcert /usr/local/bin/mkcert
# Run as the binary by default
ENTRYPOINT ["mkcert"]