-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
93 lines (81 loc) · 2.74 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
# ----------------
# Make help script
# ----------------
# Usage:
# Add help text after target name starting with '\#\#'
# A category can be added with @category. Team defaults:
# dev-environment
# docker
# test
# Output colors
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
DRUSH = docker-compose run --rm drush
COMPOSER = docker run --rm -v ${PWD}/.composer-tmp:/tmp -v ${PWD}:/app llt104/composer:1.8-php7.3
# Script
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
print "usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; }
help:
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
initialize: composer-install ## Initialize local environment.
@echo "> Setting up the Drupal site. Any existing database data will be removed."
@if [ ! -f "docroot/sites/default/settings.local.php" ]; then \
echo "> Copying settings.local.php into ./docroot/sites/default/."; \
cp ./build/settings.local.php ./web/sites/default/settings.local.php; \
fi
@if [ ! -f ".env" ]; then \
echo "> Copying env into .env."; \
cp ./build/env .env; \
fi
@echo "> Starting containers."
@docker-compose up -d --build
@echo "Waiting for database connection to be established."
@while ! docker-compose exec -T db mysqladmin -hlocalhost -u${MYSQL_USER} -p${MYSQL_PASSWORD} ping --silent &> /dev/null ; do \
echo "> ..."; \
sleep 2; \
done
@if [ ! -f "build/ref_db/dcc.sql.gz" ]; then \
echo "> [WARNING] Database dump not found. You might want to import an existing database."; \
else \
make db-import; \
fi
@echo "> Successfully finished setting up!"
up: ## Start containers.
@echo "> Starting containers."
@docker-compose up -d
stop: ## Stop containers.
@echo "> Stopping containers."
@docker-compose stop
db-import: db-drop ## Import the database.
@echo "> Importing the database."
@sleep 3
@if command -v pv >/dev/null; then \
pv ./build/ref_db/dcc.sql.gz | zcat | $(DRUSH) sqlc; \
else \
gunzip -c ./build/ref_db/dcc.sql.gz | $(DRUSH) sqlc; \
fi
db-drop: ## Drop the database.
@echo "> Dropping the database in 3 seconds. Use Control+C to abort."
@sleep 3
@$(DRUSH) sql-drop -y
@echo "> Successfully dropped the database."
composer-install: ## Runs `composer install`
@echo "> Running \"composer install\"."
@$(COMPOSER) install
site-update: ## Runs the normal Drupal site build commands.
@$(COMPOSER) install
@$(DRUSH) cr
@$(DRUSH) cim -y
@$(DRUSH) updb -y
@$(DRUSH) cr