-
Notifications
You must be signed in to change notification settings - Fork 14
/
docker-entrypoint.sh
executable file
·43 lines (35 loc) · 1.13 KB
/
docker-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
#!/bin/bash
environment=${1:-"production"}
# Check if environment variable HASHTOPOLIS_BACKEND_URL is set
# and use it with envsubst to set the backend url in the $app_cfg_base/config.json
function update_app_config {
app_cfg_base="$1"
if [ -n "$HASHTOPOLIS_BACKEND_URL" ]; then
echo "Using HASHTOPOLIS_BACKEND_URL: $HASHTOPOLIS_BACKEND_URL"
envsubst < ${app_cfg_base}/assets/config.json.example > ${app_cfg_base}/assets/config.json
fi
echo "Done configuring up Hashtopolis frontend (env=$environment) at $app_cfg_base/assets/config.json"
}
if [ "$environment" = "development" ]; then
# Ensure workspace is mounted
echo -n "Waiting for workspace to be mounted..."
until [ -f /app/package.json ]
do
sleep 5
done
echo "DONE"
# Install/Update required Node.js packages
export PUPPETEER_SKIP_DOWNLOAD='true'
npm install
# Prepare configuration
update_app_config "/app/src"
# Start worker instance
echo "Starting worker npm..."
npm start
else
# Prepare configuration
update_app_config "/usr/share/nginx/html"
# Start worker instance
echo "Starting worker nginx..."
nginx -g 'daemon off;'
fi