You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 3.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. HUGO_VERSION = $(shell grep ^HUGO_VERSION netlify.toml | tail -n 1 | cut -d '=' -f 2 | tr -d " \"\n")
  2. NODE_BIN = node_modules/.bin
  3. NETLIFY_FUNC = $(NODE_BIN)/netlify-lambda
  4. # The CONTAINER_ENGINE variable is used for specifying the container engine. By default 'docker' is used
  5. # but this can be overridden when calling make, e.g.
  6. # CONTAINER_ENGINE=podman make container-image
  7. CONTAINER_ENGINE ?= docker
  8. IMAGE_REGISTRY ?= gcr.io/k8s-staging-sig-docs
  9. IMAGE_VERSION=$(shell scripts/hash-files.sh Dockerfile Makefile | cut -c 1-12)
  10. CONTAINER_IMAGE = $(IMAGE_REGISTRY)/k8s-website-hugo:v$(HUGO_VERSION)-$(IMAGE_VERSION)
  11. # Mount read-only to allow use with tools like Podman in SELinux mode
  12. # Container targets don't need to write into /src
  13. CONTAINER_RUN = "$(CONTAINER_ENGINE)" run --rm --interactive --tty --volume "$(CURDIR):/src:ro,Z"
  14. CCRED=\033[0;31m
  15. CCEND=\033[0m
  16. # Docker buildx related settings for multi-arch images
  17. DOCKER_BUILDX ?= docker buildx
  18. REPO_ROOT:=${CURDIR}/..
  19. # setup go for managing hugo
  20. # go1.9+ can autodetect GOROOT, but if some other tool sets it ...
  21. GOROOT:=
  22. # enable modules
  23. GO111MODULE=on
  24. # disable CGO by default for static binaries
  25. CGO_ENABLED=0
  26. DOCKER = docker
  27. HUGO_VERSION = 0.60.0
  28. DOCKER_IMAGE = jojomi/hugo:$(HUGO_VERSION)
  29. DOCKER_RUN = $(DOCKER) run --rm --interactive --tty --volume $(realpath $(CURDIR)/..):/src -p 1313:1313 --workdir /src/site --entrypoint=hugo --platform linux/amd64 $(DOCKER_IMAGE)
  30. HUGO_BIN:=$(REPO_ROOT)/bin/hugo
  31. $(HUGO_BIN):
  32. go build -o $(HUGO_BIN) github.com/gohugoio/hugo
  33. .PHONY: help
  34. help: ## Show this help.
  35. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
  36. .PHONY: container-image
  37. module-check: ## Check if all of the required submodules are correctly initialized.
  38. @git submodule status --recursive | awk '/^[+-]/ {err = 1; printf "\033[31mWARNING\033[0m Submodule not initialized: \033[34m%s\033[0m\n",$$2} END { if (err != 0) print "You need to run \033[32mmake module-init\033[0m to initialize missing modules first"; exit err }' 1>&2
  39. .PHONY: module-init
  40. module-init: ## Initialize required submodules.
  41. @echo "Initializing submodules..." 1>&2
  42. @git submodule update --init --recursive --depth 1
  43. all: build ## Build site with production settings and put deliverables in ./public
  44. .PHONY: build
  45. build: module-check ## Build site with non-production settings and put deliverables in ./public
  46. $(HUGO_BIN) --cleanDestinationDir --minify --environment development
  47. .PHONY: build-preview
  48. build-preview: module-check ## Build site with drafts and future posts enabled
  49. $(HUGO_BIN) --cleanDestinationDir --buildDrafts --buildFuture --environment preview
  50. .PHONY: functions-build
  51. functions-build: ## Build functions
  52. $(NETLIFY_FUNC) build functions-src
  53. .PHONY: hugo
  54. hugo: $(HUGO_BIN) ## Build site with production settings and put deliverables in ./public
  55. $(HUGO_BIN) --cleanDestinationDir --minify --environment production
  56. .PHONY: serve
  57. serve: hugo ## Serve site at http://localhost:1313/
  58. $(HUGO_BIN) server --bind="0.0.0.0" \
  59. --ignoreCache \
  60. --buildFuture \
  61. --disableFastRender