-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
136 lines (111 loc) · 3.85 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
PWD = $(shell pwd)
UID = $(shell id -u)
GID = $(shell id -g)
PUBLISH_DIR = site
BRANCH = main
TMP_GIT_DIR = /tmp/lfe-io-site-git
PORT = 5099
#############################################################################
### DOCKER ##############################################################
#############################################################################
ZOLA_VERS = 0.16
NODE_VERS = 20
ALPINE_VERS = 3.17
DOCKER_TAG = zola$(ZOLA_VERS)-node$(NODE_VERS)-alpine$(ALPINE_VERS)
DOCKER_ORG = lfex
DOCKER_FQN = $(DOCKER_ORG):$(DOCKER_TAG)
MOUNT_DIR = /app
docker-build:
docker build -t $(DOCKER_FQN) .
docker-shell:
docker run -it \
--entrypoint ash \
$(DOCKER_FQN)
docker-publish: docker-build
docker push $(DOCKER_FQN)
#############################################################################
### SITE ################################################################
#############################################################################
zola-build: clean
@echo " >> Building site ..."
docker run \
-u "$(UID):$(GID)" -v $(PWD):$(MOUNT_DIR) --workdir $(MOUNT_DIR) $(DOCKER_FQN) \
build -o $(PUBLISH_DIR)
build: zola-build docker-build tailwind-build
serve: tailwind-build docker-build
@echo " >> Running site ..."
@docker run \
-p 8080:8080 -p 1024:1024 \
-u "$(UID):$(GID)" -v $(PWD):$(MOUNT_DIR) --workdir $(MOUNT_DIR) $(DOCKER_FQN) \
serve --interface 0.0.0.0 --port 8080 --base-url localhost
run: serve
clean:
@echo " >> Removing files from site dir ..."
@rm -rf $(PUBLISH_DIR)
$(PUBLISH_DIR)/CNAME:
@echo " >> Copying CNAME File ..."
@cp CNAME $(PUBLISH_DIR)/
publish: build $(PUBLISH_DIR)/CNAME
@echo " >> Publishing site ..."
@git commit -am "Updated content"
@git push origin $(BRANCH)
#############################################################################
### SPELLING ############################################################
#############################################################################
spell-check:
@for FILE in `find . -name "*.md"`; do \
RESULTS=$$(cat $$FILE | aspell -d en_GB --mode=markdown list | sort -u | sed -e ':a' -e 'N;$$!ba' -e 's/\n/, /g'); \
if [[ "$$RESULTS" != "" ]] ; then \
echo "Potential spelling errors in $$FILE:"; \
echo "$$RESULTS" | \
sed -e 's/^/ /'; \
echo; \
fi; \
done
add-word: WORD ?= ""
add-word:
@echo "*$(WORD)\n#" | aspell -a
add-words: WORDS ?= ""
add-words:
@echo "Adding words:"
@for WORD in `echo $(WORDS)| tr "," "\n"| tr "," "\n" | sed -e 's/^[ ]*//' | sed -e 's/[ ]*$$//'`; \
do echo " $$WORD ..."; \
echo "*$$WORD\n#" | aspell -a > /dev/null; \
done
@echo
spell-suggest:
@for FILE in `find . -name "*.md"`; do \
RESULTS=$$(cat $$FILE | aspell -d en_GB --mode=markdown list | sort -u ); \
if [[ "$$RESULTS" != "" ]] ; then \
echo "Potential spelling errors in $$FILE:"; \
for WORD in $$RESULTS; do \
echo $$WORD| aspell -d en_GB pipe | tail -2|head -1 | sed -e 's/^/ /'; \
done; \
echo; \
fi; \
done
#############################################################################
### TAILWIND ############################################################
#############################################################################
TAILWIND_BASE = styles
TAILWIND_INPUT = $(TAILWIND_BASE)/site.css
TAILWIND_OUTPUT = static/css/site.css
JS_OUTPUT = static/js/
tailwind-setup: tailwind.config.js $(JS_OUTPUT)/preline.js
$(JS_OUTPUT)/preline.js:
ID=$$(docker create $(DOCKER_FQN)) && \
docker cp $$ID:/node_modules/preline/dist/preline.js $(TAILWIND_BASE)/ && \
docker rm -v $$ID
tailwind.config.js:
docker run -it \
-v $(PWD):$(MOUNT_DIR) --workdir $(MOUNT_DIR) \
--entrypoint npx \
$(DOCKER_FQN) \
tailwindcss init
tailwind-build:
docker run -it \
-v $(PWD):$(MOUNT_DIR) --workdir $(MOUNT_DIR) \
--entrypoint npx \
$(DOCKER_FQN) \
tailwindcss -i $(TAILWIND_INPUT) -o $(TAILWIND_OUTPUT) --minify
cp $(TAILWIND_BASE)/*.js $(JS_OUTPUT)