2023-02-23 00:45:10 +08:00
|
|
|
# syntax=docker/dockerfile:1
|
2021-03-24 01:40:56 +08:00
|
|
|
|
2023-02-22 21:37:50 +08:00
|
|
|
ARG GO_VERSION=1.20
|
2021-09-09 16:29:08 +08:00
|
|
|
ARG FORMATS=md,yaml
|
2021-09-03 05:11:05 +08:00
|
|
|
|
|
|
|
FROM golang:${GO_VERSION}-alpine AS docsgen
|
2021-03-24 01:40:56 +08:00
|
|
|
WORKDIR /src
|
|
|
|
RUN --mount=target=. \
|
|
|
|
--mount=target=/root/.cache,type=cache \
|
2021-08-26 01:09:42 +08:00
|
|
|
go build -mod=vendor -o /out/docsgen ./docs/generate.go
|
2021-03-24 01:40:56 +08:00
|
|
|
|
|
|
|
FROM alpine AS gen
|
|
|
|
RUN apk add --no-cache rsync git
|
|
|
|
WORKDIR /src
|
|
|
|
COPY --from=docsgen /out/docsgen /usr/bin
|
2021-09-09 16:29:08 +08:00
|
|
|
ARG FORMATS
|
2022-08-16 18:19:28 +08:00
|
|
|
ARG BUILDX_EXPERIMENTAL
|
2021-03-24 01:40:56 +08:00
|
|
|
RUN --mount=target=/context \
|
2021-09-04 04:49:59 +08:00
|
|
|
--mount=target=.,type=tmpfs <<EOT
|
|
|
|
set -e
|
|
|
|
rsync -a /context/. .
|
2021-09-09 16:29:08 +08:00
|
|
|
docsgen --formats "$FORMATS" --source "docs/reference"
|
2021-09-04 04:49:59 +08:00
|
|
|
mkdir /out
|
|
|
|
cp -r docs/reference /out
|
|
|
|
EOT
|
2021-03-24 01:40:56 +08:00
|
|
|
|
|
|
|
FROM scratch AS update
|
|
|
|
COPY --from=gen /out /out
|
|
|
|
|
|
|
|
FROM gen AS validate
|
|
|
|
RUN --mount=target=/context \
|
2021-09-04 04:49:59 +08:00
|
|
|
--mount=target=.,type=tmpfs <<EOT
|
|
|
|
set -e
|
|
|
|
rsync -a /context/. .
|
|
|
|
git add -A
|
|
|
|
rm -rf docs/reference/*
|
|
|
|
cp -rf /out/* ./docs/
|
|
|
|
if [ -n "$(git status --porcelain -- docs/reference)" ]; then
|
|
|
|
echo >&2 'ERROR: Docs result differs. Please update with "make docs"'
|
|
|
|
git status --porcelain -- docs/reference
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
EOT
|