Makefile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. .PHONY: all default docs docs-build docs-shell shell checkvars
  2. # to allow `make DOCSPORT=9000 docs`
  3. DOCSPORT := 3004
  4. DOCKER_DOCS_IMAGE := grafana/grafana-docs
  5. SOURCES_HOST_DIR := "$(shell pwd)/sources"
  6. # assuming grafana and grafana.org-repo to be checked out in the same folder
  7. DEFAULT_LAYOUTS_DIR := "$(shell pwd)/../../../../../../grafana.org/layouts"
  8. # to allow `make DOCSDIR=docs docs-shell` (to create a bind mount in docs)
  9. LAYOUTS_MOUNT := $(if $(LAYOUTS),-v $(DEFAULT_LAYOUTS_DIR):/site/layouts)
  10. DOCS_MOUNT := -v $(SOURCES_HOST_DIR):/site/content
  11. DOCKER_RUN_DOCS := docker run --rm -it $(DOCS_MOUNT) $(LAYOUTS_MOUNT) -e NOCACHE -p 3004:3004 -p 3005:3005
  12. VERSION := $(shell head -n 1 VERSION)
  13. default: docs
  14. checkvars:
  15. ifndef ENV
  16. $(error ENV is undefined set via ENV=staging or ENV=prod as argument to make)
  17. endif
  18. docs: docs-build
  19. $(DOCKER_RUN_DOCS) $(DOCS_MOUNT) -e DOCKERHOST "$(DOCKER_DOCS_IMAGE)" /bin/bash -c "grunt --env=dev-docs && grunt connect --port=3004"
  20. watch: docs-build
  21. $(DOCKER_RUN_DOCS) $(DOCS_MOUNT) $(LAYOUTS_MOUNT) -e DOCKERHOST "$(DOCKER_DOCS_IMAGE)" /bin/bash -c "grunt --env=dev-docs && grunt connect --port=3004 & grunt watch --port=3004 --env=dev-docs"
  22. publish: checkvars docs-build
  23. $(info Publishing ENV=${ENV} and VERSION=${VERSION})
  24. $(DOCKER_RUN_DOCS) $(DOCS_MOUNT) -e DOCKERHOST "$(DOCKER_DOCS_IMAGE)" /bin/bash -c "./publish.sh ${ENV}-docs ${VERSION}"
  25. docs-build:
  26. docker build -t "$(DOCKER_DOCS_IMAGE)" --no-cache .