# 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 WORKDIR /src # Cache module downloads COPY go.mod go.sum ./ RUN go mod download # Copy the rest of the source COPY . . # Build the project RUN go build -o mkcert ./... # Run mkcert by default ENTRYPOINT ["./mkcert"]
# Ignore VCS and common dev artifacts .git .gitignore .DS_Store node_modules/ vendor/ # Go build cache and modules vendor/ -*/.cache/ # Ignore temporary and build artifacts *.log *.tmp *.bak *.swp # Certificates and keys (not needed in build context) **/*.pem **/*.crt **/*.key **/*.p12 **/*.p7s # Other common ignores _dist/ build/ dist/ Out/ out/
Concerns: FROM uses a moving tag golang:tip-alpine3.23 which can cause reproducibility issues., No explicit tests in the Dockerfile; consider pinning the Go version or adding a dedicated build/test step. Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "set -e; cd /src; ./mkcert localhost; [ -f localhost.pem ] && [ -f localhost-key.pem ] && echo OK Output: sh: syntax error: unterminated quoted string Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "set -e; cd /src; ./mkcert example.test; [ -f example.test.pem ] && [ -f example.test-key.pem ] && echo OK Output: sh: syntax error: unterminated quoted string
# Build mkcert from source using Go FROM golang:1.18-alpine3.23 # Install CA certificates to allow TLS during builds and runtime RUN apk add --no-cache ca-certificates WORKDIR /src # Cache module downloads COPY go.mod go.sum ./ RUN go mod download # Copy the rest of the source COPY . . # Build the project RUN go build -o mkcert ./... # Run mkcert by default ENTRYPOINT ["./mkcert"]
# 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 RUN go build -o mkcert ./... # Run mkcert by default (overridable by docker run --entrypoint) ENTRYPOINT ["/src/mkcert"]
Smoke [FAIL]: set -e; mkdir -p /src/work /src/ca; cd /src/work; mkcert -CAROOT /src/ca localhost 127.0.0.1; if [ -f /src/ca/rootCA.pem ] && ( [ -f localhost.pem ] || [ -f localhost+127.0.0.1.pem ] ); then echo PASS; else echo FAIL; exit 1; fi Output: sh: mkcert: not found
# Build mkcert from source using Go FROM golang:1.18-alpine3.18 # 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 ["mkcert"]
# 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"]
Concerns: The FROM uses golang:tip-alpine3.23 (tip tag) which can yield non-deterministic builds; pin to a specific Go image version for reproducibility., No HEALTHCHECK or built-in tests in the Dockerfile (not required for approval, but adding smoke tests or a test script would be beneficial). Smoke [PASS]: cd /tmp; /usr/local/bin/mkcert -CAROOT /tmp/mkc test.local; if [ -f /tmp/mkc/rootCA.pem ] && [ -f /tmp/test.local.pem ] && [ -f /tmp/test.local-key.pem ]; then echo OK; else echo FAIL; fi Smoke [PASS]: cd /tmp; /usr/local/bin/mkcert -CAROOT /tmp/mkc another.local; grep -q 'BEGIN CERTIFICATE' /tmp/another.local.pem && echo PEM_OK || echo PEM_FAIL