|
14 | 14 |
|
15 | 15 | CONTAINER_ENGINE ?= docker
|
16 | 16 | CONTAINER_RUN := $(CONTAINER_ENGINE) run --rm -it -v "$(CURDIR):/src"
|
| 17 | +CONTAINER_RUN_TTY := $(CONTAINER_ENGINE) run --rm -it |
17 | 18 | HUGO_VERSION := $(shell grep ^HUGO_VERSION netlify.toml | tail -n 1 | cut -d '=' -f 2 | tr -d " \"\n")
|
18 | 19 | CONTAINER_IMAGE := k8s-contrib-site-hugo
|
19 | 20 |
|
| 21 | +CONTAINER_HUGO_MOUNTS = \ |
| 22 | + --read-only \ |
| 23 | + --mount type=bind,source=$(CURDIR)/.git,target=/src/.git,readonly \ |
| 24 | + --mount type=bind,source=$(CURDIR)/assets,target=/src/assets,readonly \ |
| 25 | + --mount type=bind,source=$(CURDIR)/content,target=/src/content,readonly \ |
| 26 | + --mount type=bind,source=$(CURDIR)/external-sources,target=/src/external-sources,readonly \ |
| 27 | + --mount type=bind,source=$(CURDIR)/hack,target=/src/hack,readonly \ |
| 28 | + --mount type=bind,source=$(CURDIR)/layouts,target=/src/layouts,readonly \ |
| 29 | + --mount type=bind,source=$(CURDIR)/static,target=/src/static,readonly \ |
| 30 | + --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 \ |
| 31 | + --mount type=bind,source=$(CURDIR)/hugo.yaml,target=/src/hugo.yaml,readonly |
| 32 | + |
20 | 33 | # Fast NONBLOCKING IO to stdout caused by the hack/gen-content.sh script can
|
21 | 34 | # cause Netlify builds to terminate unexpectedly. This forces stdout to block.
|
22 | 35 | BLOCK_STDOUT_CMD := python -c "import os,sys,fcntl; \
|
@@ -68,17 +81,16 @@ docker-render:
|
68 | 81 | $(MAKE) container-render
|
69 | 82 |
|
70 | 83 | container-render: ## Build the site using Hugo within a container (equiv to render).
|
71 |
| - $(CONTAINER_RUN) $(CONTAINER_IMAGE) hugo --logLevel info --ignoreCache --minify |
| 84 | + $(CONTAINER_RUN_TTY) $(CONTAINER_HUGO_MOUNTS) $(CONTAINER_IMAGE) hugo --logLevel info --ignoreCache --minify |
72 | 85 |
|
73 | 86 | docker-server:
|
74 | 87 | @echo -e "**** The use of docker-server is deprecated. Use container-server instead. ****" 1>&2
|
75 | 88 | $(MAKE) container-server
|
76 | 89 |
|
77 | 90 | container-server: ## Run Hugo locally within a container, available at http://localhost:1313/
|
78 | 91 | # no build lock to allow for read-only mounts
|
79 |
| - $(CONTAINER_RUN) -p 1313:1313 \ |
80 |
| - --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 \ |
81 |
| - --read-only \ |
| 92 | + $(CONTAINER_RUN_TTY) -p 1313:1313 \ |
| 93 | + $(CONTAINER_HUGO_MOUNTS) \ |
82 | 94 | --cap-drop=ALL \
|
83 | 95 | --cap-drop=AUDIT_WRITE \
|
84 | 96 | $(CONTAINER_IMAGE) \
|
|
0 commit comments