-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
139 lines (105 loc) · 3.12 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
#---- Makefile --------------------------------------------------------#
#---- variables -------------------------------------------------------#
include .env
ENV_FILE = .env
DJANGO_CTT = alfred coubertin cupidon hermes ludo \
mnemosine petrus
#---- docker commands -------------------------------------------------#
WHO = $(shell whoami)
ifeq ($(WHO), bpoumeau)
DOCKER_FILE = docker-compose-nologs.yml
else ifeq ($(WHO), ccrottie)
DOCKER_FILE = docker-compose-nologs.yml
else ifeq ($(WHO), hgeffroy)
DOCKER_FILE = docker-compose-nologs.yml
else
DOCKER_FILE = docker-compose.yml
endif
COMPOSE = docker compose
COMPOSE_F = docker compose -f
STOP = docker compose stop
RM = docker compose rm
RM_IMG = docker rmi
VOLUME = docker volume
NETWORK = docker network
SYSTEM = docker system
#---- rules -----------------------------------------------------------#
#---- base ----#
debug: | copyfile tutum
. ./tools/init.sh
all: | copyfile tutum
. ./tools/init.sh
up: | copyfile tutum
$(COMPOSE_F) $(DOCKER_FILE) --env-file $(ENV_FILE) up -d
ifeq ($(CI), ci)
build: | copyfile
$(COMPOSE_F) $(DOCKER_FILE) --env-file $(ENV_FILE) build
else
build: | copyfile
$(COMPOSE_F) $(DOCKER_FILE) --env-file $(ENV_FILE) build
endif
#---- build rules ----#
build_parallel:
$(COMPOSE) build --parallel
watch:
$(COMPOSE) watch
dry_run:
$(COMPOSE) --dry-run up --build -d
#---- stop rules ----#
down:
$(COMPOSE) down
down_restart:
$(COMPOSE) down -v
restart:
$(COMPOSE) restart
kill:
$(COMPOSE) kill
reset: | fclean
make debug
#---- debug rules ----#
logs:
mkdir -p zelk
docker logs $(container) > zelk/$(container)
#---- setups ----#
copyfile:
./tools/copyfile.sh $(DJANGO_CTT)
tutum:
$(COMPOSE_F) $(DOCKER_FILE) up -d tutum
#---- clean ----#
# - Stops all running containers
# - Removes all stopped containers
# - Stops Docker Compose services
# - Cleans specific directories and files (migrations, tokens, vault)
clean: | down
docker stop $$(docker ps -qa) || true
docker rm $$(docker ps -qa) || true
$(COMPOSE) stop || true
rm -rf `find . | grep migrations | grep -v env` || true
# - Completely removes Docker Compose services, including images, volumes, and orphans
# - Removes all Docker images
# - Removes all Docker volumes
# - Removes all Docker networks
# - Cleans the specified volume path
fclean: | clean
$(COMPOSE) down --rmi all --volumes --remove-orphans || true
docker rmi $$(docker images -q) || true
docker volume rm $$(docker volume ls -q) || true
docker network rm $$(docker network ls -q) 2>/dev/null || true
./pass.sh
# - Removes all unused Docker data, including images, containers, volumes, and networks
prune: | fclean
docker system prune -af || true
docker volume prune -af || true
db_suppr:
rm -rf `find . | grep db.sqlite3`
db_reset: db_suppr copyfile
#---- re ----#
re: | down
make all
# pour la prod: remettre up
#---- settings --------------------------------------------------------#
.SILENT:
.DEFAULT: all
.PHONY: all up build down build_parallel down_restart restart kill \
reset copyfile modsec tutum test clean fclean prune db_suppr \
db_reset re