-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Makefile
107 lines (88 loc) · 2.64 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
SHELL=bash
COMPOSE = docker compose
PHP = $(COMPOSE) exec app
CONSOLE = $(PHP) bin/console
# Helper variables
_TITLE := "\033[32m[%s]\033[0m %s\n" # Green text
_ERROR := "\033[31m[%s]\033[0m %s\n" # Red text
##
## This Makefile is used for *local development* only.
## Production or deployment should be handled following GLPI's documentation.
##
.DEFAULT_GOAL := help
help: ## Show this help message
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-25s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
.PHONY: help
install: .env build start vendor db test-db ## Install the project
.PHONY: install
.env:
@\
if [ ! -f ".devcontainer/docker-compose.override.yaml" ]; then \
printf $(_TITLE) "Project" "Creating \".devcontainer/docker-compose.override.yaml\" file for Docker Compose" ; \
touch .devcontainer/docker-compose.override.yaml ; \
fi ; \
if [ ! -f ".env" ]; then \
printf $(_TITLE) "Project" "Creating \".env\" file for Docker Compose" ; \
touch .env ; \
fi ; \
if grep -q COMPOSE_FILE ".env"; then \
printf $(_TITLE) "Project" "\".env\" file is already populated" ; \
else \
printf $(_TITLE) "Project" "Writing config to \".env\" file" ; \
echo "COMPOSE_FILE=./.devcontainer/docker-compose.yaml:./.devcontainer/docker-compose.override.yaml" >> .env ; \
fi
.PHONY: .env
build: ## Build the Docker images
@printf $(_TITLE) "Project" "Pulling Docker images" \
@$(COMPOSE) pull
@$(COMPOSE) build
.PHONY: build
start: ## Start all containers
@$(COMPOSE) up -d --remove-orphans
.PHONY: start
stop: ## Stop all containers
@$(COMPOSE) stop
.PHONY: stop
restart: ## Restart the containers & the PHP server
@$(MAKE) stop
@$(MAKE) start
.PHONY: restart
vendor: ## Install Composer dependencies
@$(CONSOLE) dependencies install
.PHONY: vendor
locales: ## Compile locales
@$(CONSOLE) locales:compile
.PHONY: locales
kill: ## Stop and remove all containers
@$(DOCKER_COMPOSE) kill
@$(DOCKER_COMPOSE) down --volumes --remove-orphans
.PHONY: kill
reset: ## Reset and start a fresh install of the project
reset: kill install
.PHONY: reset
db: ## Install local development's database
@$(CONSOLE) database:install \
-r -f \
--db-host=db \
--db-port=3306 \
--db-name=glpi \
--db-user=root \
--db-password=glpi \
--no-interaction \
--no-telemetry
.PHONY: db
test-db: ## Install automated testing's database
@$(CONSOLE) database:install \
-r -f \
--db-host=db \
--db-port=3306 \
--db-name=glpi_test \
--db-user=root \
--db-password=glpi \
--no-interaction \
--no-telemetry \
--env=testing
.PHONY: test-db
cc: ## Clear the cache
@$(CONSOLE) cache:clear
.PHONY: cc