-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
187 lines (162 loc) ยท 6.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
## Show this help
help:
echo "$(EMOJI_interrobang) Makefile version $(VERSION) help "
echo ''
echo 'About this help:'
echo ' Commands are ${BLUE}blue${RESET}'
echo ' Targets are ${YELLOW}yellow${RESET}'
echo ' Descriptions are ${GREEN}green${RESET}'
echo ''
echo 'Usage:'
echo ' ${BLUE}make${RESET} ${YELLOW}<target>${RESET}'
echo ''
echo 'Targets:'
awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")+1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-${TARGET_MAX_CHAR_NUM}s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## Stop all containers
stop:
echo "$(EMOJI_stop) Shutting down"
docker compose stop
sleep 0.4
docker compose down --remove-orphans
## Removes all containers and volumes
destroy: stop
echo "$(EMOJI_litter) Removing the project"
docker compose down -v --remove-orphans
## Starts docker compose up -d
start:
echo "$(EMOJI_up) Starting the docker project"
docker compose up -d --build
make urls
## Starts composer-install
composer:
echo "$(EMOJI_package) Installing composer dependencies"
docker compose exec php composer $(ARGS)
## Starts composer-install
composer-install:
echo "$(EMOJI_package) Installing composer dependencies"
docker compose exec php composer install
## Create necessary directories
create-dirs:
echo "$(EMOJI_dividers) Creating required directories"
## Starts composer-install
composer-install-production:
echo "$(EMOJI_package) Installing composer dependencies (without dev)"
docker compose exec php composer install --no-dev -ao
install-mkcert:
if [[ "$$OSTYPE" == "linux-gnu" ]]; then \
if [[ "$$(command -v certutil > /dev/null; echo $$?)" -ne 0 ]]; then sudo apt install libnss3-tools; fi; \
if [[ "$$(command -v mkcert > /dev/null; echo $$?)" -ne 0 ]]; then sudo curl -L https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-linux-amd64 -o /usr/local/bin/mkcert; sudo chmod +x /usr/local/bin/mkcert; fi; \
elif [[ "$$OSTYPE" == "darwin"* ]]; then \
BREW_LIST=$$(brew ls); \
if [[ ! $$BREW_LIST == *"mkcert"* ]]; then brew install mkcert; fi; \
if [[ ! $$BREW_LIST == *"nss"* ]]; then brew install nss; fi; \
fi;
mkcert -install > /dev/null
## Create SSL certificates for dinghy and starting project
create-certificate: install-mkcert
echo "$(EMOJI_secure) Creating SSL certificates for dinghy http proxy"
mkdir -p $(HOME)/.dinghy/certs/
PROJECT=$$(echo "$${PWD##*/}" | tr -d '.'); \
if [[ ! -f $(HOME)/.dinghy/certs/$$PROJECT.docker.key ]]; then mkcert -cert-file $(HOME)/.dinghy/certs/$$PROJECT.docker.crt -key-file $(HOME)/.dinghy/certs/$$PROJECT.docker.key "*.$$PROJECT.docker"; fi;
if [[ ! -f $(HOME)/.dinghy/certs/local.bluedist.com.key ]]; then mkcert -cert-file $(HOME)/.dinghy/certs/local.bluedist.com.crt -key-file $(HOME)/.dinghy/certs/local.bluedist.com.key local.bluedist.com; fi;
if [[ ! -f $(HOME)/.dinghy/certs/mail.local.bluedist.com.key ]]; then mkcert -cert-file $(HOME)/.dinghy/certs/mail.local.bluedist.com.crt -key-file $(HOME)/.dinghy/certs/mail.local.bluedist.com.key mail.local.bluedist.com; fi;
## Initialize the docker setup
init-docker: create-dirs create-certificate
echo "$(EMOJI_rocket) Initializing docker environment"
docker compose pull
docker compose up -d --build
## To start an existing project
install-project: stop add-hosts-entry init-docker composer-install
echo "---------------------"
echo ""
echo "The project is online $(EMOJI_thumbsup)"
echo ""
echo 'Stop the project with "make stop"'
echo ""
echo "---------------------"
make urls
## Print Project URIs
urls:
PROJECT=$$(echo "$${PWD##*/}" | tr -d '.'); \
SERVICES=$$(docker compose ps --services | grep '$(SERVICELIST)'); \
LONGEST=$$(($$(echo -e "$$SERVICES\nFrontend:" | wc -L 2> /dev/null || echo 15)+2)); \
echo "$(EMOJI_telescope) Project URLs:"; \
echo ''; \
printf " %-$${LONGEST}s %s\n" "Frontend:" "https://local.bluedist.com/"; \
printf " %-$${LONGEST}s %s\n" "Mailpit:" "https://mail.local.bluedist.com/"; \
for service in $$SERVICES; do \
printf " %-$${LONGEST}s %s\n" "$$service:" "https://$$service.$$PROJECT.docker/"; \
done;
## Create the hosts entry for the custom project URL (non-dinghy convention)
add-hosts-entry:
echo "$(EMOJI_monkey) Creating Hosts Entry (if not set yet)"
SERVICES=$$(command -v getent > /dev/null && echo "getent ahostsv4" || echo "dscacheutil -q host -a name"); \
if [ ! "$$($$SERVICES local.bluedist.com | grep 127.0.0.1 > /dev/null; echo $$?)" -eq 0 ]; then sudo bash -c 'echo "127.0.0.1 local.bluedist.com" >> /etc/hosts; echo "Entry was added"'; else echo 'Entry already exists'; fi; \
if [ ! "$$($$SERVICES mail.local.bluedist.com | grep 127.0.0.1 > /dev/null; echo $$?)" -eq 0 ]; then sudo bash -c 'echo "127.0.0.1 mail.local.bluedist.com" >> /etc/hosts; echo "Entry was added"'; else echo 'Entry already exists'; fi;
## Log into the PHP container
login-php:
echo "$(EMOJI_elephant) Logging into the PHP container"
docker compose exec php bash
## Log into the httpd container
login-httpd:
echo "$(EMOJI_helicopter) Logging into HTTPD Container"
docker compose exec httpd bash
# SETTINGS
TARGET_MAX_CHAR_NUM := 25
MAKEFLAGS += --silent
SHELL := /bin/bash
VERSION := 1.0.0
ARGS = $(filter-out $@,$(MAKECMDGOALS))
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
BLUE := $(shell tput -Txterm setaf 4)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
# EMOJIS (some are padded right with whitespace for text alignment)
EMOJI_litter := "๐ฎ๏ธ"
EMOJI_interrobang := "โ๏ธ "
EMOJI_floppy_disk := "๐พ๏ธ"
EMOJI_dividers := "๐๏ธ "
EMOJI_up := "๐๏ธ"
EMOJI_receive := "๐ฅ๏ธ"
EMOJI_robot := "๐ค๏ธ"
EMOJI_stop := "๐๏ธ"
EMOJI_package := "๐ฆ๏ธ"
EMOJI_secure := "๐๏ธ"
EMOJI_explodinghead := "๐คฏ๏ธ"
EMOJI_rocket := "๐๏ธ"
EMOJI_plug := "๐๏ธ"
EMOJI_leftright := "โ๏ธ "
EMOJI_upright := "โ๏ธ "
EMOJI_thumbsup := "๐๏ธ"
EMOJI_telescope := "๐ญ๏ธ"
EMOJI_monkey := "๐๏ธ"
EMOJI_elephant := "๐๏ธ"
EMOJI_dolphin := "๐ฌ๏ธ"
EMOJI_helicopter := "๐๏ธ"
EMOJI_broom := "๐งน"
EMOJI_nutandbolt := "๐ฉ"
EMOJI_controlknobs := "๐๏ธ"
%:
@:
cept-debug:
docker compose exec -e PHP_IDE_CONFIG="serverName=local.bluedist.com" php php -dxdebug.mode=debug -dxdebug.remote_autostart=1 -dxdebug.start_with_request=yes -dxdebug.remote_host=host.docker.internal ./vendor/bin/codecept run
cept-run:
docker compose exec php ./vendor/bin/codecept run
cept-run-unit:
docker compose exec php ./vendor/bin/codecept run unit --recurse-includes
cept-run-functional:
docker compose exec php ./vendor/bin/codecept run functional
cept-run-acceptance:
docker compose exec php ./vendor/bin/codecept run acceptance
cept-build:
docker compose exec php ./vendor/bin/codecept build