# Build mkcert from source using Go
FROM golang:tip-alpine3.23
# Install CA certificates to allow TLS during builds and runtime
RUN apk add --no-cache ca-certificates
# Build a static Go binary to be Alpine-friendly
ENV CGO_ENABLED=0
WORKDIR /src
# Cache module downloads
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source
COPY . .
# Build the project and install the binary into /usr/local/bin
RUN go build -o /usr/local/bin/mkcert ./...
# Run mkcert by default (overridable by docker run --entrypoint)
ENTRYPOINT ["/usr/local/bin/mkcert"]