-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (85 loc) · 3.19 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mpeulet <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/03/18 09:13:18 by mpeulet #+# #+# #
# Updated: 2024/05/15 12:21:28 by mpeulet ### ########.fr #
# #
# **************************************************************************** #
#Colors / base 16 / Bright
DEF_COLOR = \033[0;39m
GREY = \033[0;90m
RED = \033[0;91m
GREEN = \033[0;92m
YELLOW = \033[0;93m
BLUE = \033[0;94m
MAGENTA = \033[0;95m
CYAN = \033[0;96m
WHITE = \033[0;97m
ORANGE = \033[38;5;214m
PROJECT_DATA = /home/${USER}/data
MDB_VOLUME = /home/${USER}/data/mariadb
WP_VOLUME = /home/${USER}/data/wordpress
all: voldir
voldir:
@if [ ! -f ./srcs/.env ]; then \
echo "[❌] .env file missing"; exit 1; \
fi
@echo "$(BLUE)"; cat ./tools/dockerart.txt; echo "$(DEF_COLOR)\n"
@if [ ! -d $(MDB_VOLUME) ]; then \
mkdir -p $(MDB_VOLUME); \
chmod -R 777 $(MDB_VOLUME); \
echo "$(YELLOW)local mariadb directory created.$(DEF_COLOR)"; \
fi
@if [ ! -d $(WP_VOLUME) ]; then \
mkdir -p $(WP_VOLUME); \
chmod -R 777 $(WP_VOLUME); \
echo "$(MAGENTA)local wordpress directory created.$(DEF_COLOR)"; \
fi
docker compose -f ./srcs/docker-compose.yaml up -d --build
@echo "$(GREEN)Build is complete. Service started.$(DEF_COLOR)"
build:
docker compose -f ./srcs/docker-compose.yaml build
@echo "$(CYAN)Built is complete. You may start service.$(DEF_COLOR)"
images:
@docker images
start: voldir
@docker compose -f ./srcs/docker-compose.yaml up -d
@echo "$(GREEN)Service is started.$(DEF_COLOR)"
stop:
@docker compose -f ./srcs/docker-compose.yaml stop
@echo "$(ORANGE)Service is stopped.$(DEF_COLOR)"
clean:
@docker compose -f ./srcs/docker-compose.yaml down
@echo "$(RED)Service was downed and removed.$(DEF_COLOR)"
fclean: clean
@sudo rm -rf $(PROJECT_DATA)
@echo "$(RED)All local data erased.$(DEF_COLOR)"
@if [ "$$(docker images -q)" != "" ]; then \
docker rmi -f $$(docker images -q); \
fi
@if [ "$$(docker volume ls -q)" != "" ]; then \
docker volume rm $$(docker volume ls -q); \
fi
docker network prune -f
docker system prune -af
docker image prune -a -f
fclean42: clean
@rm -rf $(PROJECT_DATA)
@echo "$(RED)All local data erased.$(DEF_COLOR)"
@if [ "$$(docker images -q)" != "" ]; then \
docker rmi -f $$(docker images -q); \
fi
@if [ "$$(docker volume ls -q)" != "" ]; then \
docker volume rm $$(docker volume ls -q); \
fi
docker network prune -f
docker system prune -af
docker image prune -a -f
stopcontainers:
@docker stop $$(docker ps -q)
re: fclean all
.phony: all build images start stop clean fclean re