-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
113 lines (98 loc) · 3.76 KB
/
Makefile
File metadata and controls
113 lines (98 loc) · 3.76 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# ====================== CONSTANTS SECTION ========================= #
#
compose_spec = "docker/docker-compose.yml"
dotenv = "./.env"
venv-name = "env"
#
# ==================== END CONSTANTS SECTION ======================= #
# ====================================================================
# Create/upgrade python3 virtual environment.
# ====================================================================
venv-init:
python3 -m venv $(venv-name)
# Subshell required here: you don't have sh env in make runtime
(\
source $(venv-name)/bin/activate && \
pip install --upgrade pip && \
pip install -r misc/requirements.txt \
)
# ====================================================================
# Run database initialization process.
# ====================================================================
init-db:
(\
source $(dotenv) && \
docker-compose -f $(compose_spec) --project-directory $(CURDIR) exec \
-e GAMES_REC_DB_NAME=$${GAMES_REC_DB_NAME} \
-e GAMES_REC_DB_USER=$${GAMES_REC_DB_USER} \
-e GAMES_REC_DB_PASS=$${GAMES_REC_DB_PASS} \
psql sh -x /init-db.sh \
)
# ====================================================================
# Run arbitrary docker-compose commands.
# ====================================================================
docker-compose:
docker-compose -f $(compose_spec) --project-directory $(CURDIR) $(ARGS)
# ====================================================================
# Create docker-compose images from dockerfiles and spec provided in
# this Makefile.
# ====================================================================
dc-build: ARGS=build
dc-build: docker-compose
# ====================================================================
# Run docker-compose using env and spec provided in this Makefile
# ====================================================================
up: ARGS=up
up: docker-compose
# ====================================================================
# Bring docker-compose down (for cases when you use -d flag)
# ====================================================================
down: ARGS=down
down: docker-compose
# =====================================================================
# Get bash session to selected container
# =====================================================================
connect: ARGS=exec $(CONTAINER) bash
connect: docker-compose
# ==============================================================================
# Get to django shell of app container
# ==============================================================================
shell: ARGS=exec app python ./manage.py shell
shell: docker-compose
# ====================================================================
# Install UI dependencies
# ====================================================================
ui-dep:
(\
cd ui && \
npm i \
)
# ====================================================================
# Build UI bundle
# ====================================================================
ui-build:
(\
cd ui && \
npm run-script build \
)
# ====================================================================
# Copy templates in $PROJECT_ROOT/env_vars (no override)
# ====================================================================
env-init:
(\
sh ./misc/scripts/init.sh \
)
# ====================================================================
# Copy templates in $PROJECT_ROOT/env_vars (with override)
# ====================================================================
env-override:
(\
sh ./misc/scripts/init.sh --override \
)
# ====================================================================
# Compose .env file from sources declared in $PROJECT_ROOT/env_vars
# ====================================================================
env-compose:
(\
sh ./misc/scripts/compose.sh \
)