Skip to content

Commit 53bf40c

Browse files
committed
Disable live reload in production
The application enviroment can be set through the NODE_ENV environment variable. It defaults to production. The application won't watch for changes when running in production.
1 parent 93f6d18 commit 53bf40c

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ MAINTAINER Aad Versteden <[email protected]>
44

55
ENV MU_SPARQL_ENDPOINT 'http://database:8890/sparql'
66
ENV MU_APPLICATION_GRAPH 'http://mu.semte.ch/application'
7+
ENV NODE_ENV 'production'
78

89
WORKDIR /usr/src/app
910
COPY . /usr/src/app

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ You can install additional dependencies by including a `package.json` file next
8383

8484
## Developing with the template
8585

86-
When developing, you can use the template image, mount the volume with your sources on `/app` and add a link to the database. The service will live-reload on changes. You'll need to restart the container when you define additional dependencies in your `package.json`.
86+
When developing, you can use the template image, mount the volume with your sources in `/app` and add a link to the database. Set the `NODE_ENV` environment variable to `development`. The service will live-reload on changes. You'll need to restart the container when you define additional dependencies in your `package.json`.
8787

8888
docker run --link virtuoso:database \
8989
-v `pwd`:/app \
9090
-p 8888:80 \
91+
-e NODE_ENV=development \
9192
--name my-js-test \
9293
semtech/mu-javascript-template
9394

boot.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44
npm install /app
55
npm install
66

7-
./node_modules/supervisor/lib/cli-wrapper.js \
8-
-w /usr/src/app,/app \
9-
-i /usr/src/app/node_modules,/usr/src/app/helpers,/app/node_modules \
10-
-e .js \
11-
-k --ignore-symlinks \
12-
-x sh start.sh
7+
if [ "$NODE_ENV" == "production" ];
8+
then
9+
./node_modules/supervisor/lib/cli-wrapper.js \
10+
-i . \
11+
-k --ignore-symlinks \
12+
-x sh start.sh
13+
else
14+
./node_modules/supervisor/lib/cli-wrapper.js \
15+
-w /usr/src/app,/app \
16+
-i /usr/src/app/node_modules,/usr/src/app/helpers,/app/node_modules \
17+
-e .js \
18+
-k --ignore-symlinks \
19+
-x sh start.sh
20+
fi

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414
"mu-semtech"
1515
],
1616
"dependencies": {
17-
"body-parser": "~1.15.1",
18-
"express": "^4.14.0"
19-
},
20-
"devDependencies": {
2117
"babel-cli": "^6.18.0",
2218
"babel-preset-es2015": "^6.18.0",
2319
"babel-preset-es2016": "^6.16.0",
2420
"babel-preset-es2017": "^6.16.0",
21+
"body-parser": "~1.15.1",
22+
"express": "^4.14.0",
2523
"supervisor": "^0.12.0",
2624
"sparql-client-2": "^0.6.0"
2725
},

0 commit comments

Comments
 (0)