Files
buildkit/hack/dockerfiles/doctoc.Dockerfile
Tonis Tiigi 4ffb02ffcd update doctoc to v2.4.1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-05-14 10:13:21 -07:00

35 lines
891 B
Docker

# syntax=docker/dockerfile-upstream:master
ARG NODE_VERSION=24
FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache git
WORKDIR /src
FROM base AS doctoc
# DOCTOC_VERSION is the version of doctoc to install
# see https://github.com/thlorenz/doctoc/tags for available releases.
ARG DOCTOC_VERSION=v2.4.1
RUN npm install -g doctoc@${DOCTOC_VERSION#v}
RUN --mount=type=bind,source=README.md,target=README.md,rw <<EOT
set -e
doctoc README.md
mkdir /out
cp README.md /out/
EOT
FROM scratch AS update
COPY --from=doctoc /out /
FROM base AS validate-toc
RUN --mount=type=bind,target=.,rw \
--mount=type=bind,from=doctoc,source=/out/README.md,target=./README.md <<EOT
set -e
if [ -n "$(git status --porcelain -- 'README.md')" ]; then
echo >&2 'ERROR: The result of "doctoc" differs. Please update with "make doctoc"'
git diff -- README.md
exit 1
fi
EOT