forked from aspirepress/AspireCloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
131 lines (89 loc) · 4.05 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
.PHONY: *
# Set additional parameters for command
OPTS=
# Set DEBUG=1 to enable xdebug
ifeq ($(origin DEBUG),undefined)
XDEBUG :=
PHPSTAN_XDEBUG :=
else
XDEBUG := XDEBUG_SESSION=1
PHPSTAN_XDEBUG := --xdebug
endif
ifneq (,$(wildcard ./.env))
include .env
export
endif
list:
@grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | perl -ne '/^(?:.*?:)?(.*?):.*##(.*$$)/ and printf "\033[36m%-30s\033[0m %s\n", $$1, $$2'
init: check-env down clean build network up install-composer reset-database generate-key ## Initial configuration tasks
check-env:
@[ -f .env ] || { cp .env.example .env && bin/dcrun ./artisan key:generate; }
build: ## Builds the Docker containers
docker compose build
clean: ## Remove all Docker containers, volumes, etc
docker compose down -v --remove-orphans
docker compose rm -f
rm -fr ./vendor
up: ## Starts the Docker containers
docker compose up -d
down: ## Stops the Docker containers
docker compose down
unit: ## Run unit tests
bin/dcrun vendor/bin/pest --testsuite=unit ${OPTS}
functional: ## Run functional tests
bin/dcrun vendor/bin/pest --testsuite=functional ${OPTS}
test: unit functional ## Run all tests
acceptance: ## Run acceptance tests
bin/dcrun vendor/bin/behat -vvv ${OPTS}
quality: ## Run all quality checks
bin/dcrun vendor/bin/phpstan --memory-limit=1G analyse ${OPTS}
quality-baseline: ## Run all static analysis checks with baseline
bin/dcrun vendor/bin/phpstan analyse -b baseline.neon $(PHPSTAN_XDEBUG) src tests
install-composer: ## Install composer dependencies
bin/dcrun composer install
logs-%: ## View logs (follow mode) for the container where % is a service name (webapp, postgres, node, nginx, smtp, rabbitmq)
docker compose logs -f $*
sh-webapp: # webapp is alpine, so we need to use sh, not sh
docker compose exec webapp sh
sh-%: ## Execute shell for the container where % is a service name (webapp, postgres, node, nginx, smtp, rabbitmq)
docker compose exec $* sh || docker compose run --rm $* sh
clear-cache: ## Clear cache
bin/dcrun php artisan optimize:clear
check: cs quality test ## Check all quality and test elements
cs: ## Run code style checks
bin/dcrun vendor/bin/pint ${OPTS}
create-migration: ## Create a new database migration
bin/dcrun php artisan make:migration
create-seed: ## Create a new database seed
bin/dcrun php artisan make:seed
migrate: ## Run database migrations
bin/dcrun php artisan migrate --force --no-interaction
migration-rollback: ## Rollback database migrations
bin/dcrun php artisan migrate --force --no-interaction
seed: ## Run database seeds
bin/dcrun php artisan db:seed
migrate-testing: ## Run database migrations
bin/dcrun php artisan migrate --database=test --force --no-interaction
seed-testing: ## Run database seeds
bin/dcrun php artisan db:seed --database=test
generate-key: ## Generate APP_KEY environment var
bin/dcrun php artisan key:generate
drop-database:
bin/dcrun sh -c "export PGPASSWORD=${DB_ROOT_PASSWORD} && psql -U ${DB_ROOT_USERNAME} -h ${DB_HOST} -c 'drop database if exists ${DB_DATABASE}'"
create-database:
bin/dcrun sh -c "export PGPASSWORD=${DB_ROOT_PASSWORD} && psql -U ${DB_ROOT_USERNAME} -h ${DB_HOST} -c 'create database ${DB_DATABASE} owner ${DB_USERNAME}'"
reset-database: drop-database create-database migrate seed ## run migrations and seeds
reset-testing-database: migrate-testing seed-testing
run-psql: ## Runs Postgres on the command line using the .env file variables
bin/dcrun sh -c "PGPASSWORD=${DB_PASSWORD} psql -U ${DB_USERNAME} -h ${DB_HOST} -p ${DB_PORT} -d ${DB_USERNAME}"
network: ## Create docker networks for app and traefik proxy (if they don't exist already)
bin/create-external-network.sh wp-services
bin/create-external-network.sh traefik
rm-network: ## Remove application docker network. (traefik
-bin/remove-external-network.sh wp-services
build-prod:
docker build --target prod -t aspirepress/aspirecloud-php -f ./docker/webapp/Dockerfile .
traefik-up: network
docker compose -f docker/traefik/docker-compose.yml up -d
traefik-down:
docker compose -f docker/traefik/docker-compose.yml down