-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
198 lines (164 loc) · 6.11 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
188
189
190
191
192
193
194
195
196
197
198
include .env
DOCKER_COMPOSE ?= docker compose
DOCKER_CMD ?= exec
## default : Run `make` without parameters to create the dist build from scratch.
default: .env up-dist
$(DOCKER_COMPOSE) $(DOCKER_CMD) dist bash -c "drush uli"
## help : Print commands help.
.PHONY: help
help : Makefile
@sed -n 's/^##//p' $<
# Files to make
.env:
cp .env.dist .env
docker-compose.override.yml:
cp docker-compose.yml docker-compose.override.yml
# Build tasks for development.
## build : Build the development environment.
.PHONY: build build/composer
build: .env build/composer
build/composer:
@echo "Building $(PROJECT_NAME) project development environment..."
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev bash -c "composer install"
# Install test site.
## build : Build the development environment.
.PHONY: install
install: build
@echo "Installing $(PROJECT_NAME)..."
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev bash -c "./vendor/bin/run drupal:site-install"
@$(DOCKER_COMPOSE) up -d --remove-orphans node
@$(MAKE) --no-print-directory theme-build
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev bash -c "drush uli"
# Build tasks for development.
## build-dev : Build the Docker image.
.PHONY: build-dev
build-dev:
@echo "Building $(PROJECT_NAME) dev Docker image..."
$(DOCKER_COMPOSE) build --no-cache dev
$(DOCKER_COMPOSE) up -d
# Build tasks for development.
## build-dist : Build the Docker image.
.PHONY: build-dist
build-dist:
@echo "Building $(PROJECT_NAME) dist Docker image..."
$(DOCKER_COMPOSE) build --no-cache dist
$(DOCKER_COMPOSE) up -d
.PHONY: release
release: docker-compose.override.yml up-dev build
@echo Building release artifact...
$(DOCKER_COMPOSE) exec -T dev ./vendor/bin/run release:ca --tag=$(RELEASE_TAG) --zip
## up : Start up containers.
.PHONY: up
up: .env
@echo "Starting up containers for $(PROJECT_NAME)..."
@$(DOCKER_COMPOSE) up -d --remove-orphans
## up-dev : Start dev container.
.PHONY: up-dev
up-dev: .env
@echo "Starting dev container for $(PROJECT_NAME)..."
@$(DOCKER_COMPOSE) up -d --remove-orphans dev
## up-dist : Start dist container.
.PHONY: up-dist
up-dist: .env
@echo "Starting dist container for $(PROJECT_NAME)..."
@$(DOCKER_COMPOSE) up -d --remove-orphans dist
## down : Stop containers.
.PHONY: down
down: stop
## start : Start containers without updating.
.PHONY: start
start:
@echo "Starting containers for $(PROJECT_NAME) from where you left off..."
@$(DOCKER_COMPOSE) start
.PHONY: stop
stop:
@echo "Stopping containers for $(PROJECT_NAME)..."
@$(DOCKER_COMPOSE) stop
## pull : Pull containers.
.PHONY: pull
pull:
@echo "Pulling containers..."
@$(DOCKER_COMPOSE) pull
## shell : Access a container via shell.
## The container to be accessed must be passed as argument (without argument the 'dev' container will be accessed by default, if active)
.PHONY: shell
shell:
docker exec -ti -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) $(shell docker ps --filter name='$(PROJECT_NAME)_$(or $(filter-out $@,$(MAKECMDGOALS)), 'dev')' --format "{{ .ID }}") bash
## shell-dev : Access `dev` container via shell.
.PHONY: shell-dev
shell-dev:
@$(MAKE) --no-print-directory shell dev
## shell-dist : Access `dist` container via shell.
.PHONY: shell-dist
shell-dist:
@$(MAKE) --no-print-directory shell dist
## shell-node : Access `node` container via shell.
.PHONY: shell-node
shell-node:
@$(MAKE) --no-print-directory shell node
## logs : View containers logs.
## You can optionally pass an argument with the service name to limit logs
## logs dev : View `dev` container logs.
## logs nginx dev : View `nginx` and `dev` containers logs.
.PHONY: logs
logs:
@$(DOCKER_COMPOSE) logs -f $(filter-out $@,$(MAKECMDGOALS))
# Shortcuts for developers not using docker-relay. See https://github.com/bircher/docker-relay
## composer : Executes `composer` command.
## To use "--flag" arguments include them in quotation marks.
## For example: make composer "update drupal/core --with-dependencies"
.PHONY: composer
composer:
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev composer $(filter-out $@,$(MAKECMDGOALS))
## drush : Executes `drush` command.
## To use "--flag" arguments include them in quotation marks.
## For example: make drush "watchdog:show --type=cron"
.PHONY: drush
drush:
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev vendor/bin/drush $(filter-out $@,$(MAKECMDGOALS))
## fix-perms : Fix files permissions
.PHONY: fix-perms
fix-perms:
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev vendor/bin/run drupal:fix-perms
## cr : Clears the Drupal cache.
.PHONY: cr
cr:
@$(MAKE) --no-print-directory drush cache-rebuild
## phpunit : Runs phpunit tests.
.PHONY: phpunit
phpunit:
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev bash -c "vendor/bin/phpunit" $(filter-out $@,$(MAKECMDGOALS))
## twig-debug-on : Enable Twig debug.
.PHONY: twig-debug-on
twig-debug-on:
@echo "Enabling Twig debug for $(PROJECT_NAME)..."
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev drush twig:debug on
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev drush state:set disable_rendered_output_cache_bins 1 --input-format=integer
@$(MAKE) --no-print-directory cr
## twig-debug-off : Disable Twig debug.
.PHONY: twig-debug-off
twig-debug-off:
@echo "Disabling Twig debug for $(PROJECT_NAME)..."
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev drush twig:debug off
$(DOCKER_COMPOSE) $(DOCKER_CMD) dev drush state:set disable_rendered_output_cache_bins 0 --input-format=integer
@$(MAKE) --no-print-directory cr
## theme-dev : Launch the watcher for theme development.
.PHONY: theme-dev
theme-dev:
@echo "Launch the watcher for $(PROJECT_NAME) theme development..."
@$(DOCKER_COMPOSE) $(DOCKER_CMD) node npm run theme:dev
## theme-build : Compile a development version of the theme for debug purposes.
.PHONY: theme-build
theme-build:
@echo "Compile a development version of $(PROJECT_NAME) theme for debug purposes..."
@$(DOCKER_COMPOSE) $(DOCKER_CMD) node npm run theme:build
@$(MAKE) --no-print-directory cr
## theme-prod : Compile and optimize a production-ready theme.
.PHONY: theme-prod
theme-prod:
@echo "Compile and optimize a production-ready theme for $(PROJECT_NAME)..."
@$(DOCKER_COMPOSE) $(DOCKER_CMD) node npm run theme:prod
@$(MAKE) --no-print-directory cr
# https://stackoverflow.com/a/6273809/1826109
%:
@: