-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
144 lines (120 loc) · 6.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
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
140
141
142
143
144
# Makefile for Drupal 8 skeleton docker.
include .env
help:
@echo "\n${ORANGE}usage: make ${BLUE}COMMAND${NC}"
@echo "\n${YELLOW}Commands:${NC}"
@echo " ${BLUE}code-sniff : ${LIGHT_BLUE}Check the API with PHP Code Sniffer (Drupal Standards).${NC}"
@echo " ${BLUE}clean : ${LIGHT_BLUE}Clean directories for reset.${NC}"
@echo " ${BLUE}c-install : ${LIGHT_BLUE}Install PHP/Drupal dependencies with composer.${NC}"
@echo " ${BLUE}c-update : ${LIGHT_BLUE}Update PHP/Drupal dependencies with composer.${NC}"
@echo " ${BLUE}clean-drupal-config : ${LIGHT_BLUE}Delete exported configuration from project.${NC}"
@echo " ${BLUE}docker-start : ${LIGHT_BLUE}Create and start containers.${NC}"
@echo " ${BLUE}docker-stop : ${LIGHT_BLUE}Stop and clear all services.${NC}"
@echo " ${BLUE}gen-certs : ${LIGHT_BLUE}Generate SSL certificates.${NC}"
@echo " ${BLUE}logs : ${LIGHT_BLUE}Follow log output.${NC}"
@echo " ${BLUE}mysql-dump : ${LIGHT_BLUE}Create backup of all databases.${NC}"
@echo " ${BLUE}mysql-restore : ${LIGHT_BLUE}Restore backup of all databases.${NC}"
@echo "\n${YELLOW}Tests commands:${NC}"
@echo " ${BLUE}test : ${LIGHT_BLUE}Test all application (custom and contribution modules).${NC}"
@echo " ${BLUE}test-contrib : ${LIGHT_BLUE}Test Drupal contributor modules.${NC}"
@echo " ${BLUE}test-custom-modules : ${LIGHT_BLUE}Test Drupal custom modules.${NC}"
@echo "\n${YELLOW}Drupal specific commands:${NC}"
@echo "${RED}Important: All ${BLUE}COMMAND${NC} import automatically your \`sync\` exported configuration. You can specify another configuration to install/update/export ${YELLOW}\`eg: make ${BLUE}COMMAND${NC} my_config_name\`.${NC}"
@echo " ${BLUE}drupal-si : ${LIGHT_BLUE}Install new Drupal instance and drop database.${NC}"
@echo " ${BLUE}drupal-update : ${LIGHT_BLUE}Update your current Drupal instance and (re)import your \`/config\` exported configuration.${NC}"
@echo " ${BLUE}drupal-config-export : ${LIGHT_BLUE}Export your current Drupal instance from \`/config\` by default. That can be in sub-folder depend your custom changes.${NC}"
@echo "\n${YELLOW}Drush specific commands:${NC}"
@echo " ${BLUE}drush : ${LIGHT_BLUE}Execute the given command from arguments ${YELLOW}\`eg: make drush command=cr\` .${NC}"
@echo " ${BLUE}drupal-clear-all-caches : ${LIGHT_BLUE}Flush all caches from Drupal App.${NC}"
init:
@echo "${BLUE}Project configuration initialization:${NC}"
@$(shell cp -n $(shell pwd)/docker-compose.yml.dist $(shell pwd)/docker-compose.yml 2> /dev/null)
@$(shell cp -n $(shell pwd)/composer.json.dist $(shell pwd)/composer.json 2> /dev/null)
@$(shell cp -n $(shell pwd)/composer.required.json.dist $(shell pwd)/composer.required.json 2> /dev/null)
@$(shell cp -n $(shell pwd)/composer.suggested.json.dist $(shell pwd)/composer.suggested.json 2> /dev/null)
@$(shell cp -n $(shell pwd)/settings/settings.local.php.dist $(shell pwd)/settings/settings.local.php 2> /dev/null)
@$(shell cp -n $(shell pwd)/settings/development.services.yml.dist $(shell pwd)/settings/development.services.yml 2> /dev/null)
@$(shell cp -n $(shell pwd)/settings/phpunit.xml.dist $(shell pwd)/settings/phpunit.xml 2> /dev/null)
clean:
@echo "${BLUE}Clean directories:${NC}"
@rm -Rf data/db/mysql/*
@rm -Rf $(MYSQL_DUMPS_DIR)/*
@rm -Rf vendor/
@rm -Rf composer.lock
@rm -Rf settings/settings.local.php
@rm -Rf settings/development.services.yml
@rm -Rf settings/phpunit.xml
@rm -Rf report
@rm -Rf web/
@rm -Rf etc/ssl/*
@rm -Rf bin/
@rm -Rf app/Drupal/parameters.yml
@rm -Rf composer.required.json
@rm -Rf composer.suggested.json
@rm -Rf composer.json
@rm -Rf docker-compose.yml
clean-drupal-config:
@echo "${RED}Clean exported config directories:${NC}"
@rm -Rf config/*
code-sniff:
@echo "${BLUE}Check your Drupal project with PHP Code Sniffer:${NC}"
@docker-compose exec -T php composer phpcs $(path)
c-update:
@echo "${BLUE}Updating your application dependencies:${NC}"
@docker-compose exec -T php composer update
c-install:
@echo "${BLUE}Installing your application dependencies:${NC}"
@docker-compose exec -T php composer install
@echo "\n${BLUE}Initialize phpunit Drupal Core file:${NC}"
@$(shell cp -n $(shell pwd)/settings/phpunit.xml $(shell pwd)/web/core/phpunit.xml 2> /dev/null)
drupal-si:
@echo "${BLUE}Installing your Drupal Application:${NC}"
# Restart PHP-FPM to avoid caches of container if you change ENV variables.
@docker-compose up -d php
@docker-compose exec -T php composer site-install
drush:
@echo "${BLUE}Perform Drush [$(command)] command:${NC}"
@docker-compose exec -T php bin/drush -r=/web $(command)
drupal-clear-all-caches:
@echo "${BLUE}Clearings all Drupal caches:${NC}"
@docker-compose exec -T php bin/drush -r=/web cr
drupal-update:
@echo "${BLUE}Updating your Drupal Application:${NC}"
# Restart PHP-FPM to avoid caches of container if you change ENV variables.
@docker-compose up -d php
@docker-compose exec -T php composer site-update
drupal-config-export:
@echo "${BLUE}Export of your Drupal configuration:${NC}"
@docker-compose exec -T php composer export-conf
docker-start: init gen-certs
@echo "${BLUE}Starting all containers:${NC}"
@docker-compose up -d
@make c-install
docker-stop:
@echo "${BLUE}Stopping all containers:${NC}"
@docker-compose down -v
@make clean
gen-certs:
@echo "${BLUE}SSL certificate generation:${NC}"
@docker run --rm -v $(shell pwd)/etc/ssl:/certificates -e "SERVER=$(NGINX_HOST)" jacoelho/generate-certificate
logs:
@docker-compose logs -f
mysql-dump:
@echo "${BLUE}Dump of all database:${NC}"
@mkdir -p $(MYSQL_DUMPS_DIR)
@docker exec $(shell docker-compose ps -q mysqldb) mysqldump --all-databases -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" > $(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null
@make resetOwner
mysql-restore:
@echo "${BLUE}Restore all database:${NC}"
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < $(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null
test: test-contrib test-custom-modules
@make resetOwner
test-contrib:
@echo "${LIGHT_BLUE}Lets go to test installed contributor modules."
@docker-compose exec -T php bin/phpunit -c ./web/core ./web/modules/contrib/ --colors=always
test-custom-modules:
@echo "${LIGHT_BLUE}Lets go to test custom modules."
@docker-compose exec -T php bin/phpunit -c ./web/core ./web/modules/custom/ --colors=always
resetOwner:
@$(shell chown -Rf $(SUDO_USER):$(shell id -g -n $(SUDO_USER)) $(MYSQL_DUMPS_DIR) "$(shell pwd)/etc/ssl" "$(shell pwd)/web" 2> /dev/null)
.PHONY: clean test code-sniff init clean-drupal-config