-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·140 lines (117 loc) · 3.5 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
# Include environment variables
-include .env
# Variables
DONE_MESSAGE = " \033[1;32mDone\n\033[0m"
UPLOADS_DIR = "./app/uploads"
# Default
.PHONY: default
default:
@printf " \033[1;31mPlease supply an environment argument (dev) or command\n\033[0m";
# Top-level commands
.PHONY: dev refresh rebuild rebuild-all clean
dev: env up
refresh: down clean-host up
rebuild: clean build up
rebuild-all: clean build-no-cache up
clean: clean-docker clean-host
.PHONY: env
env:
@if [ ! -f .env ]; then \
echo "Creating \`.env\` file..."; \
cp .stubs/dev.env .env; \
printf $(DONE_MESSAGE); \
else \
echo "The \`.env\` file already exists."; \
fi;
.PHONY: build
build:
@echo "Building docker images..."; \
docker-compose build; \
printf $(DONE_MESSAGE);
.PHONY: build-no-cache
build-no-cache:
@echo "Building docker images from scratch..."; \
docker-compose build --no-cache; \
printf $(DONE_MESSAGE);
.PHONY: up
up:
@echo "Building and running docker services..."; \
docker-compose up; \
printf $(DONE_MESSAGE);
.PHONY: up-d
up-d:
@echo "Building and running docker services in detached (daemon) mode..."; \
docker-compose up -d; \
printf $(DONE_MESSAGE);
.PHONY: start
start:
@echo "Starting docker services..."; \
docker-compose start; \
printf $(DONE_MESSAGE);
.PHONY: restart
restart:
@echo "Restarting docker services..."; \
docker-compose restart; \
printf $(DONE_MESSAGE);
.PHONY: stop
stop:
@echo "Stopping docker services..."; \
docker-compose stop; \
printf $(DONE_MESSAGE);
.PHONY: kill
kill:
@echo "Killing docker services..."; \
docker-compose kill; \
printf $(DONE_MESSAGE);
.PHONY: down
down:
@echo "Stopping and removing docker services..."; \
docker-compose down; \
printf $(DONE_MESSAGE);
.PHONY: clean-docker
clean-docker:
@echo "Stopping and removing docker services, volumes and images..."; \
docker-compose down --volumes --remove-orphans --rmi 'all'; \
printf $(DONE_MESSAGE); \
.PHONY: clean-host
clean-host:
@echo "Cleaning up generated directories and files on the host..."; \
rm -r {$(HOST_STORAGE_DIR),$(HOST_THEME_DIR)/node_modules,$(HOST_THEME_DIR)/build}; \
printf $(DONE_MESSAGE);
.PHONY: ssh-web
ssh-web:
@echo "Starting interactive shell in \`web\` container ..."; \
docker-compose exec web bash;
.PHONY: ssh-node
ssh-node:
@echo "Starting interactive shell in \`node\` container ..."; \
docker-compose exec node bash;
.PHONY: ssh-database
ssh-database:
@echo "Starting interactive shell in \`database\` container ..."; \
docker-compose exec database bash;
.PHONY: export-database
export-database:
@echo "Exporting database..."; \
docker-compose exec -T database /usr/bin/mysqldump -u root --password=$(DB_ROOT_PASSWORD) --skip-extended-insert $(DB_NAME) | gzip --best > $(DB_DUMP_DIR)/db_dump.sql.gz; \
printf $(DONE_MESSAGE);
.PHONY: import-database
import-database:
@echo "Importing database..."; \
gunzip < $(DB_DUMP_DIR)/db_dump.sql.gz | docker-compose exec -T database /usr/bin/mysql -u root --password=$(DB_ROOT_PASSWORD) $(DB_NAME); \
printf $(DONE_MESSAGE);
.PHONY: composer-update
composer-update:
@echo "Updating Composer packages..."; \
docker-compose exec web composer update; \
printf $(DONE_MESSAGE);
.PHONY: npm-update
npm-update:
@echo "Updating NPM packages..."; \
docker-compose exec web bash -c "cd app/themes/wlion && ncu -u && npm install"; \
printf $(DONE_MESSAGE);
.PHONY: permissions-uploads
permissions-uploads:
@echo "Updating uploads directory permissions...";
@docker-compose exec web chmod -R 0777 $(UPLOADS_DIR);
@printf $(DONE_MESSAGE);