-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-development.sh
executable file
·73 lines (55 loc) · 1.7 KB
/
run-development.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
#! /bin/sh
# We want to run from /app but don't want to touch that folder.
#
# - node_modules which were already available in the mounted sources
# should be taken into account but shouldn't be overwritten by a
# following npm install.
#
# - Only run npm install when the package.json has changed.
# Move to right folder
cd /usr/src/app/
######################
# Install dependencies
######################
## Check if package existed and did not change since previous build (/usr/src/app/app/ is copied later in this script, at first run from the template itself it doesn't exist but that's fine for comparison)
cmp -s /app/package.json /usr/src/app/app/package.json
CHANGE_IN_PACKAGE_JSON="$?"
## Copy node_modules to temporary location so we can reuse them, this occurs when the mountend sources have a node_modules and/or on restart
rm -Rf /tmp/node_modules
if [ -d /usr/src/app/app/node_modules/ ]
then
mv ./app/node_modules /tmp/node_modules
fi
## Remove app folder if exists
rm -rf ./app
mkdir ./app
if [ -d /tmp/node_modules/ ]
then
mv /tmp/node_modules ./app/;
fi
## Copy app folder and config folder (including node_modules so host node_modules win)
cp -rf /app ./
if [[ "$(ls -A /config/ 2> /dev/null)" ]]
then
mkdir -p ./app/config/
cp -rf /config/* ./app/config/
fi
## Install dependencies on first boot
if [ $CHANGE_IN_PACKAGE_JSON != "0" ] && [ -f ./app/package.json ]
then
echo "Running npm install"
cd /usr/src/app/app/
npm install
cd /usr/src/app/
fi
###############
# Transpilation
###############
./transpile-sources.sh
##############
# Start server
##############
cd /usr/src/build/
/usr/src/app/node_modules/.bin/babel-node \
--inspect="0.0.0.0:9229" \
./app.js