-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
133 lines (110 loc) · 2.9 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
ENV?=test
EFS_FILE_SYSTEM_ID?=
NODE_ENV?=$(ENV)
LOG_LEVEL_DIALOG?=info
DOTENV=env/$(ENV)/.env
$(DOTENV):
@echo
@echo "Trying to run the app locally?"
@echo "You need a secrets-config file at $(DOTENV)"
@echo "Check with project admins/README for details"
@echo
@echo
@exit 1
.PHONY: clean
clean:
@rm -rf build deploy.zip
build/run/node_modules: build/run
cd build/run && \
npm ci
build/run/.env: $(DOTENV)
mkdir -p build/run
cp $(DOTENV) build/run/.env
build/run:
mkdir -p build/run
rsync -rv \
--exclude node_modules \
publish/ build/run/
build/deploy:
# put everything we want in our beanstalk deploy.zip file
# into a build/deploy folder.
@if [ -z "$(EFS_FILE_SYSTEM_ID)" ] ; then \
echo "required env var EFS_FILE_SYSTEM_ID unset.";\
echo "See https://github.com/mentorpal/aws-beanstalk-terraform/blob/main/template/README.md"; \
false ; \
fi
mkdir -p build/deploy
cp -r ebs/bundle build/deploy/bundle
# Must set the env-specific EFS_FILE_SYSTEM_ID in an .ebextensions config file
# to have our beanstalk-env instances mount this network file system
# (used for reading/writing trained models)
# ...
# sed -i option works differently on linux and mac
# so have to output to a temp file and then copy back
cd build/deploy/bundle/.ebextensions \
&& sed 's/VAR_EFS_FILE_SYSTEM_ID/$(EFS_FILE_SYSTEM_ID)/g' efs.config > efs.config.tmp \
&& mv efs.config.tmp efs.config
cp -r ./nginx build/deploy/bundle/nginx
mkdir -p build/deploy/bundle/classifier
# for now at least word2vec.bin
# directly into the deploy.zip for beanstalk
cp -r ./shared build/deploy/bundle/classifier/shared
deploy.zip:
$(MAKE) clean build/deploy
cd build/deploy/bundle && zip -r $(PWD)/deploy.zip .
archive:
mkdir -p archive
models:
mkdir -p models
uploads:
mkdir -p uploads
.PHONY: run
run: clean build/run/.env archive models uploads
NODE_ENV=$(ENV) \
ENV=$(ENV) \
LOG_LEVEL_DIALOG=$(LOG_LEVEL_DIALOG) \
docker-compose up
run-%:
ENV=$* $(MAKE) run
.PHONY: stop
stop:
docker-compose down --remove-orphans
LICENSE:
@echo "you must have a LICENSE file" 1>&2
exit 1
LICENSE_HEADER:
@echo "you must have a LICENSE_HEADER file" 1>&2
exit 1
.PHONY: license
license: LICENSE LICENSE_HEADER node_modules
npm run license:fix
$(MAKE) format
.PHONY: test-license
test-license: LICENSE LICENSE_HEADER node_modules
npm run test:license
.PHONY: format
format: node_modules
npm run format
.PHONY: test-format
test-format: node_modules
npm run test:format
.PHONY: test
test-run:
NODE_ENV=$(ENV) \
ENV=$(ENV) \
LOG_LEVEL_DIALOG=$(LOG_LEVEL_DIALOG) \
docker-compose -f docker-compose.yml -f docker-compose-e2e.yml up
.PHONY: test-cypress
test-cypress:
NODE_ENV=$(ENV) \
ENV=$(ENV) \
LOG_LEVEL_DIALOG=$(LOG_LEVEL_DIALOG) \
cd test && make test
.PHONY: test-cypress-with-ui
test-cypress-with-ui:
NODE_ENV=$(ENV) \
ENV=$(ENV) \
LOG_LEVEL_DIALOG=$(LOG_LEVEL_DIALOG) \
cd test && make test-ui
node_modules:
npm ci