forked from revagomes/drupal-pece
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker.mk
76 lines (58 loc) · 2.76 KB
/
docker.mk
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
include .env
.PHONY: up down stop prune ps shell drush logs
default: up
DRUPAL_ROOT ?= /var/www/html/web
## help : Print commands help.
help : docker.mk
@sed -n 's/^##//p' $<
## up : Start up containers.
up:
@echo "Starting up containers for $(PROJECT_NAME)..."
docker-compose pull
docker-compose up -d --remove-orphans
## down : Stop containers.
down: stop
## start : Start containers without updating.
start:
@echo "Starting containers for $(PROJECT_NAME) from where you left off..."
@docker-compose start
## stop : Stop containers.
stop:
@echo "Stopping containers for $(PROJECT_NAME)..."
@docker-compose stop
## prune : Remove containers and their volumes.
## You can optionally pass an argument with the service name to prune single container
## prune mariadb : Prune `mariadb` container and remove its volumes.
## prune mariadb solr : Prune `mariadb` and `solr` containers and remove their volumes.
prune:
@echo "Removing containers for $(PROJECT_NAME)..."
@docker-compose down -v $(filter-out $@,$(MAKECMDGOALS))
## ps : List running containers.
ps:
@docker ps --filter name='$(PROJECT_NAME)*'
## shell : Access `php` container via shell.
shell:
docker exec -ti -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) $(shell docker ps --filter name='$(PROJECT_NAME)_php' --format "{{ .ID }}") sh
shell-node:
docker exec -ti --user root -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) $(shell docker ps --filter name='$(PROJECT_NAME)_front_node' --format "{{ .ID }}") sh
## drush : Executes `drush` command in a specified `DRUPAL_ROOT` directory (default is `/var/www/html/web`).
## Doesn't support --flag arguments.
drush:
docker exec -it $(shell docker ps --filter name='^/$(PROJECT_NAME)_php' --format "{{ .ID }}") drush -r $(DRUPAL_ROOT) $(filter-out $@,$(MAKECMDGOALS))
## drupal : Executes Drupal Console command in a specified `DRUPAL_ROOT` directory (default is `/var/www/html/web`).
## Doesn't support --flag arguments unless command is wrapped by quotes.
drupal:
docker exec -it $(shell docker ps --filter name='^/$(PROJECT_NAME)_php' --format "{{ .ID }}") vendor/bin/drupal --root=$(DRUPAL_ROOT) $(filter-out $@,$(MAKECMDGOALS))
## exec : Executes any command in PHP container WORKDIR (default is `/var/www/html`).
## Doesn't support --flag arguments unless command is wrapped by quotes.
exec:
docker exec -it $(shell docker ps --filter name='^/$(PROJECT_NAME)_php' --format "{{ .ID }}") $(filter-out $@,$(MAKECMDGOALS))
## logs : View containers logs.
## You can optinally pass an argument with the service name to limit logs
## logs php : View `php` container logs.
## logs nginx php : View `nginx` and `php` containers logs.
logs:
@docker-compose logs -f $(filter-out $@,$(MAKECMDGOALS))
# https://stackoverflow.com/a/6273809/1826109
%:
@: