-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (73 loc) · 2.82 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
include .env
default: up
COMPOSER_ROOT ?= /var/www/html
DRUPAL_ROOT ?= /var/www/html/web
## help : Print commands help.
.PHONY: help
ifneq (,$(wildcard docker.mk))
help : docker.mk
@sed -n 's/^##//p' $<
else
help : Makefile
@sed -n 's/^##//p' $<
endif
## up : Pull new images and start up containers (won't prune old ones).
.PHONY: up
up:
@echo "Starting up containers for $(PROJECT_NAME)..."
docker-compose pull
docker-compose up -d --remove-orphans
docker cp $(APACHE_CONFIG) $(PROJECT_NAME)_web:/etc/apache2/sites-available/000-default.conf
docker-compose stop
docker-compose start
docker exec -it $(PROJECT_NAME)_node bash -c "npm install -g webpack-cli"
@printf "\n\nIf this is a fresh launch, run 'make db-init'..."
@printf "\n\nLoad the DB with: zcat prod-DB_FILENAME.sql.gz | mysql -u drupal -pdrupal -h db drupal\n\n"
## down : Stop containers (won't prune).
.PHONY: down
down: stop
## start : Start existing containers without updating.
.PHONY: start
start:
@echo "Starting containers for $(PROJECT_NAME) from where you left off..."
@docker-compose start
## stop : Stop containers (won't prune).
.PHONY: stop
stop:
@echo "Stopping containers for $(PROJECT_NAME)..."
@docker-compose stop
## prune : Remove containers and their volumes (DB will be lost!).
## 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.
.PHONY: prune
prune:
@echo "Removing containers for $(PROJECT_NAME)..."
@docker-compose down -v $(filter-out $@,$(MAKECMDGOALS))
## ps : List running containers.
.PHONY: ps
ps:
@docker ps --filter name='$(PROJECT_NAME)*'
## shell : Access `web` container via shell.
.PHONY: shell
shell:
docker exec -ti $(PROJECT_NAME)_web bash
## shell-node : Access `node` container via shell..
.PHONY: shell-node
shell-node:
docker exec -it $(PROJECT_NAME)_node bash
## shell-db : Access `db` container via shell..
.PHONY: shell-db
shell-db:
docker exec -it $(PROJECT_NAME)_db bash -c "mysql -u $(MYSQL_USER) -p$(MYSQL_PW) $(MYSQL_DB)"
## root-shell-web : Access `web` container via ROOT shell.
.PHONY: root-shell-web
root-shell-web:
docker exec -u0 -ti $(PROJECT_NAME)_web bash
## hsa-init : Custom INIT tasks specific to a given site.
.PHONY: db-init
hsa-init:
@echo "Initializing Database and User for $(PROJECT_NAME)..."
docker exec -it $(PROJECT_NAME)_db bash -c "mysql -u drupal -pdrupal -e \"SELECT * from variable where name like '%memcache%';\" drupal"
docker exec -it $(PROJECT_NAME)_db bash -c "mysql -u drupal -pdrupal -e \"DELETE FROM variable where name like '%memcache%';\" drupal"
docker exec -it $(PROJECT_NAME)_db bash -c "mysql -u drupal -pdrupal -e \"SELECT * from variable where name like '%memcache%';\" drupal"