Debian Codegraph @

buildkit/hack/dockerfiles/docs.Dockerfile

raw
1 # syntax=docker/dockerfile:1
2
3 ARG GO_VERSION=1.25
4 ARG ALPINE_VERSION=3.22
5
6 FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS golatest
7
8 FROM golatest AS buildctl
9 WORKDIR /src
10 ENV CGO_ENABLED=0
11 ARG TARGETPLATFORM
12 RUN --mount=target=. \
13 --mount=target=/root/.cache,type=cache \
14 --mount=target=/go/pkg/mod,type=cache \
15 go build -mod=vendor -o /usr/bin/buildctl ./cmd/buildctl
16
17 FROM golatest AS docsgen
18 WORKDIR /src
19 ENV CGO_ENABLED=0
20 RUN --mount=target=. \
21 --mount=target=/root/.cache,type=cache \
22 --mount=target=/go/pkg/mod,type=cache \
23 go build -mod=vendor -o /out/docsgen ./docs/generate.go
24
25 FROM alpine AS gen
26 RUN apk add --no-cache rsync git
27 WORKDIR /src
28 COPY --from=docsgen /out/docsgen /usr/bin
29 COPY --from=buildctl /usr/bin/buildctl /usr/bin/
30 RUN --mount=target=/context \
31 --mount=target=.,type=tmpfs <<EOT
32 set -e
33 rsync -a /context/. .
34 docsgen
35 mkdir /out
36 cp -r docs/* /out
37 EOT
38
39 FROM scratch AS update
40 COPY --from=gen /out /
41
42 FROM gen AS validate
43 RUN --mount=target=/context \
44 --mount=target=.,type=tmpfs <<EOT
45 set -e
46 rsync -a /context/. .
47 git add -A
48 rm -rf docs/*
49 cp -rf /out/* ./docs/
50 if [ -n "$(git status --porcelain -- docs/)" ]; then
51 echo >&2 'ERROR: Docs result differs. Please update with "make docs"'
52 git status --porcelain -- docs/
53 exit 1
54 fi
55 EOT