-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
134 lines (96 loc) · 4.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
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
#!/bin/bash
include .env
SHELL := /bin/bash # Use bash syntax
export TZ=America/Sao_Paulo
export
.PHONY: help
.DEFAULT_GOAL := up
##@ Docker
up: ## Start all project containers
@echo -e "\n~~> Starting up containers for ${PROJECT_NAME}..."
@docker-compose up -d
@echo -e "~> Access Application through url: http://localhost:${DOCKER_APP_PORT} or https://localhost:${DOCKER_APP_PORT_SSL}"
stop: ## Stop all project containers
@echo -e "\n~~> Stoping all containers for ${PROJECT_NAME}..."
@docker-compose stop
@docker-compose rm -f
@echo -e "done!\n"
restart: ## Stop, Remove and Start app containers
@echo -e "\n~~> Restarting all containers for ${PROJECT_NAME}..."
@make stop
@make up
in: ## Enter in backend app container
@docker exec -it "${PROJECT_NAME}-app" bash
in-db: ## Enter in app container
@docker exec -it "${PROJECT_NAME}-db" bash
ps: ## List the project containers
@docker-compose ps
logs: ## Show application logs as tail
@docker-compose logs -f app
nginx-restart: ## Restart nginx service
@docker exec -it "${PROJECT_NAME}-app" nginx -s reload
nginx-logs: ## Show application nginx logs as tail
@docker exec -it "${PROJECT_NAME}-app" tail -f /var/log/nginx/application-error.log
##@ Composer
install: ## Composer install dependencies
@echo -e "~~> Installing composer dependencies..."
@docker exec -it "${PROJECT_NAME}-app" composer install -o
@echo -e "done!\n"
require: ## Run the composer require. (e.g make require PACKAGE="vendor/package")
@echo -e "~~> Installing ${PACKAGE} Composer package..."
@docker exec -it "${PROJECT_NAME}-app" composer require -o "${PACKAGE}"
@echo -e "done!\n"
require-dev: ## Run the composer require with dev dependency flag. (e.g make require-dev PACKAGE="vendor/package")
@echo -e "~~> Installing ${PACKAGE} Composer Development package..."
@docker exec -it "${PROJECT_NAME}-app" composer require --dev -o "${PACKAGE}"
@echo -e "done!\n"
update: ## Run the composer update. (e.g make update)
@echo -e "~~> Updating Composer packages..."
@docker exec -it "${PROJECT_NAME}-app" composer update -o
@echo -e "done!\n"
dump: ## Run the composer dump
@docker exec -it "${PROJECT_NAME}-app" composer dump-autoload -o
##@ Quality Tools
cs: ## Run Code Sniffer Tool
@echo -e "~~> Running PHP Code Sniffer Tool..."
@docker exec -it "${PROJECT_NAME}-app" composer run phpcs
@echo -e "done!\n"
fixer: ## Run PHP Code Beautifier Tool
@echo -e "~~> Running PHP Code Beautifier Tool..."
@docker exec -it "${PROJECT_NAME}-app" composer run phpcbf
@echo -e "done!\n"
##@ Yii and Application
migrate: ## Run all the yii migrations
@echo -e "\n~~> Running app migrations..."
@docker exec -it "${PROJECT_NAME}-app" php ./yii migrate
@echo -e "done!\n"
migrate-create: ## Run all the ./yii migrate/create. (e.g make migrate-create NAME="migrateName")
@docker exec -it "${PROJECT_NAME}-app" php ./yii migrate/create "${NAME}"
migrate-down: ## Run all the yii migrate/down
@docker exec -it "${PROJECT_NAME}-app" php ./yii migrate/down
migrate-fresh: ## Delete all tables from the database and apply all migrations from the beginning
@docker exec -it "${PROJECT_NAME}-app" php ./yii migrate/fresh
model: ## Create a model using GII (e.g make model TABLE=users MODEL=User)
@docker exec -it "${PROJECT_NAME}-app" php ./yii gii/model --tableName="${TABLE}" --modelClass="${MODEL}"
cache: ## Flush all yii cache
@docker exec -it "${PROJECT_NAME}-app" php ./yii cache/flush-all
##@ PHP Unit - Tests
test: ## Run the all suite test
@docker exec -it "${PROJECT_NAME}-app" composer run test
test-filter: ## Run a single test by method name (e.g make test-filter NAME="testYourTestName")
@docker exec -it "${PROJECT_NAME}-app" composer run test:filter ${NAME}
test-unit: ## Run the application unit tests only
@docker exec -it "${PROJECT_NAME}-app" composer run test:unit
test-integration: ## Run the application integration tests only
@docker exec -it "${PROJECT_NAME}-app" composer run test:integration
test-coverage: ## Run the all suite test and generate the Code Coverage
@docker exec -it -e XDEBUG_MODE=coverage "${PROJECT_NAME}-app" composer run test:coverage
test-coverage-ci: ## Run the all suite test and generate the Code Coverage
@docker exec -i -e XDEBUG_MODE=coverage "${PROJECT_NAME}-app" composer run test:coverage-ci
##@ Database
db-backup: ## Backup database
@docker exec "${PROJECT_NAME}-db" /usr/bin/mysqldump -u "${DB_USERNAME}" -p"${DB_PASSWORD}" "${DB_DATABASE}" > dump/database-dump.sql
db-restore: ## Restore database
@cat dump/backup.sql | docker exec -i "${PROJECT_NAME}-db" /usr/bin/mysql -u "${DB_USERNAME}" -p"${DB_PASSWORD}" "${DB_DATABASE}"
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)