-
Notifications
You must be signed in to change notification settings - Fork 17
/
run-development.sh
executable file
·70 lines (52 loc) · 1.72 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
#!/bin/bash
source ./helpers.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.json 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="$?"
## Ensure we _sync_ the sources from the hosted app and _copy_ the node_modules.
##
## We don't want to do --delete on the node_modules because this allows us
## to depend on the node_modules installed in an earlier update cycle as well as
## taking node_modules from the hosted app into account.
docker-rsync --delete --exclude node_modules /app/ /usr/src/app/app/
if [ -d /app/node_modules/ ]
then
docker-rsync /app/node_modules /usr/src/app/app/
fi
## Copy config folder
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