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
- REPO_ROOT :=${CURDIR}
20
20
21
- # Fast NONBlOCKING IO to stdout caused by the hack/gen-content.sh script can
22
- # cause Netlify builds to terminate unexpectantly. This forces stdout to block.
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
+
33
+ # Fast NONBLOCKING IO to stdout caused by the hack/gen-content.sh script can
34
+ # cause Netlify builds to terminate unexpectedly. This forces stdout to block.
23
35
BLOCK_STDOUT_CMD := python -c "import os,sys,fcntl; \
24
36
flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); \
25
37
fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);"
26
38
27
39
.DEFAULT_GOAL := help
28
40
29
41
.PHONY : targets container-targets
30
- targets : help gen-content render serve clean clean-all sproduction preview-build
42
+ targets : help gen-content render server clean clean-all production-build preview-build
31
43
container-targets : container-image container-gen-content container-render container-server
32
44
33
45
help : # # Show this help text.
34
46
@grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
35
47
48
+ dependencies :
49
+ npm ci
50
+
36
51
gen-content : # # Generates content from external sources.
37
52
hack/gen-content.sh
38
53
39
- render : # # Build the site using Hugo on the host.
40
- git submodule update --init --recursive --depth 1
41
- hugo --verbose --ignoreCache --minify
54
+ render : dependencies # # Build the site using Hugo on the host.
55
+ hugo --logLevel info --ignoreCache --minify
42
56
43
- server : # # Run Hugo locally (if Hugo "extended" is installed locally)
44
- git submodule update --init --recursive --depth 1
57
+ server : dependencies # # Run Hugo locally (if Hugo "extended" is installed locally)
45
58
hugo server \
46
- --verbose \
59
+ --logLevel info \
47
60
--buildDrafts \
48
61
--buildFuture \
49
62
--disableFastRender \
50
63
--ignoreCache
51
64
52
- docker-image : container-image
65
+ docker-image :
53
66
@echo -e " **** The use of docker-image is deprecated. Use container-image instead. ****" 1>&2
67
+ $(MAKE ) container-image
54
68
55
69
container-image : # # Build container image for use with container-* targets.
56
70
$(CONTAINER_ENGINE ) build . -t $(CONTAINER_IMAGE ) --build-arg HUGO_VERSION=$(HUGO_VERSION )
@@ -67,27 +81,24 @@ docker-render:
67
81
$(MAKE ) container-render
68
82
69
83
container-render : # # Build the site using Hugo within a container (equiv to render).
70
- git submodule update --init --recursive --depth 1
71
- $(CONTAINER_RUN ) $(CONTAINER_IMAGE ) hugo --verbose --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
- git submodule update --init --recursive --depth 1
80
- $(CONTAINER_RUN ) -p 1313:1313 \
81
- --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 \
82
- --read-only \
92
+ $(CONTAINER_RUN_TTY ) -p 1313:1313 \
93
+ $(CONTAINER_HUGO_MOUNTS ) \
83
94
--cap-drop=ALL \
84
95
--cap-drop=AUDIT_WRITE \
85
96
$(CONTAINER_IMAGE ) \
86
97
bash -c ' cd /src && hack/gen-content.sh --in-container && \
87
98
cd /tmp/src && \
88
99
hugo server \
89
100
--environment preview \
90
- --verbose \
101
+ --logLevel info \
91
102
--noBuildLock \
92
103
--bind 0.0.0.0 \
93
104
--buildDrafts \
@@ -100,7 +111,7 @@ container-server: ## Run Hugo locally within a container, available at http://lo
100
111
clean : # # Cleans build artifacts.
101
112
rm -rf public/ resources/ _tmp/
102
113
103
- clean-all : # # Cleans both build artifacts and files sycned to content directory
114
+ clean-all : # # Cleans both build artifacts and files synced to content directory
104
115
rm -rf public/ resources/ _tmp/
105
116
rm -f content/en/events/community-meeting.md
106
117
rm -f content/en/events/meet-our-contributors.md
@@ -129,21 +140,19 @@ clean-all: ## Cleans both build artifacts and files sycned to content directory
129
140
130
141
production-build : # # Builds the production site (this command used only by Netlify).
131
142
$(BLOCK_STDOUT_CMD )
132
- git submodule update --init --recursive --depth 1
133
143
hack/gen-content.sh
134
144
hugo \
135
145
--environment production \
136
- --verbose \
146
+ --logLevel info \
137
147
--ignoreCache \
138
148
--minify
139
149
140
150
preview-build : # # Builds a deploy preview of the site (this command used only by Netlify).
141
151
$(BLOCK_STDOUT_CMD )
142
- git submodule update --init --recursive --depth 1
143
152
hack/gen-content.sh
144
153
hugo \
145
154
--environment preview \
146
- --verbose \
155
+ --logLevel info \
147
156
--baseURL $(DEPLOY_PRIME_URL ) \
148
157
--buildDrafts \
149
158
--buildFuture \
0 commit comments