Skip to content

Commit 9de4626

Browse files
fix: only mount folders that are needed so as to not shadow node_modules
1 parent f672a79 commit 9de4626

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Makefile

+16-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,22 @@
1414

1515
CONTAINER_ENGINE ?= docker
1616
CONTAINER_RUN := $(CONTAINER_ENGINE) run --rm -it -v "$(CURDIR):/src"
17+
CONTAINER_RUN_TTY := $(CONTAINER_ENGINE) run --rm -it
1718
HUGO_VERSION := $(shell grep ^HUGO_VERSION netlify.toml | tail -n 1 | cut -d '=' -f 2 | tr -d " \"\n")
1819
CONTAINER_IMAGE := k8s-contrib-site-hugo
1920

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+
2033
# Fast NONBLOCKING IO to stdout caused by the hack/gen-content.sh script can
2134
# cause Netlify builds to terminate unexpectedly. This forces stdout to block.
2235
BLOCK_STDOUT_CMD := python -c "import os,sys,fcntl; \
@@ -68,17 +81,16 @@ docker-render:
6881
$(MAKE) container-render
6982

7083
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
7285

7386
docker-server:
7487
@echo -e "**** The use of docker-server is deprecated. Use container-server instead. ****" 1>&2
7588
$(MAKE) container-server
7689

7790
container-server: ## Run Hugo locally within a container, available at http://localhost:1313/
7891
# 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) \
8294
--cap-drop=ALL \
8395
--cap-drop=AUDIT_WRITE \
8496
$(CONTAINER_IMAGE) \

0 commit comments

Comments
 (0)