This repository has been archived by the owner on May 11, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
134 lines (123 loc) · 4.67 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
MATERIAL_KIT := 2.0.3
COMPOSE := docker-compose -f docker-compose.yml -p hugs
.PHONY: help
help: #| Shows available help information of Makefile.
@fgrep -h "#|" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/#|//'
#|
#| ---
#|
.PHONY: up
up: #| Builds, (re)creates, starts, and attaches to containers for a service.
@($(COMPOSE) up -d)
@($(COMPOSE) rm -f)
#|
.PHONY: clean
clean: #| Removes stopped service containers.
@($(COMPOSE) rm -f)
#|
.PHONY: status
status: #| List containers and their status.
@($(COMPOSE) ps)
#|
.PHONY: down
down: #| Stops containers and removes them with networks.
@($(COMPOSE) down)
#|
.PHONY: destroy
destroy: #| Stops containers and removes them with networks, volumes, and images
#| created by `up`.
@($(COMPOSE) down --rmi local --volumes --remove-orphans)
#|
#| ---
#|
CONTAINERS = database \
click \
forma \
hugo \
passport \
server
.PHONY: services
services: #| Shows available services.
@(echo 'available services:'; for container in $(CONTAINERS); do echo '-' $$container; done)
define container_tpl
#|
.PHONY: up-$(1)
up-$(1): #| Builds, (re)creates, starts, and attaches to a container of the service $(1).
#| For example `make up-server`. See `make services`.
@($$(COMPOSE) up -d $(1))
#|
.PHONY: enter-$(1)
enter-$(1): #| Enter to a running container of the service $(1).
#| For example `make enter-server`. See `make services`.
@($$(COMPOSE) exec $(1) sh)
#|
.PHONY: start-$(1)
start-$(1): #| Start an existing container of the service $(1).
#| For example `make start-server`. See `make services`.
@($$(COMPOSE) start $(1))
#|
.PHONY: restart-$(1)
restart-$(1): #| Restart a running container of the service $(1).
#| For example `make restart-server`. See `make services`.
@($$(COMPOSE) restart $(1))
#|
.PHONY: stop-$(1)
stop-$(1): #| Stop a running container of the service $(1) without removing them.
#| For example `make stop-server`. See `make services`.
@($$(COMPOSE) stop $(1))
#|
.PHONY: log-$(1)
log-$(1): #| View output from a container of the service $(1).
#| For example `make log-server`. See `make services`.
@($$(COMPOSE) logs -f $(1))
#|
endef
#| ---
#|
render_container_tpl = $(eval $(call container_tpl,$(container)))
$(foreach container,$(CONTAINERS),$(render_container_tpl))
.PHONY: backup-database
backup-database:
@echo not implemented yet
.PHONY: restore-database
restore-database:
@echo not implemented yet
.PHONY: demo
demo: #| Insert demo data to the database.
@(docker cp ./etc/demo $$(make status | tail +3 | awk '{print $$1}' | grep _database_ | sort | head -1):/tmp/)
@($(COMPOSE) exec database /bin/sh -c 'for sql in $$(ls /tmp/demo/click/*.sql); do su - postgres -c "psql click < $$sql"; done')
@($(COMPOSE) exec database /bin/sh -c 'for sql in $$(ls /tmp/demo/forma/*.sql); do su - postgres -c "psql forma < $$sql"; done')
@#@($(COMPOSE) exec database /bin/sh -c 'for sql in $$(ls /tmp/demo/passport/*.sql); do su - postgres -c "psql passport < $$sql"; done')
#|
.PHONY: psql
psql: #| Connect to the database with psql.
@($(COMPOSE) exec database /bin/sh -c 'su - postgres -c psql')
#|
.PHONY: refresh-nginx
refresh-nginx: #| Sync configurations, process them and reload nginx.
@($(COMPOSE) exec server ./entrypoint.sh repeat)
.PHONY: publish
publish:
docker run --rm -it \
-v $(PWD)/site:/usr/share/site \
-v $(PWD)/docs:/usr/share/docs \
-w /usr/share/site \
kamilsk/hugo:latest hugo --cleanDestinationDir \
--config=config.yml,config.github.yml \
--destination=/usr/share/docs
git checkout docs/CNAME
.PHONY: pull-template
pull-template:
rm -rf template
git clone [email protected]:octotpl/materialkit.git template
( \
cd template && \
git checkout $(MATERIAL_KIT) \
)
( \
rm -rf site/themes/materialkit/static/vendor/* && \
cp -rn template/Template/assets/css site/themes/materialkit/static/vendor/ && \
cp -rn template/Template/assets/js site/themes/materialkit/static/vendor/ \
)
rm -rf template/.git
git add site/themes/materialkit/static/vendor