Makefile 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. .PHONY: all binary build cross default docs docs-build docs-shell shell test test-unit test-integration test-integration-cli test-docker-py validate
  2. # env vars passed through directly to Docker's build scripts
  3. # to allow things like `make DOCKER_CLIENTONLY=1 binary` easily
  4. # `docs/sources/contributing/devenvironment.md ` and `project/PACKAGERS.md` have some limited documentation of some of these
  5. DOCKER_ENVS := \
  6. -e BUILDFLAGS \
  7. -e DOCKER_CLIENTONLY \
  8. -e DOCKER_EXECDRIVER \
  9. -e DOCKER_GRAPHDRIVER \
  10. -e TESTDIRS \
  11. -e TESTFLAGS \
  12. -e TIMEOUT
  13. # note: we _cannot_ add "-e DOCKER_BUILDTAGS" here because even if it's unset in the shell, that would shadow the "ENV DOCKER_BUILDTAGS" set in our Dockerfile, which is very important for our official builds
  14. # to allow `make DOCSDIR=docs docs-shell` (to create a bind mount in docs)
  15. DOCS_MOUNT := $(if $(DOCSDIR),-v $(CURDIR)/$(DOCSDIR):/$(DOCSDIR))
  16. # to allow `make DOCSPORT=9000 docs`
  17. DOCSPORT := 8000
  18. # Get the IP ADDRESS
  19. DOCKER_IP=$(shell python -c "import urlparse ; print urlparse.urlparse('$(DOCKER_HOST)').hostname or ''")
  20. HUGO_BASE_URL=$(shell test -z "$(DOCKER_IP)" && echo localhost || echo "$(DOCKER_IP)")
  21. HUGO_BIND_IP=0.0.0.0
  22. GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
  23. DOCKER_IMAGE := docker$(if $(GIT_BRANCH),:$(GIT_BRANCH))
  24. DOCKER_DOCS_IMAGE := docs-base$(if $(GIT_BRANCH),:$(GIT_BRANCH))
  25. DOCKER_RUN_DOCS := docker run --rm -it $(DOCS_MOUNT) -e AWS_S3_BUCKET -e NOCACHE
  26. # for some docs workarounds (see below in "docs-build" target)
  27. GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
  28. default: docs
  29. docs: docs-build
  30. $(DOCKER_RUN_DOCS) -p $(if $(DOCSPORT),$(DOCSPORT):)8000 -e DOCKERHOST "$(DOCKER_DOCS_IMAGE)" hugo server --port=$(DOCSPORT) --baseUrl=$(HUGO_BASE_URL) --bind=$(HUGO_BIND_IP)
  31. docs-draft: docs-build
  32. $(DOCKER_RUN_DOCS) -p $(if $(DOCSPORT),$(DOCSPORT):)8000 -e DOCKERHOST "$(DOCKER_DOCS_IMAGE)" hugo server --buildDrafts="true" --port=$(DOCSPORT) --baseUrl=$(HUGO_BASE_URL) --bind=$(HUGO_BIND_IP)
  33. docs-shell: docs-build
  34. $(DOCKER_RUN_DOCS) -p $(if $(DOCSPORT),$(DOCSPORT):)8000 "$(DOCKER_DOCS_IMAGE)" bash
  35. docs-build:
  36. # ( git remote | grep -v upstream ) || git diff --name-status upstream/release..upstream/docs ./ > ./changed-files
  37. # echo "$(GIT_BRANCH)" > GIT_BRANCH
  38. # echo "$(AWS_S3_BUCKET)" > AWS_S3_BUCKET
  39. # echo "$(GITCOMMIT)" > GITCOMMIT
  40. docker build -t "$(DOCKER_DOCS_IMAGE)" .