Skip to content

Commit 72eece3

Browse files
committed
FS-4978: dont use nodemon in production
nodemon is designed to be run locally to watch for file changes and restart the running process. This behaviour could lead to unpredictable behaviour when running and has security implications for exucting modified code. The `NODE_ENV` is often used by servers and dependencies to gate behaviour that would only be acceptable in a development environment. I've not audited what would depend on that in this instance but we don't want to leave room for vulnerabilities through defauling to open (development). Note that this continues the practice of including the NODE_ENV in the package json. This is to aim for this fix to be as least disruptive as possible but I don't encourage this. Ideally the script will just take care of starting the server and the context it is running in should be responsible for appropriately configuring the environment.
1 parent 4c25963 commit 72eece3

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

designer/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"scripts": {
66
"watch": "NODE_ENV=development webpack",
77
"dev": "NODE_OPTIONS=--openssl-legacy-provider && concurrently 'yarn watch' 'yarn start:local'",
8-
"production": "yarn start:prod",
8+
"production": "NODE_ENV=production yarn start:server",
9+
"start:test": "NODE_ENV=test yarn start:server",
910
"build": "NODE_ENV=production && NODE_OPTIONS=--openssl-legacy-provider && webpack",
10-
"start:prod": "NODE_ENV=production nodemon dist/server.js",
11+
"start:server": "node dist/server.js",
1112
"start:local": "NODE_ENV=development PERSISTENT_BACKEND=preview ts-node-dev --inspect --respawn --transpile-only server/index.ts"
1213
},
1314
"author": "Communities UK",

docker-compose.e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services:
1313
- LAST_COMMIT
1414
- LAST_TAG
1515
- AUTH_ENABLED=false
16-
command: yarn designer production
16+
command: yarn designer start:test
1717
depends_on:
1818
- runner
1919
- localstack
@@ -44,7 +44,7 @@ services:
4444
- SINGLE_REDIS=true
4545
- FORM_RUNNER_ADAPTER_REDIS_INSTANCE_URI=redis://redis-data:6379
4646
- PREVIEW_MODE=true
47-
command: yarn runner production
47+
command: yarn runner start:test
4848
logging:
4949
driver: "json-file"
5050
depends_on:

runner/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"copy-forms": "node copy-form-json.js",
1313
"clean:build": "rm -rf dist",
1414
"dev": "NODE_ENV=development nodemon --watch src --ext js,json,ts,html,scss --exec 'yarn build && node dist/digital-form-builder-adapter/runner/index.js'",
15-
"production": "NODE_ENV=development nodemon dist/digital-form-builder-adapter/runner/index.js",
15+
"start:server": "nodemon dist/digital-form-builder-adapter/runner/index.js",
16+
"production": "NODE_ENV=production npm run start:server",
17+
"start:test": "NODE_ENV=development npm run start:server",
1618
"test-cov": "yarn run unit-test-cov",
1719
"test:dev": "lab -T test/.transform.js -P (test|src)/**/*.test.* -v test --coverage-exclude",
1820
"unit-test": "lab -T test/.transform.js -P (test|src)/**/*.test.* -v test -S -v -r console -o stdout -r html -o unit-test.html -I version -l",

0 commit comments

Comments
 (0)