Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_GRAPHDRIVER \
  9. -e TESTDIRS \
  10. -e TESTFLAGS \
  11. -e TIMEOUT
  12. # 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
  13. # to allow `make DOCSDIR=docs docs-shell` (to create a bind mount in docs)
  14. DOCS_MOUNT := $(if $(DOCSDIR),-v $(CURDIR)/$(DOCSDIR):/$(DOCSDIR))
  15. # to allow `make DOCSPORT=9000 docs`
  16. DOCSPORT := 8000
  17. # Get the IP ADDRESS
  18. DOCKER_IP=$(shell python -c "import urlparse ; print urlparse.urlparse('$(DOCKER_HOST)').hostname or ''")
  19. HUGO_BASE_URL=$(shell test -z "$(DOCKER_IP)" && echo localhost || echo "$(DOCKER_IP)")
  20. HUGO_BIND_IP=0.0.0.0
  21. GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
  22. DOCKER_IMAGE := docker$(if $(GIT_BRANCH),:$(GIT_BRANCH))
  23. DOCKER_DOCS_IMAGE := docs-base$(if $(GIT_BRANCH),:$(GIT_BRANCH))
  24. DOCKER_RUN_DOCS := docker run --rm -it $(DOCS_MOUNT) -e AWS_S3_BUCKET -e NOCACHE
  25. # for some docs workarounds (see below in "docs-build" target)
  26. GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
  27. default: docs
  28. docs: docs-build
  29. $(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)
  30. docs-draft: docs-build
  31. $(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)
  32. docs-shell: docs-build
  33. $(DOCKER_RUN_DOCS) -p $(if $(DOCSPORT),$(DOCSPORT):)8000 "$(DOCKER_DOCS_IMAGE)" bash
  34. docs-build:
  35. # ( git remote | grep -v upstream ) || git diff --name-status upstream/release..upstream/docs ./ > ./changed-files
  36. # echo "$(GIT_BRANCH)" > GIT_BRANCH
  37. # echo "$(AWS_S3_BUCKET)" > AWS_S3_BUCKET
  38. # echo "$(GITCOMMIT)" > GITCOMMIT
  39. docker build -t "$(DOCKER_DOCS_IMAGE)" .