-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
82 lines (58 loc) · 2.29 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
.PHONY: help \
artisan-key \
composer-install config \
install npm-install npm-run-dev \
npm-watch shell tinker uninstall \
up upd stop env-setup app-setup \
migrate
.DEFAULT_GOAL := help
PHP_CONTAINER := sb-learning-task-php-1
NODE_CONTAINER := node:latest
NODE_VITE_PORT := 5173:5173
# Set dir of Makefile to a variable to use later
MAKEPATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PWD := $(dir $(MAKEPATH))
USER_ID=$(shell id -u)
GROUP_ID=$(shell id -g)
NODE := docker run -p $(NODE_VITE_PORT) -it -v $(PWD)/src:/usr/src/app -w /usr/src/app --rm node:latest
help: ## * Show help (Default task)
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
composer-install: ## Setup step #2: Run composer install
docker exec -it $(PHP_CONTAINER) composer install
env-setup: ## Setup step #3: create .env file from .env.example
cp src/.env.example src/.env
artisan-key: ## Setup step #4: generate laravel application key
docker exec -it $(PHP_CONTAINER) php artisan key:generate
migrate: ## Setup step #5: Run laravel database migration
docker exec -it $(PHP_CONTAINER) php artisan migrate
npm-install: ## Setup step #6: Run npm install
$(NODE) npm install
npm-dev: ## Setup step #7: Run npm run dev
$(NODE) npm run dev
npm-build: ## Run npm run build
$(NODE) npm run build
install: composer-install env-setup artisan-key migrate npm-install npm-build ## Run the setup steps automatically
uninstall: ## Cleanup project by removing .env, PHP packages, node modules, files under the storage directory, etc.
rm -f .env
rm -f storage/logs/*.log
rm -f storage/app/public/*
rm -rf storage/framework/cache/data/*
rm -rf vendor
rm -rf node_modules
rm -rf coverage
rm -rf resources/json/*
app-setup: build install ## Setup: build and install the project
shell: ## Open bash as host user in the PHP container
docker exec -u $(USER_ID):$(GROUP_ID) -it $(PHP_CONTAINER) bash
shell-root: ## Open bash as root in the PHP container
docker exec -it $(PHP_CONTAINER) bash
build: ## App build
docker-compose up -d --build
up: ## Run docker-compose up
docker-compose up
upd: ## Run docker-compose up with -d
docker-compose up -d
start: ## Start docker containers
docker-compose start
stop: ## Stop docker containers
docker-compose stop