github.com/pdmccormick/importable-docker-buildx@v0.0.0-20240426161518-e47091289030/hack/dockerfiles/docs.Dockerfile (about) 1 # syntax=docker/dockerfile:1 2 3 ARG GO_VERSION=1.21 4 ARG FORMATS=md,yaml 5 6 FROM golang:${GO_VERSION}-alpine AS docsgen 7 WORKDIR /src 8 RUN --mount=target=. \ 9 --mount=target=/root/.cache,type=cache \ 10 go build -mod=vendor -o /out/docsgen ./docs/generate.go 11 12 FROM alpine AS gen 13 RUN apk add --no-cache rsync git 14 WORKDIR /src 15 COPY --from=docsgen /out/docsgen /usr/bin 16 ARG FORMATS 17 ARG BUILDX_EXPERIMENTAL 18 RUN --mount=target=/context \ 19 --mount=target=.,type=tmpfs <<EOT 20 set -e 21 rsync -a /context/. . 22 docsgen --formats "$FORMATS" --source "docs/reference" 23 mkdir /out 24 cp -r docs/reference /out 25 rm -f /out/reference/*__INTERNAL_SERVE.yaml /out/reference/*__INTERNAL_SERVE.md 26 EOT 27 28 FROM scratch AS update 29 COPY --from=gen /out /out 30 31 FROM gen AS validate 32 RUN --mount=target=/context \ 33 --mount=target=.,type=tmpfs <<EOT 34 set -e 35 rsync -a /context/. . 36 git add -A 37 rm -rf docs/reference/* 38 cp -rf /out/* ./docs/ 39 if [ -n "$(git status --porcelain -- docs/reference)" ]; then 40 echo >&2 'ERROR: Docs result differs. Please update with "make docs"' 41 git status --porcelain -- docs/reference 42 exit 1 43 fi 44 EOT