mirror of https://github.com/docker/compose.git
contenairized documetation generation
add docs validation (using same process a BuildX project) Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
This commit is contained in:
parent
35ba6f68e5
commit
bf26cbd498
|
@ -1,3 +1,2 @@
|
||||||
.git/
|
|
||||||
bin/
|
bin/
|
||||||
dist/
|
dist/
|
||||||
|
|
15
Makefile
15
Makefile
|
@ -82,6 +82,19 @@ lint: ## run linter(s)
|
||||||
--build-arg GIT_TAG=$(GIT_TAG) \
|
--build-arg GIT_TAG=$(GIT_TAG) \
|
||||||
--target lint
|
--target lint
|
||||||
|
|
||||||
|
.PHONY: docs
|
||||||
|
docs: ## generate documentation
|
||||||
|
@docker build . \
|
||||||
|
--output type=local,dest=./docs/ \
|
||||||
|
-f ./docs/docs.Dockerfile \
|
||||||
|
--target update
|
||||||
|
|
||||||
|
.PHONY: validate-docs
|
||||||
|
validate-docs: ## validate the doc does not change
|
||||||
|
@docker build . \
|
||||||
|
-f ./docs/docs.Dockerfile \
|
||||||
|
--target validate
|
||||||
|
|
||||||
.PHONY: check-dependencies
|
.PHONY: check-dependencies
|
||||||
check-dependencies: ## check dependency updates
|
check-dependencies: ## check dependency updates
|
||||||
go list -u -m -f '{{if not .Indirect}}{{if .Update}}{{.}}{{end}}{{end}}' all
|
go list -u -m -f '{{if not .Indirect}}{{if .Update}}{{.}}{{end}}{{end}}' all
|
||||||
|
@ -98,7 +111,7 @@ go-mod-tidy: ## Run go mod tidy in a container and output resulting go.mod and g
|
||||||
validate-go-mod: ## Validate go.mod and go.sum are up-to-date
|
validate-go-mod: ## Validate go.mod and go.sum are up-to-date
|
||||||
@docker build . --target check-go-mod
|
@docker build . --target check-go-mod
|
||||||
|
|
||||||
validate: validate-go-mod validate-headers ## Validate sources
|
validate: validate-go-mod validate-headers validate-docs ## Validate sources
|
||||||
|
|
||||||
pre-commit: validate check-dependencies lint compose-plugin test e2e-compose
|
pre-commit: validate check-dependencies lint compose-plugin test e2e-compose
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,3 @@ check-license-headers:
|
||||||
.PHONY: check-go-mod
|
.PHONY: check-go-mod
|
||||||
check-go-mod:
|
check-go-mod:
|
||||||
./scripts/validate/check-go-mod
|
./scripts/validate/check-go-mod
|
||||||
|
|
||||||
.PHONY: yamldocs
|
|
||||||
yamldocs:
|
|
||||||
go run docs/yaml/main/generate.go
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
# syntax=docker/dockerfile:1.3-labs
|
||||||
|
|
||||||
|
|
||||||
|
# Copyright 2020 Docker Compose CLI authors
|
||||||
|
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
ARG GO_VERSION=1.17
|
||||||
|
ARG FORMATS=md,yaml
|
||||||
|
|
||||||
|
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS docsgen
|
||||||
|
WORKDIR /src
|
||||||
|
RUN --mount=target=. \
|
||||||
|
--mount=target=/root/.cache,type=cache \
|
||||||
|
go build -o /out/docsgen ./docs/yaml/main/generate.go
|
||||||
|
|
||||||
|
FROM --platform=${BUILDPLATFORM} alpine AS gen
|
||||||
|
RUN apk add --no-cache rsync git
|
||||||
|
WORKDIR /src
|
||||||
|
COPY --from=docsgen /out/docsgen /usr/bin
|
||||||
|
ARG FORMATS
|
||||||
|
RUN --mount=target=/context \
|
||||||
|
--mount=target=.,type=tmpfs <<EOT
|
||||||
|
set -e
|
||||||
|
rsync -a /context/. .
|
||||||
|
docsgen --formats "$FORMATS" --source "docs/reference"
|
||||||
|
mkdir /out
|
||||||
|
cp -r docs/reference /out
|
||||||
|
EOT
|
||||||
|
|
||||||
|
FROM scratch AS update
|
||||||
|
COPY --from=gen /out /
|
||||||
|
|
||||||
|
FROM gen AS validate
|
||||||
|
RUN --mount=target=/context \
|
||||||
|
--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
|
|
@ -22,16 +22,21 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
clidocstool "github.com/docker/cli-docs-tool"
|
clidocstool "github.com/docker/cli-docs-tool"
|
||||||
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/compose/v2/cmd/compose"
|
"github.com/docker/compose/v2/cmd/compose"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func generateDocs(opts *options) error {
|
func generateDocs(opts *options) error {
|
||||||
|
dockerCLI, err := command.NewDockerCli()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "docker",
|
Use: "docker",
|
||||||
DisableAutoGenTag: true,
|
DisableAutoGenTag: true,
|
||||||
}
|
}
|
||||||
cmd.AddCommand(compose.RootCommand(nil, nil))
|
cmd.AddCommand(compose.RootCommand(dockerCLI, nil))
|
||||||
disableFlagsInUseLine(cmd)
|
disableFlagsInUseLine(cmd)
|
||||||
|
|
||||||
tool, err := clidocstool.New(clidocstool.Options{
|
tool, err := clidocstool.New(clidocstool.Options{
|
||||||
|
|
Loading…
Reference in New Issue