-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.mk
78 lines (58 loc) · 1.91 KB
/
base.mk
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
PWD ?= pwd_unknown
BASE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
export PROJECT_ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
CONFIG_FILE ?= $(BASE_DIR)/.project_config.json
define GetFromCfg
$(shell node -p "require('$(CONFIG_FILE)').$(1)")
endef
export AWS_DEFAULT_REGION ?= $(call GetFromCfg,aws.region)
ifeq ($(CI),true)
AWS_VAULT =
VERSION := $(shell cat $(BASE_DIR)/VERSION)
DOCKER_COMPOSE = docker-compose -p schema-cms -f $(BASE_DIR)/docker-compose.yml -f $(BASE_DIR)/docker-compose.ci.yml
else ifeq ($(ENV_STAGE),local)
AWS_VAULT =
VERSION := $(shell git describe --tags --first-parent --abbrev=11 --long --dirty --always)
DOCKER_COMPOSE = docker-compose -p schema-cms
else
AWS_VAULT_PROFILE := $(call GetFromCfg,aws.profile)
AWS_VAULT = aws-vault exec $(AWS_VAULT_PROFILE) --
VERSION := $(shell git describe --tags --first-parent --abbrev=11 --long --dirty --always)
DOCKER_COMPOSE = docker-compose -p schema-cms
endif
export VERSION
CMD_ARGUMENTS ?= $(cmd)
version:
@echo $(VERSION)
install-infra-cdk:
$(MAKE) -C $(BASE_DIR)/infra install
aws-shell:
$(AWS_VAULT) $(SHELL)
up:
$(DOCKER_COMPOSE) up --build --force-recreate
fe-up:
$(MAKE) -C $(BASE_DIR)/frontend start
down:
$(DOCKER_COMPOSE) down
shell:
$(DOCKER_COMPOSE) run --rm backend bash
attach:
docker attach schema-cms-backend
migrate:
$(DOCKER_COMPOSE) run --rm backend ./manage.py migrate
makemigrations:
$(DOCKER_COMPOSE) run --rm backend ./manage.py makemigrations
pytest:
$(DOCKER_COMPOSE) run --rm backend pytest
clean:
# remove created images
@docker-compose -p schema-cms down --remove-orphans --rmi all 2>/dev/null \
&& echo 'Image(s) for schema-cms removed.' \
|| echo 'Image(s) for schema-cms already removed.'
prune:
# clean all that is not actively used
docker system prune -af
docker-login:
ifneq ($(DOCKER_USERNAME),)
echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
endif