# Image versions are pinned: update them on purpose.

# ---- Build ----
FROM golang:1.27.1-alpine3.24 AS build
WORKDIR /src
COPY go.mod ./
COPY *.go ./
COPY web ./web
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/searchgit .

# ---- Final image ----
FROM alpine:3.24.2
RUN apk add --no-cache ca-certificates \
 && adduser -D -H -u 10001 searchgit
COPY --from=build /out/searchgit /usr/local/bin/searchgit
USER searchgit
EXPOSE 8080/tcp
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://127.0.0.1:8080/healthz || exit 1
ENTRYPOINT ["/usr/local/bin/searchgit"]
