-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
153 lines (128 loc) · 3.65 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#
# Copyright 2021-present, Nuance, Inc.
# All rights reserved.
#
# This source code is licensed under the Apache-2.0 license found in
# the LICENSE.md file in the root directory of this source tree.
#
PLATFORM := $(shell uname -s)
XMKCERT :=
XOPENSSL :=
XOPEN :=
XPACKAGEMANAGER :=
XVENVACTIVATE :=
ifeq ($(OS),Windows_NT)
XPACKAGEMANAGER=choco
XMKCERT=mkcert.exe
XOPENSSL=openssl.exe
XOPEN=start
XVENVACTIVATE=.venv/scripts/activate
else
ifeq ($(PLATFORM),Linux)
XPACKAGEMANAGER=brew
XMKCERT=mkcert
XOPENSSL=openssl
XOPEN=xdg-open
XVENVACTIVATE=.venv/bin/activate
endif
ifeq ($(PLATFORM),Darwin)
XPACKAGEMANAGER=brew
XMKCERT=mkcert
XOPENSSL=openssl
XOPEN=open
XVENVACTIVATE=.venv/bin/activate
endif
endif
all : certs-prep native-build-app native-build-api \
native-run-app-secure native-run-api-secure native-clean \
containers-build containers-run containers-restart \
containers-stop containers-status containers-logs \
containers-clean launch new-data-access-endpoint help
.PHONY : all
help:
@echo "See the README for more details."
@echo "CERTS: certs-(prep|setup)"
@echo "*LAUNCH: launch"
@echo "DOCKER: containers-(build|run|restart|stop|status|logs|clean)"
@echo "NATIVE.BUILD: native-build-(app|api)"
@echo "NATIVE.RUN: native-run-(app|api)-(secure|insecure)"
@echo "NATIVE.CLEANUP: native-clean"
@echo "DATA.ACCESS: new-data-access-endpoint"
# SSL
certs-prep:
@echo Preparing requirements for certificates.
$(XPACKAGEMANAGER) install openssl mkcert
certs-setup:
@echo Creating and Installing Certs for SSL
cd resources; \
$(XMKCERT) localhost 127.0.0.1 ::1; \
$(XMKCERT) -install
# Windows:
# replace with `Read-Host` if using PowerShell
# else use GitBash/cygwin
@read -s -p "Password: " password; \
echo $$password > resources/.password
@echo Setting up .pfx
$(XOPENSSL) pkcs12 -export -out resources/certificate.pfx -inkey resources/localhost+2-key.pem -in resources/localhost+2.pem -password file:resources/.password
# Docker
containers-build:
@echo Building Containers
docker-compose build
containers-run: containers-build
@echo Starting App
docker-compose up -d
containers-restart:
@echo Restarting....
docker-compose restart
containers-stop:
@echo Stopping...
docker-compose down
containers-status:
docker-compose ps
containers-logs:
docker-compose logs --follow
containers-clean:
@echo Cleaning containers...
docker-compose down --rmi all
# Native
native-build-app:
cd app/; npm install --legacy-peer-deps --loglevel warn
native-build-api:
cp resources/local.settings.json api/local.settings.json
cd api/; \
python3 -m venv .venv; \
source $(XVENVACTIVATE); \
pip install -r requirements.txt
native-run-app-secure: native-build-app
cd app/; \
npm run develop -- --https --cert-file ../resources/localhost+2.pem --key-file ../resources/localhost+2-key.pem
$(XOPEN) "https://localhost:8000"
native-run-api-secure: native-build-api
cd api/; \
source $(XVENVACTIVATE); \
pip list; \
func start --useHttps \
--cert ../resources/certificate.pfx \
--password ../resources/.password
native-run-app-insecure:
@echo Make sure `local.settings.json` is using `http`, _not_ `https`
cd app/; npm run develop
native-run-api-insecure:
cd api/; func start
native-clean:
@echo 1/2: Cleaning Client
rm -rf app/node_modules
rm -rf app/.cache
rm -rf app/public
@echo 2/2: Cleaning APIs
rm -rf api/.venv
rm -rf api/__pycache__
# Utiltiies
launch: certs-setup containers-run
@echo Launch "https://localhost:8000"
$(XOPEN) "https://localhost:8000"
new-data-access-endpoint:
@read -p "Endpoint: " endpoint; \
if [ ! -z "$$endpoint" ]; then \
./scripts/create-da-handler.sh $$endpoint; \
fi;