-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (51 loc) · 1.86 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
.PHONY: help
help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# =====================================================================
# Docker variables and exports ========================================
# =====================================================================
CURRENT_DIR = $(shell pwd)
USER_ID = $(shell id -u)
GROUP_ID = $(shell id -g)
export UID = $(USER_ID)
export GID = $(GROUP_ID)
# =====================
# Install =============
# =====================
create-cert: ## create local ssl certificate (need to install mkcert https://github.com/FiloSottile/mkcert#linux)
mkdir -p ./infrastructure && \
mkdir -p ./infrastructure/tls && cd ./infrastructure/tls && \
mkcert react-esi.local && \
mkcert -install
install: ## install js dependencies
docker-compose run --no-deps --rm next bash -ci 'npm install --force'
# =====================
# Development =========
# =====================
.PHONY: start
start: ## start local dev environment in docker containers
docker-compose up -d
.PHONY: stop
stop: ## stop dockerised local dev environment
docker-compose down
.PHONY: logs
logs: ## display dockerised local dev environment logs
docker-compose logs -f
# =====================
# Production =========
# =====================
DOCKER_COMPOSE_PROD := docker-compose -p react-esi-prod -f docker-compose-prod.yml
.PHONY: build
build: ## build for production
mkdir -p ./dist
rm -rf dist/*
$(DOCKER_COMPOSE_PROD) run --no-deps --rm next bash -ci 'npm run build'
.PHONY: prod-start
prod-start: build ## start production build
$(DOCKER_COMPOSE_PROD) up -d
.PHONY: prod-stop
prod-stop: ## stop production build
($(DOCKER_COMPOSE_PROD) down && $(DOCKER_COMPOSE_PROD) rm -f) || true
.PHONY: prod-logs
prod-logs: ## display logs of production build
${DOCKER_COMPOSE_PROD} logs -f