-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (52 loc) · 1.71 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
CWD := ${PWD}/srcs
REQUIREMENTS := $(CWD)/requirements
DB_VOLUME := ${HOME}/data/mariadb
WP_VOLUME := ${HOME}/data/wordpress
CERTS_PATH := $(REQUIREMENTS)/nginx/conf/certs
DOTENV_PATH := $(CWD)/.env
GEN_CERTS := $(REQUIREMENTS)/tools/make_certs.sh
# COMMANDS
DOCKER_COMPOSE := docker-compose -f $(CWD)/docker-compose.yml
RMDIR := rm -fr
MKDIR := mkdir -p
.DEFAULT_GOAL := help
$(shell $(MKDIR) $(DB_VOLUME) $(WP_VOLUME))
.PHONY: setup
setup:
@if [ ! -f $(DOTENV_PATH) ]; then \
cp $(CWD)/.env.example $(DOTENV_PATH) && \
echo ".env file not found. Created .env from .env.example."; \
fi
@if [ ! -d $(CERTS_PATH) ]; then \
echo "ssl certificates not found in $(CERTS_PATH), generating self signed certificates..."; \
bash $(GEN_CERTS) $(CERTS_PATH) > /dev/null 2>&1; \
fi
.PHONY: up
up: setup
@$(DOCKER_COMPOSE) up --build -d
.PHONY: down
down:
@$(DOCKER_COMPOSE) down
.PHONY: status
status:
@$(DOCKER_COMPOSE) ps
.PHONY: logs
logs:
@$(DOCKER_COMPOSE) logs
.PHONY: clean
clean:
@$(DOCKER_COMPOSE) down -v
@$(RMDIR) $(WP_VOLUME) $(DB_VOLUME)
.PHONY: prune
prune: clean
@docker system prune -af --volumes
.PHONY: help
help:
@echo "setup : Prepares the environment by creating necessary files and directories."
@echo "up : Builds and starts the Docker containers."
@echo "down : Stops and removes the Docker containers."
@echo "status: Displays the status of the Docker containers."
@echo "logs : Shows the logs of the Docker containers."
@echo "clean : Removes containers and associated data volumes."
@echo "prune : Removes all unused Docker data, including volumes."
@echo "help : Displays this help message."