Skip to content

Commit 0dafd86

Browse files
committed
move targets
1 parent d559418 commit 0dafd86

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

Dockerfile

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,44 @@ FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS base
99
RUN apk add --no-cache git rsync
1010
WORKDIR /app
1111

12+
# Docs generation and validation targets
13+
FROM base AS docs-gen
14+
WORKDIR /src
15+
RUN --mount=target=. \
16+
--mount=target=/root/.cache,type=cache \
17+
go build -mod=vendor -o /out/docsgen ./docs/generator/generate.go
18+
19+
FROM base AS docs-build
20+
COPY --from=docs-gen /out/docsgen /usr/bin
21+
ENV DOCKER_CLI_PLUGIN_ORIGINAL_CLI_COMMAND="mcp"
22+
ARG DOCS_FORMATS
23+
RUN --mount=target=/context \
24+
--mount=target=.,type=tmpfs <<EOT
25+
set -e
26+
rsync -a /context/. .
27+
docsgen --formats "$DOCS_FORMATS" --source "docs/generator/reference"
28+
mkdir /out
29+
cp -r docs/generator/reference/* /out/
30+
EOT
31+
32+
FROM scratch AS docs-update
33+
COPY --from=docs-build /out /
34+
35+
FROM docs-build AS docs-validate
36+
RUN --mount=target=/context \
37+
--mount=target=.,type=tmpfs <<EOT
38+
set -e
39+
rsync -a /context/. .
40+
git add -A
41+
rm -rf docs/generator/reference/*
42+
cp -rf /out/* ./docs/generator/reference/
43+
if [ -n "$(git status --porcelain -- docs/generator/reference)" ]; then
44+
echo >&2 'ERROR: Docs result differs. Please update with "make docs"'
45+
git status --porcelain -- docs/generator/reference
46+
exit 1
47+
fi
48+
EOT
49+
1250
FROM base AS lint
1351
COPY --from=lint-base /usr/bin/golangci-lint /usr/bin/golangci-lint
1452
ARG TARGETOS
@@ -130,40 +168,3 @@ EOF
130168
RUN chmod +x /run.sh
131169
ENV PORT=8080
132170
ENTRYPOINT ["/run.sh"]
133-
134-
FROM base AS docs-gen
135-
WORKDIR /src
136-
RUN --mount=target=. \
137-
--mount=target=/root/.cache,type=cache \
138-
go build -mod=vendor -o /out/docsgen ./docs/generator/generate.go
139-
140-
FROM base AS docs-build
141-
COPY --from=docs-gen /out/docsgen /usr/bin
142-
ENV DOCKER_CLI_PLUGIN_ORIGINAL_CLI_COMMAND="mcp"
143-
ARG DOCS_FORMATS
144-
RUN --mount=target=/context \
145-
--mount=target=.,type=tmpfs <<EOT
146-
set -e
147-
rsync -a /context/. .
148-
docsgen --formats "$DOCS_FORMATS" --source "docs/generator/reference"
149-
mkdir /out
150-
cp -r docs/generator/reference/* /out/
151-
EOT
152-
153-
FROM scratch AS docs-update
154-
COPY --from=docs-build /out /
155-
156-
FROM docs-build AS docs-validate
157-
RUN --mount=target=/context \
158-
--mount=target=.,type=tmpfs <<EOT
159-
set -e
160-
rsync -a /context/. .
161-
git add -A
162-
rm -rf docs/generator/reference/*
163-
cp -rf /out/* ./docs/generator/reference/
164-
if [ -n "$(git status --porcelain -- docs/generator/reference)" ]; then
165-
echo >&2 'ERROR: Docs result differs. Please update with "make docs"'
166-
git status --porcelain -- docs/generator/reference
167-
exit 1
168-
fi
169-
EOT

0 commit comments

Comments
 (0)