-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
64 lines (49 loc) · 2.09 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
SHELL=bash
###################################################################################################
## INITIALISATION
###################################################################################################
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
###################################################################################################
## DEV
###################################################################################################
.PHONY: build-dev build-dev-no-cache build-test start start-detached stop shell
build-dev: ##@dev Build the application for dev
docker compose build
build-dev-no-cache: ##@dev Build the application for dev without using cache
docker compose build --no-cache
build-test: ##@dev Build the application to run tests
docker build \
--build-arg NODE_ENV=production \
--target test \
-t app-test:1.00 .
start: ##@dev Start the development environment
docker compose up
start-detached: ##@dev Start the development environment (detached)
docker compose up -d
stop: ##@dev Stop the development environment
docker compose down
shell: ##@dev Go into the running container (the app name should match what's in docker-compose.yml)
docker compose exec app /bin/sh
###################################################################################################
## HELP
###################################################################################################
.PHONY: default
default: help
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
print "usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; }
help: ##@other Show this help
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)