Dockerfile takes ARG VERSION (default "dev") and stamps it into main.version with -X. CD passes --build-arg VERSION=<git tag on v* builds, else the short sha>, so the running pod logs the actual build instead of "dev". Verified locally: `-ldflags -X main.version=...` embeds the string. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
27 lines
927 B
Docker
27 lines
927 B
Docker
FROM golang:1.26-alpine AS build
|
|
WORKDIR /src
|
|
|
|
# Fetch internal git-hosted Go modules (e.g. mcp-chassis) without going
|
|
# through proxy.golang.org and without HTTP→HTTPS surprises. Gitea returns
|
|
# http:// in its go-import meta tag, so rewrite to https here and bypass
|
|
# the module proxy + sumdb.
|
|
RUN apk add --no-cache git && \
|
|
git config --global url."https://git.d-ma.be/".insteadOf "http://git.d-ma.be/"
|
|
ENV GOPRIVATE=git.d-ma.be
|
|
ENV GOPROXY=direct
|
|
ENV GOSUMDB=off
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY . .
|
|
# Build version stamped in by CI (--build-arg VERSION=<tag|sha>); defaults to
|
|
# "dev" for a plain `docker build` (#47).
|
|
ARG VERSION=dev
|
|
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o /out/gitea-mcp ./cmd/gitea-mcp
|
|
|
|
FROM gcr.io/distroless/static-debian12:nonroot
|
|
COPY --from=build /out/gitea-mcp /gitea-mcp
|
|
USER nonroot:nonroot
|
|
EXPOSE 8080
|
|
ENTRYPOINT ["/gitea-mcp"]
|