-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
168 lines (115 loc) · 5.31 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
.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 dirs down clean build-containers network up build reset-database generate-key ## Initial configuration tasks
dirs:
mkdir -p .cache
check-env:
@[ -f .env ] || { cp .env.example .env; }
build-containers: ## 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 ./node_modules
up: ## Starts the Docker containers
docker compose up -d
build: install-composer install-npm build-js
down: ## Stops the Docker containers
docker compose down
unit: ## Run unit tests
bin/dcrun vendor/bin/pest --testsuite=Unit ${OPTS}
functional: reset-testing-database ## Run functional tests
bin/dcrun vendor/bin/pest --testsuite=Feature ${OPTS}
test-bruno: ## Run bruno tests (npm install -g @usebruno/cli)
cd bruno && bru run -r . --env 'Local API'
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
install-npm:
bin/dcrun npm ci
build-js:
bin/dcrun npm run build
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
helpers: ## Generate Laravel IDE helpers
@if [ -z $(FORCE) ]; then \
echo "*** laravel-ide-helper generates incorrect code for Laravel 11, and is not recommended at this time."; \
echo "*** if you wish to generate helpers anyway, run 'make helpers FORCE=1'"; \
exit 1; \
fi
bin/dcrun php artisan ide-helper:generate
bin/dcrun php artisan ide-helper:meta
bin/dcrun php artisan ide-helper:models --write --smart-reset
lint: style quality ## Check code standards conformance
check: lint test ## Run lint and unit tests
fix: fix-style ## Run automated code fixes
style: ## Run code style checks
bin/dcrun vendor/bin/php-cs-fixer check
fix-style: ## Run code style fixes
bin/dcrun vendor/bin/php-cs-fixer fix
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: drop-testing-database create-testing-database migrate-testing seed-testing
drop-testing-database:
bin/dcrun sh -c "export PGPASSWORD=${DB_ROOT_PASSWORD} && psql -U ${DB_ROOT_USERNAME} -h ${DB_HOST} -c 'drop database if exists aspirecloud_testing'"
create-testing-database:
bin/dcrun sh -c "export PGPASSWORD=${DB_ROOT_PASSWORD} && psql -U ${DB_ROOT_USERNAME} -h ${DB_HOST} -c 'create database aspirecloud_testing owner ${DB_USERNAME}'"
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 aspire-net and traefik proxy (if they don't exist already)
bin/create-external-network.sh aspire-net
bin/create-external-network.sh traefik
rm-network: ## Remove aspire-net docker network. (traefik is not touched)
-bin/remove-external-network.sh aspire-net
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