forked from nanoninja/docker-nginx-php-mysql
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
83 lines (65 loc) · 2.62 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
# Makefile for Docker Nginx PHP Composer MySQL
include .env
# MySQL
MYSQL_DUMPS_DIR=data/db/dumps
help:
@echo ""
@echo "usage: make COMMAND"
@echo ""
@echo "Commands:"
@echo " apidoc Generate documentation of API"
@echo " code-sniff Check the API with PHP Code Sniffer (PSR2)"
@echo " clean Clean directories for reset"
@echo " composer-up Update PHP dependencies with composer"
@echo " docker-start Create and start containers"
@echo " docker-stop Stop and clear all services"
@echo " gen-certs Generate SSL certificates"
@echo " logs Follow log output"
@echo " mysql-dump Create backup of all databases"
@echo " mysql-restore Restore backup of all databases"
@echo " phpmd Analyse the API with PHP Mess Detector"
@echo " test Test application"
init:
@$(shell cp -n $(shell pwd)/web/app/composer.json.dist $(shell pwd)/web/app/composer.json 2> /dev/null)
apidoc:
@docker-compose exec -T php php -d memory_limit=256M -d xdebug.profiler_enable=0 ./app/vendor/bin/apigen generate app/src --destination app/doc
@make resetOwner
clean:
@rm -Rf data/db/mysql/*
@rm -Rf $(MYSQL_DUMPS_DIR)/*
@rm -Rf web/app/vendor
@rm -Rf web/app/composer.lock
@rm -Rf web/app/doc
@rm -Rf web/app/report
@rm -Rf etc/ssl/*
code-sniff:
@echo "Checking the standard code..."
@docker-compose exec -T php ./app/vendor/bin/phpcs -v --standard=PSR2 app/src
composer-up:
@docker run --rm -v $(shell pwd)/web/app:/app composer update
docker-start: init
docker-compose up -d
docker-stop:
@docker-compose down -v
@make clean
gen-certs:
@docker run --rm -v $(shell pwd)/etc/ssl:/certificates -e "SERVER=$(NGINX_HOST)" jacoelho/generate-certificate
logs:
@docker-compose logs -f
mysql-dump:
@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:
@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
phpmd:
@docker-compose exec -T php \
./app/vendor/bin/phpmd \
./app/src \
text cleancode,codesize,controversial,design,naming,unusedcode
test: code-sniff
@docker-compose exec -T php ./app/vendor/bin/phpunit --colors=always --configuration ./app/
@make resetOwner
resetOwner:
@$(shell chown -Rf $(SUDO_USER):$(shell id -g -n $(SUDO_USER)) $(MYSQL_DUMPS_DIR) "$(shell pwd)/etc/ssl" "$(shell pwd)/web/app" 2> /dev/null)
.PHONY: clean test code-sniff init