mirror of
https://github.com/thecodingrobot/echoip.git
synced 2026-05-09 00:04:23 +02:00
Makefile: - Add .PHONY declaration for all 16 phony targets. - Fix parse-time $(error) at line 39: replace with runtime shell check so the guard actually fires when the recipe runs. - Simplify check-fmt to portable 'gofmt -l -s .' form. - Add -trimpath -ldflags='-s -w' to install for smaller, reproducible binaries. Dockerfile: - Switch runtime to distroless/static-debian13:nonroot + USER nonroot. - Split COPY so go.mod/go.sum cache layer is independent of source. - Drop ENV GO111MODULE=on (no-op since Go 1.16).
24 lines
523 B
Docker
24 lines
523 B
Docker
# Build stage
|
|
FROM golang:1.26-trixie AS build
|
|
WORKDIR /go/src/github.com/mpolden/echoip
|
|
|
|
# Must build without cgo because libc is unavailable in runtime image
|
|
ENV CGO_ENABLED=0
|
|
|
|
# Cache module downloads independently of source changes
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
RUN make
|
|
|
|
# Runtime stage
|
|
FROM gcr.io/distroless/static-debian13:nonroot
|
|
EXPOSE 8080
|
|
|
|
COPY --from=build /go/bin/echoip /opt/echoip/
|
|
COPY html /opt/echoip/html
|
|
|
|
WORKDIR /opt/echoip
|
|
USER nonroot:nonroot
|
|
ENTRYPOINT ["/opt/echoip/echoip"]
|