-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (67 loc) · 3.22 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
# Global variables
# echo _FormatCode_ guide:
# 0 Reset all styles
# 1 Bold
# 32 Green
# 34 Blue
# 35 Magenta
# 36 Cyan
RESET_STYLES=\033[0m
BOLD_GREEN=\033[1m\033[33m
BOLD_BLUE=\033[1m\033[34m
BOLD_MAGENTA=\033[1m\033[35m
BOLD_CYAN=\033[1m\033[36m
# .PHONY defines parts of the makefile that are not dependant on any specific file
# This is most often used to store functions
.PHONY = all help setup clean wipe docker-setup docker-clean docker-wipe
# Defines the default target that `make` will to try to make, or in the case of a phony target, execute the specified commands
# This target is executed whenever we just type `make`
.DEFAULT_GOAL = help
# The @ makes sure that the command itself isn't echoed in the terminal
help:
@echo "$(BOLD_GREEN)-----------------------------MAKE GUIDE----------------------------$(RESET_STYLES)"
@echo "$(BOLD_CYAN)make setup$(RESET_STYLES) : Setup development environment"
@echo "$(BOLD_CYAN)make clean$(RESET_STYLES) : Clean up development environment"
@echo "$(BOLD_CYAN)make wipe$(RESET_STYLES) : Wipe data from development environment"
@echo "$(BOLD_CYAN)make docker-setup$(RESET_STYLES) : Setup docker images"
@echo "$(BOLD_CYAN)make docker-clean$(RESET_STYLES) : Clean docker images"
@echo "$(BOLD_CYAN)make docker-wipe$(RESET_STYLES) : Wipe docker data"
@echo "$(BOLD_GREEN)-------------------------------------------------------------------$(RESET_STYLES)"
setup: #: Setup development environment and start docker
@echo "\n$(BOLD_GREEN)Initializing development environment$(RESET_STYLES) 🏁️️️ "
@echo "\n$(BOLD_CYAN)Checking env file$(RESET_STYLES) "
@sh scripts/dev/init_env.sh
@echo "\n$(BOLD_CYAN)Checking npm version and installing dependencies$(RESET_STYLES) "
@sh scripts/dev/init_npm.sh
@make docker-setup
@echo "\n$(BOLD_CYAN)Building project locally$(RESET_STYLES) "
@npm run build
@echo "\n$(BOLD_GREEN)Local environment is setup for development$(RESET_STYLES) 🏳️️️️ \n"
clean: #: Clean up and stop docker
@echo "\n$(BOLD_GREEN)Cleaning up environment$(RESET_STYLES) ❄️ "
@echo "\n$(BOLD_CYAN)Clean dist$(RESET_STYLES) "
@rm -rf dist
@echo "\n$(BOLD_CYAN)Clean node_modules$(RESET_STYLES) "
@rm -rf node_modules
@echo "\n$(BOLD_CYAN)Clean logs$(RESET_STYLES) "
@cd logs && find . \! -name "sample.log" -delete
@make docker-clean
@echo "\n$(BOLD_GREEN)Local environment is neat & clean$(RESET_STYLES) 💫️ \n"
wipe: #: Clean & Wipe all data & Wipe all docker data
@echo "\n$(BOLD_GREEN)Wipe all data in environment: $(BOLD_MAGENTA)POTENTIALLY DANGEROUS$(RESET_STYLES) 🚿"
@make clean
@echo "\n$(BOLD_CYAN)Clean .env file$(RESET_STYLES) "
@rm -f .env
@make docker-wipe
@echo "\n$(BOLD_GREEN)Local data is flushed$(RESET_STYLES) 👍 \n"
docker-setup:
@echo "\n$(BOLD_CYAN)Composing TimescaleDB docker$(RESET_STYLES) "
@cd ./docker/timescale/postgres-volume/ && ([ -d data ] || mkdir data) && cd ../../..
@cd docker/timescale && docker-compose build && docker-compose -p matrix-core-timescale up --remove-orphans --detach
@sh scripts/dev/docker_setup.sh
docker-clean:
@echo "\n$(BOLD_CYAN)Clean docker projects$(RESET_STYLES) "
@sh scripts/dev/docker_clean.sh
docker-wipe:
@echo "\n$(BOLD_CYAN)Wipe docker volumes$(RESET_STYLES) "
@sh scripts/dev/docker_wipe.sh