Makefile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Copyright 2019 The Kubernetes Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. DOCKER ?= docker
  15. MKDOCS_IMAGE ?= github.com/external-secrets-mkdocs:latest
  16. MKDOCS ?= mkdocs
  17. SERVE_BIND_ADDRESS ?= 127.0.0.1
  18. # TOP is the current directory where this Makefile lives.
  19. TOP := $(dir $(firstword $(MAKEFILE_LIST)))
  20. # ROOT is the repository root.
  21. ROOT := $(abspath $(TOP))/../../
  22. SRCDIR := $(ROOT)/docs
  23. CFGFILE := $(ROOT)/hack/api-docs/mkdocs.yml
  24. # GENROOT is the root of the generated documentation.
  25. GENROOT := $(ROOT)/site
  26. # Grab the uid/gid to fix permissions due to running in a docker container.
  27. GID := $(shell id -g)
  28. UID := $(shell id -u)
  29. # SOURCES is a list of a source files used to generate the documentation.
  30. SOURCES := $(shell find $(SRCDIR) -name \*.md)
  31. SOURCES += mkdocs.yml Makefile
  32. # entrypoint
  33. all: build
  34. .PHONY: image
  35. image:
  36. $(DOCKER) build -t $(MKDOCS_IMAGE) -f Dockerfile .
  37. .PHONY: build
  38. build: image generate $(SOURCES)
  39. mkdir -p $(GENROOT)
  40. $(DOCKER) run \
  41. --mount type=bind,source=$(SRCDIR),target=/docs \
  42. --mount type=bind,source=$(CFGFILE),target=/mkdocs.yml \
  43. --mount type=bind,source=$(GENROOT),target=/site \
  44. --sig-proxy=true \
  45. --rm \
  46. $(MKDOCS_IMAGE) \
  47. /bin/bash -c "cd / && $(MKDOCS) build; find /site -exec chown $(UID):$(GID) {} \;"
  48. .PHONY: generate
  49. generate:
  50. ./generate.sh $(SRCDIR)/spec.md
  51. .PHONY: clean
  52. clean:
  53. rm -r $(GENROOT)/* || true
  54. # serve runs mkdocs as a local webserver for interactive development.
  55. # This will serve the live copy of the docs on 127.0.0.1:8000.
  56. .PHONY: serve
  57. serve: build
  58. $(DOCKER) run \
  59. -it \
  60. --sig-proxy=true \
  61. --mount type=bind,source=$(SRCDIR),target=/docs \
  62. --mount type=bind,source=$(CFGFILE),target=/mkdocs.yml \
  63. --mount type=bind,source=$(GENROOT),target=/site \
  64. -p $(SERVE_BIND_ADDRESS):8000:8000 \
  65. --rm \
  66. $(MKDOCS_IMAGE) \
  67. /bin/bash -c "cd / && $(MKDOCS) serve -a 0.0.0.0:8000"