-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
150 lines (120 loc) · 4.01 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
.DEFAULT_GOAL := build
.PHONY: build-hs test-hs repl-hs watch-hs
.PHONY: build-ps test-ps repl-ps watch-ps deps-ps
.PHONY: build-static build clean cert-renew dns-acme
.PHONY: deployable do-rsync-deploy deploy-stage deploy-cloud
.PHONY: serve dump-contacts todo backup-db
### Haskell ####################################################################
build-hs:
@stack build --pedantic --test --no-run-tests
test-hs: build-hs
@stack test
repl-hs:
@stack ghci --test --main-is mattaudesse-com
watch-hs:
@ghcid -T "Spec.main"
### PureScript #################################################################
PS_BUILD_DIR = .purs-output
PS_SRC_DIR = ps/src
PS_TEST_DIR = ps/test
PS_BUNDLE_DIR = dist/assets/js
PS_BUNDLE_DIST = $(PS_BUNDLE_DIR)/mattaudesse.com.js
deps-ps:
@psc-package install
$(PS_BUNDLE_DIR):
@mkdir -p $(PS_BUNDLE_DIR)
$(PS_BUNDLE_DIST): $(PS_BUNDLE_DIR) $(shell find ./ps -type f) ./psc-package.json ./Makefile
@$(MAKE) -s deps-ps
@pulp \
--psc-package \
build \
--build-path $(PS_BUILD_DIR) \
--src-path $(PS_SRC_DIR) \
--test-path $(PS_TEST_DIR) \
--jobs 6 \
--optimise \
| closure-compiler \
--compilation_level SIMPLE \
--js_output_file $(PS_BUNDLE_DIST)
build-ps: $(PS_BUNDLE_DIST)
test-ps: deps-ps
@pulp \
--psc-package \
test \
--main Spec \
--build-path $(PS_BUILD_DIR) \
--src-path $(PS_SRC_DIR) \
--test-path $(PS_TEST_DIR)
repl-ps: deps-ps
@pulp \
--psc-package \
repl \
--src-path $(PS_SRC_DIR) \
--test-path $(PS_TEST_DIR)
watch-ps: deps-ps
@pulp \
--psc-package \
--before clear \
--watch \
test \
--main Spec \
--build-path $(PS_BUILD_DIR) \
--src-path $(PS_SRC_DIR) \
--test-path $(PS_TEST_DIR)
### Common #####################################################################
build-static: build-hs
@stack exec -- mattaudesse-com-static site
build: build-static build-ps
clean:
@stack clean
@[ -d $(PS_BUILD_DIR) ] && rm -r $(PS_BUILD_DIR) || true
@[ -d ./dist ] && rm -r ./dist || true
SITE_FQDN = mattaudesse.com
TLS_DIR = ~/.config/letsencrypt/conf/live/$(SITE_FQDN)
SITE_ROOT = /usr/local/jail/nginx/site/$(SITE_FQDN)
RSYNC = rsync -vzhr --progress --perms
CLOUD = matt@$(SITE_FQDN)
CLOUD_ROOT = $(CLOUD):$(SITE_ROOT)
BINARY = $(shell stack path --local-install-root)/bin/mattaudesse-com
cert-renew:
@certbot certonly \
--manual \
--preferred-challenges dns \
-d $(SITE_FQDN)
dns-acme:
@dig @1.1.1.1 +short TXT _acme-challenge.$(SITE_FQDN)
deployable: build test-hs test-ps
@sudo BINARY=$(BINARY) sh/jail-new.sh
./etc/dhparam:
@openssl dhparam -out ./etc/dhparam 4096
do-rsync-deploy: ./etc/dhparam
@$(RSYNC) --mkpath --chmod=F0644 ./dist/ $(ROOT)/static/
@$(RSYNC) --mkpath --chmod=F0600 ./etc/nginx.conf $(ROOT)/conf/
@$(RSYNC) --mkpath --chmod=F0600 ./etc/dhparam $(ROOT)/conf/
@$(RSYNC) -L --chmod=F0600 $(TLS_DIR)/chain.pem $(ROOT)/conf/trusted
@$(RSYNC) -L --chmod=F0600 $(TLS_DIR)/fullchain.pem $(ROOT)/conf/rsa.crt
@$(RSYNC) -L --chmod=F0600 $(TLS_DIR)/privkey.pem $(ROOT)/conf/rsa.key
deploy-stage:
@$(MAKE) -s ROOT=$(SITE_ROOT) do-rsync-deploy
@chmod 0700 $(SITE_ROOT)/conf
@sudo bastille restart mattaudesse-com
@sudo service -j nginx nginx reload
deploy-cloud:
@sh/jail-deploy-cloud.sh
@$(MAKE) -s ROOT=$(CLOUD_ROOT) do-rsync-deploy
@ssh $(CLOUD) 'chmod 0700 $(SITE_ROOT)/conf'
@ssh -t $(CLOUD) 'sudo service -j nginx nginx reload'
serve: build
@stack exec -- mattaudesse-com serve \
--db ./mattaudesse.com.db \
--conf ./mattaudesse.com.yaml
dump-contacts: build-hs
@stack exec -- mattaudesse-com dump-contacts --db ./mattaudesse.com.db
todo:
@ag -i --ignore Makefile todo . || echo "No TODOs left!"
backup-db: BACKUP-DB-DIR=.db-backup/`date -u +"%Y"`/`date -u +"%m"`
backup-db:
@mkdir -p $(BACKUP-DB-DIR)
@$(RSYNC) \
$(CLOUD):/usr/local/jail/mattaudesse-com/db/mattaudesse.com.db \
$(BACKUP-DB-DIR)/`date -u +"%Y-%m-%d-%H-%M"`-mattaudesse.com.db