-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (71 loc) · 2.01 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
ENVFILE=./.env
DJANGO_ENVFILE=./_/env/.env
ifneq (,$(wildcard ${ENVFILE}))
include ${ENVFILE}
endif
CP_CMD=cp -n
SED_CMD=sed -i
ifeq ($(OS),Windows_NT)
$(error This make script will not support Windows OS.)
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SED_CMD=sed -i ''
endif
endif
VOLUME_SET=-v `pwd`/${DJANGO_ENV_PATH}:/devicetalk/_/env/.env -v `pwd`/$(DATA_PATH):/devicetalk/datas -v `pwd`/DeviceTalk-Basic-file:/devicetalk/DeviceTalk-Basic-file -v `pwd`/DeviceTalk-Library-file:/devicetalk/DeviceTalk-Library-file
DOCKER_RUN_CMD=docker run $(VOLUME_SET) -it devicetalk:${USER}
DOCKER_COMPOSE_CMD=
ifndef DOCKER_COMPOSE_CMD
ifneq (,$(if $(shell which docker),$(findstring Docker Compose,$(shell docker info -f '{{ .ClientInfo.Plugins }}'))))
DOCKER_COMPOSE_CMD=docker compose
else ifneq (,$(shell which docker-compose))
DOCKER_COMPOSE_CMD=docker-compose
else
DOCKER_COMPOSE_CMD=$(error Could not find either `docker compose` plugin or `docker-compose` command)
endif
endif
config:
ifeq (,$(wildcard ${DJANGO_ENVFILE}))
$(CP_CMD) ./_/env/.env.sample ${DJANGO_ENVFILE};
else
@echo "DJANGO_ENVFILE ${DJANGO_ENVFILE} already exists, skipping";
endif
.PHONY: config
dockerconfig:
ifeq (,$(wildcard ${ENVFILE}))
$(CP_CMD) ./share/.env.sample ${ENVFILE};
else
@echo "ENVFILE ${ENVFILE} already exists, skipping"
endif
@read -p "Which port do you want to use in host? " HOST_PORT; \
$(SED_CMD) -e 's@^HOST_PORT=.*$$@HOST_PORT='$$HOST_PORT'@' ${ENVFILE};
.PHONY: dockerconfig
submodule:
.PHONY: submodule
build:
$(DOCKER_COMPOSE_CMD) build devicetalk
.PHONY: build
up:
$(DOCKER_COMPOSE_CMD) up
.PHONY: up
initdb: migrate
git submodule init
git submodule update --recursive
$(DOCKER_RUN_CMD) python manage.py initdb
.PHONY: initdb
migrate:
$(DOCKER_RUN_CMD) python manage.py migrate
.PHONY: initdb
shell:
$(DOCKER_RUN_CMD) python manage.py shell
.PHONY: shell
bash:
$(DOCKER_RUN_CMD) bash
.PHONY: bash
logs:
$(DOCKER_COMPOSE_CMD) logs -f devicetalk
.PHONY: logs
down:
$(DOCKER_COMPOSE_CMD) down
.PHONY: down