-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·87 lines (74 loc) · 2.4 KB
/
entrypoint.sh
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
#!/bin/bash
# ===============================================
set -eo pipefail
if [[ -z "$HPF_KEY" ]]; then
echo -e "You must specify an API key with env HPF_KEY"
exit 1
fi
if [[ -z "$HPF_PROJECT" ]]; then
echo -e "You must specify a project id with env HPF_PROJECT"
exit 1
fi
if [[ -z "$API_URL" ]]; then
echo -e "You must specify an Api URL"
exit 1
fi
# ===============================================
# Start services
service redis-server start
service mongod start
service nginx start || (cat /var/log/nginx/error.log && exit 1)
# ===============================================
# Add special hosts
echo "127.0.0.1 mongodb redis" >> /etc/hosts
# ===============================================
# Dirty work-around to use admin routes in components
SEARCH="return '<<M a-a>>';";
REPLACE="return 'admin/<<M a-a>>';";
sed -i "s@${SEARCH}@${REPLACE}@g" /app/boilerplate-ngx-components/hapify/src/app/models/model/model.service.ts.hpf
SEARCH=" = true;";
REPLACE=" = false;";
sed -i "s@${SEARCH}@${REPLACE}@g" /app/boilerplate-ngx-components/hapify/src/app/models/model/model.service.ts.hpf
# ===============================================
# Generate project
hpf config --apiKey ${HPF_KEY}
if [[ ! -z "$HPF_API_URL" ]]; then
hpf config --apiUrl ${HPF_API_URL}
fi
hpf -d /app use -p ${HPF_PROJECT}
hpf --debug -d /app generate
# ===============================================
# Install API
cd /app/boilerplate-hapijs
if [[ ! -d "node_modules" ]]; then
npm install
fi
npm run cmd setup
npm run cmd insert-admin
# Populate Database
if [[ "$POPULATE_DATABASE" -eq "1" ]]; then
npm run cmd populate
fi
# ===============================================
# Change API URL
SEARCH="https://api.example.com";
sed -i "s@${SEARCH}@${API_URL}@g" /app/boilerplate-ngx-dashboard/src/environments/environment.production.ts
sed -i "s@${SEARCH}@${API_URL}@g" /app/boilerplate-ngx-components/src/environments/environment.production.ts
# ===============================================
# Build dashboard
cd /app/boilerplate-ngx-dashboard
if [[ ! -d "node_modules" ]]; then
npm install
fi
npm run build:production-quick
# ===============================================
# Build components
cd /app/boilerplate-ngx-components
if [[ ! -d "node_modules" ]]; then
npm install
fi
npm run build:production-quick
# ===============================================
# Start API
cd /app/boilerplate-hapijs
NODE_ENV=development npm start