- Go module (github.com/elfoundation/hatch) with go 1.25 - cmd/hatch: HTTP server with GET /healthz returning 200 OK - Multi-stage Dockerfile producing static binary from scratch - docker-compose with hatch + optional Caddy reverse proxy - CI placeholder with Go test/lint stubs - .gitignore, .dockerignore, .env.example Co-Authored-By: Paperclip <noreply@paperclip.ing>
25 lines
477 B
Docker
25 lines
477 B
Docker
# syntax=docker/dockerfile:1
|
|
|
|
# ---- build stage ----
|
|
FROM golang:1.25-alpine AS build
|
|
|
|
WORKDIR /src
|
|
|
|
# Cache module downloads before copying source (layer caching).
|
|
COPY go.mod ./
|
|
RUN go mod download
|
|
|
|
COPY . ./
|
|
|
|
# Build a fully static binary (CGO disabled, no libc dependency).
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /bin/hatch ./cmd/hatch
|
|
|
|
# ---- run stage ----
|
|
FROM scratch
|
|
|
|
COPY --from=build /bin/hatch /bin/hatch
|
|
|
|
EXPOSE 8080
|
|
|
|
ENTRYPOINT ["/bin/hatch"]
|