-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
115 lines (95 loc) · 2.83 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
# SETTINGS #
MAKEFLAGS += --silent
NAME = transcendence
VOLUME = transcendence_postgres
DOCKER_COMPOSE = ./docker-compose.yml
#------------------------------------------------------------------------------#
# Basic rules #
all: build attach
.PHONY: all
$(NAME): all
.PHONY: $(NAME)
# Managing rules #
down:
echo -n "Removing '$(NAME)' containers...\n"
docker compose -f $(DOCKER_COMPOSE) down
.PHONY: down
up:
echo -n "Starting '$(NAME)' containers...\n"
docker compose -f $(DOCKER_COMPOSE) up -d
.PHONY: up
attach:
echo -n "Attaching '$(NAME)' containers...\n"
docker compose -f $(DOCKER_COMPOSE) up
.PHONY: attach
stop:
echo -n "Stopping '$(NAME)' containers...\n"
docker compose -f $(DOCKER_COMPOSE) stop
.PHONY: stop
start: up
.PHONY: start
restart: stop start
.PHONY: restart
ps:
docker compose -f $(DOCKER_COMPOSE) ps
.PHONY: ps
frontend:
echo -n "Connecting to '$@' containers...\n"
docker container exec -it $@ sh
.PHONY: frontend
backend:
echo -n "Connecting to '$@' containers...\n"
docker container exec -it $@ sh
.PHONY: backend
postgresql:
echo -n "Connecting to '$@' containers...\n"
docker container exec -it $@ sh
.PHONY: postgresql
db:
docker start postgresql
# Building rules #
build:
echo -n "Building '$(NAME)' images...\n"
docker compose -f $(DOCKER_COMPOSE) build
.PHONY: build
rebuild: down
echo -n "Rebuilding '$(NAME)' images...\n"
docker compose -f $(DOCKER_COMPOSE) build --no-cache
.PHONY: rebuild
re: rebuild up
.PHONY: re
# Cleaning rules #
clean:
docker compose -f $(DOCKER_COMPOSE) rm -f -s
echo -n "🗑️ '$(NAME)' has been deleted.\n"
.PHONY: clean
fclean: clean
echo -n "Warning ! You are going to delete $(VOLUME), are you sure to continue ? [y/N]\n"
read choice; \
if [ "$$choice" = "y" ]; then \
docker volume rm $(VOLUME); \
echo -n "🗑️ '$(VOLUME)' has been deleted.\n"; \
else \
echo -n "Abord.\n"; \
fi
.PHONY: fclean
purge: clean
echo -n "Warning ! You are going to delete every docker container and image on your pc, are you sure to continue ? [y/N]\n"
read choice; \
if [ "$$choice" = "y" ]; then \
docker stop $$(docker ps -a -q) 2>/dev/null; \
docker rm $$(docker ps -a -q) 2>/dev/null; \
docker rmi $$(docker images -q) 2>/dev/null; \
docker builder prune -a -f 2>/dev/null; \
echo -n "🗑️ 'Builder cache' has been deleted.\n"; \
docker buildx prune -a -f 2>/dev/null; \
echo -n "🗑️ 'Buildx cache' has been deleted.\n"; \
docker builder prune -a -f 2>/dev/null; \
docker volume rm $$(docker volume ls -q) 2>/dev/null; \
echo -n "🗑️ 'Docker volumes' has been deleted.\n"; \
docker network rm $$(docker network ls) 2>/dev/null; \
docker system prune -a --volumes 2>/dev/null; \
else \
echo -n "Abord.\n"; \
fi
.PHONY: purge