filosottile-mkcert
SUCCESS
3m 33s
History Source
SummaryIterations1Transcript5Dockerfile
01Iteration 1
WRITEWriteFile· step #1
0s
Dockerfile743 bytes written
text26 lines · 743 chars
# Build stage: compile mkcert for Linux (amd64) using a Go 1.18 Alpine-based image
FROM golang:1.18-alpine3.17 AS builder
WORKDIR /src

# Cache go module downloads
COPY go.mod go.sum ./
RUN go mod download

# Copy the rest of the source and build
COPY . .
ARG VERSION=devel
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
    go build -ldflags "-X main.Version=${VERSION}" -o /build/mkcert

# Runtime stage: minimal Alpine image with the statically linked binary
FROM alpine:3.22.4
RUN apk add --no-cache ca-certificates

# Copy the built binary from builder stage
COPY --from=builder /build/mkcert /usr/local/bin/mkcert

WORKDIR /root

# Default command is the mkcert binary; running the container with no args prints usage
ENTRYPOINT ["mkcert"]
WRITEWriteFile· step #2
0s
.dockerignore154 bytes written
dockerignore18 lines · 154 chars
# Ignore VCS and build/test related files
.git
node_modules
vendor
*.test
*.log
.DS_Store
_build
build
*.exe
*.dll
*.so
*.dylib
*.md
.Makefile
**/tmp/**

VERIFYVerifyBuild· step #3
1m 03s
VerifyBuildsmoke_failed
Smoke [PASS]: mkcert example.test
Smoke [FAIL]: test -f example.test.pem && test -f example.test-key.pem
  Output:
WRITEWriteFile· step #4
0s
Dockerfile840 bytes written
text28 lines · 840 chars
# Build stage: compile mkcert for Linux (amd64) using a Go 1.18 Alpine-based image
FROM golang:1.18-alpine3.17 AS builder
WORKDIR /src

# Cache go module downloads
COPY go.mod go.sum ./
RUN go mod download

# Copy the rest of the source and build
COPY . .
ARG VERSION=devel
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
    go build -ldflags "-X main.Version=${VERSION}" -o /build/mkcert

# Runtime stage: minimal Alpine image with the statically linked binary
FROM alpine:3.22.4
RUN apk add --no-cache ca-certificates

# Create a working directory for the smoke tests and set as default
RUN mkdir -p /workspace
WORKDIR /workspace

# Copy the built binary from builder stage
COPY --from=builder /build/mkcert /usr/local/bin/mkcert

# Default command is the mkcert binary; running the container with no args prints usage
ENTRYPOINT ["mkcert"]
VERIFYVerifyBuild· step #5
34s
VerifyBuildaccepted
Concerns: The smoke test relies on mkcert generating files in the current directory; ensure the container user has write access to /workspace and that mkcert does not require additional setup (like -install) for this test to succeed in Alpine.
Smoke [PASS]: rm -f test-cert.pem test-key.pem; mkcert -cert-file test-cert.pem -key-file test-key.pem localhost; [ -s test-cert.pem ] && [ -s test-key.pem ]