-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
63 lines (48 loc) · 1.6 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
PROJECT_NAME=takenews
# Port on which development server serves the app
PORT=3000
# Docker things
DOCKER_IMAGE=$(PROJECT_NAME)
DOCKER_RUN=docker run \
-u $(shell id -u):$(shell id -g) \
-v $(shell pwd)/src/:/app/src/ \
-v $(shell pwd)/public/:/app/public/ \
-p $(PORT):$(PORT)
all: dev
help: ## Display help message
help:
@echo Make targets:
@echo
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
docker_build: ## Build docker image
docker_build:
docker build -t $(DOCKER_IMAGE) $(OPTIONS) .
run_%: ## Run 'npm run %'
run_%:
$(DOCKER_RUN) -t $(DOCKER_IMAGE) run $(shell echo $@ | cut -d _ -f 2-)
start: ## Run 'npm start': start the development server
start:
$(DOCKER_RUN) -i -t $(DOCKER_IMAGE) start
dev: ## Build and start the development server
dev: docker_build start
format: ## Build and reformat the code
format: docker_build run_format
lint: ## Build and check code format
lint: docker_build run_lint
build: ## Build docker image and generate production-ready code in build directory
build: docker_build
mkdir -p $(shell pwd)/build/
$(DOCKER_RUN) \
-e PUBLIC_URL \
-v $(shell pwd)/build:/app/build \
-t $(DOCKER_IMAGE) run build
_interactive: # Enter the docker image interactivelly
_interactive: docker_build
$(DOCKER_RUN) -i --entrypoint /bin/bash -t $(DOCKER_IMAGE)
_node_modules: # Force node_nodules update
mkdir -p node_modules
$(DOCKER_RUN) \
-v $(shell pwd)/node_modules:/app/node_modules \
-t $(DOCKER_IMAGE) install
node_modules: ## Build and return node_modules directory using docker
node_modules: docker_build _node_modules