forked from DLBD-Department/BRIO_x_Alkemy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (99 loc) · 3.29 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
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
113
114
115
116
117
118
IMAGE_NAME="brio_frontend"
CONTAINER_NAME="brio"
MONGO_CONTAINER_NAME="mongodb"
MONGO_VERSION="7.0-ubi8"
MONGO_USER="brio"
MONGO_PWD="q+Y!h2s+JH*10La"
CURRENT_TIME := $(shell date +"%Y%m%d_%H%M%S")
SHARED_VOLUME="brio_storage"
BRIO_UPLOAD_PATH="/app/frontend/uploads"
UNAME := $(shell uname -o)
ifeq ($(UNAME), GNU/Linux)
HOST_IP=$(shell hostname -I | cut -d ' ' -f1)
endif
ifeq ($(UNAME), Darwin)
HOST_IP=$(shell osascript -e "IPv4 address of (system info)")
endif
.PHONY: help build test shell stop
help:
@echo "- make build Build docker image"
@echo "- make frontend Start the frontend application is a container"
@echo "- make shell Open a shell inside docker container"
@echo "- make stop Stop the docker container"
.DEFAULT_GOAL := help
.PHONY: network
network: shared_volume
@docker network create -d bridge ${MONGO_CONTAINER_NAME}
.PHONY: build
build:
@docker build \
--tag ${IMAGE_NAME}:latest \
--tag ${IMAGE_NAME}:$$(cat VERSION.txt) \
.
.PHONY: frontend
frontend: build
@docker run -dp 80:80 \
-v ${SHARED_VOLUME}:${BRIO_UPLOAD_PATH} \
--name ${CONTAINER_NAME} \
--network ${MONGO_CONTAINER_NAME} \
--env HOST_IP=$(HOST_IP) \
${IMAGE_NAME}
.PHONY: mongodb
mongodb: network
@docker run --name ${MONGO_CONTAINER_NAME} \
--network ${MONGO_CONTAINER_NAME} \
-d -p 27017:27017 \
mongodb/mongodb-community-server:${MONGO_VERSION}
@docker cp datasources/restore/mongo/schema/* ${MONGO_CONTAINER_NAME}:data
@docker exec -i ${MONGO_CONTAINER_NAME} /usr/bin/mongorestore \
-d brio \
data/brio/
@docker cp datasources/services/* ${MONGO_CONTAINER_NAME}:home
mongodb_stop: destroy_shared_volume
@docker exec -i ${MONGO_CONTAINER_NAME} mkdir -p tmp/brio_${CURRENT_TIME}
@docker exec -i ${MONGO_CONTAINER_NAME} /usr/bin/mongodump \
-d brio \
-o tmp/brio_${CURRENT_TIME}
@docker cp ${MONGO_CONTAINER_NAME}:tmp/brio_${CURRENT_TIME}/ datasources/backups/mongo/${CURRENT_TIME}/
@docker stop ${MONGO_CONTAINER_NAME} && docker rm ${MONGO_CONTAINER_NAME}
@docker network rm ${MONGO_CONTAINER_NAME}
@docker image rm mongodb/mongodb-community-server
shared_volume:
@docker volume create ${SHARED_VOLUME}
destroy_shared_volume:
@docker volume rm ${SHARED_VOLUME}
mongodb_reset_files_status:
@docker exec -i ${MONGO_CONTAINER_NAME} mongosh -f home/files_reset_status.js
mongodb_restore: network
@docker run --name ${MONGO_CONTAINER_NAME} \
--network ${MONGO_CONTAINER_NAME} \
-d -p 27017:27017 \
mongodb/mongodb-community-server:${MONGO_VERSION}
@docker cp ${path}/* ${MONGO_CONTAINER_NAME}:data
@docker exec -i ${MONGO_CONTAINER_NAME} /usr/bin/mongorestore \
-d brio \
data/brio/
@docker cp datasources/services/* ${MONGO_CONTAINER_NAME}:home
.PHONY: shell
shell:
@docker exec -it ${CONTAINER_NAME} /bin/bash
.PHONY: stop
stop:
@docker stop ${CONTAINER_NAME}
@docker rm ${CONTAINER_NAME}
@docker image rm ${IMAGE_NAME}
@docker image rm ${IMAGE_NAME}:$$(cat VERSION.txt)
@docker exec -i ${MONGO_CONTAINER_NAME} mongosh -f home/files_reset_status.js
.PHONY: test
test:
@python3 -m tests.unit.TestBiasDetector
.PHONY: venv
venv:
python3 -m virtualenv .
. bin/activate; pip install -Ur requirements.txt
. bin/activate; pip install -Ur requirements-dev.txt
.PHONY: clean
clean:
-rm -rf build dist
-rm -rf *.egg-info
-rm -rf bin lib share pyvenv.cfg