Run babel node instead of nodemon

Quote of @appinteractive:
```
Currently we are running nodemon on production which watches for filechanges and consumes much more memory then just node. As nodemon is only for development, I added a build step to compile the application for production and then only run the dist folder with pure node.
```
This commit is contained in:
Robert Schäfer 2018-12-14 22:04:02 +01:00
parent 212725e44d
commit 9f78a96de2
7 changed files with 41 additions and 17 deletions

View File

@ -1 +1,12 @@
{ "presets": ["@babel/preset-env"] } {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "10"
}
}
]
]
}

View File

@ -22,7 +22,9 @@ install:
- docker-compose -f docker-compose.yml up -d - docker-compose -f docker-compose.yml up -d
script: script:
- docker-compose exec backend yarn run ci - docker-compose exec backend yarn run lint
- docker-compose exec backend yarn run test
- docker-compose exec backend yarn run test:coverage
- docker-compose exec backend yarn run db:reset - docker-compose exec backend yarn run db:reset
- docker-compose exec backend yarn run db:seed - docker-compose exec backend yarn run db:seed

View File

@ -16,4 +16,5 @@ RUN yarn install --production=false --frozen-lockfile --non-interactive
COPY . . COPY . .
COPY .env.template .env COPY .env.template .env
RUN yarn run build
CMD ["yarn", "run", "start"] CMD ["yarn", "run", "start"]

View File

@ -63,6 +63,14 @@ Configure the file `.env` according to your needs and your local setup.
Start the GraphQL service: Start the GraphQL service:
```bash
yarn dev
# -or-
npm dev
```
And on the production machine run following:
```bash ```bash
yarn start yarn start
# -or- # -or-

0
dist/.gitkeep vendored Normal file
View File

View File

@ -7,25 +7,22 @@
"no_auth": "cross-env GRAPHQL_URI=http://localhost:4001 GRAPHQL_PORT=4001 PERMISSIONS=disabled" "no_auth": "cross-env GRAPHQL_URI=http://localhost:4001 GRAPHQL_PORT=4001 PERMISSIONS=disabled"
}, },
"scripts": { "scripts": {
"ci": "yarn run lint && yarn run test && yarn run test:coverage", "build": "babel src/ -d dist/ --copy-files",
"start": "node dist/",
"dev": "nodemon --exec babel-node src/index.js",
"dev:debug": "nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js",
"mocha": "mocha --require @babel/register src/**/*.test.js",
"lint": "eslint src --config .eslintrc.js", "lint": "eslint src --config .eslintrc.js",
"test": "./node_modules/.bin/nyc --reporter=text-lcov ./node_modules/.bin/mocha --require @babel/register src/**/*.test.js", "test": "nyc --reporter=text-lcov mocha --require @babel/register src/**/*.test.js",
"test:coverage": "./node_modules/.bin/nyc report --reporter=text-lcov > coverage.lcov", "test:coverage": "nyc report --reporter=text-lcov > coverage.lcov",
"start": "./node_modules/.bin/nodemon --exec babel-node src/index.js", "db:script:seed": "wait-on tcp:4001 && babel-node src/seed/seed-db.js",
"start:debug": "./node_modules/.bin/nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js", "db:script:reset": "wait-on tcp:4001 && babel-node src/seed/reset-db.js",
"db:script:seed": "wait-on tcp:4001 && ./node_modules/.bin/babel-node src/seed/seed-db.js",
"db:script:reset": "wait-on tcp:4001 && ./node_modules/.bin/babel-node src/seed/reset-db.js",
"db:seed": "$npm_package_config_no_auth run-p --race start db:script:seed", "db:seed": "$npm_package_config_no_auth run-p --race start db:script:seed",
"db:reset": "$npm_package_config_no_auth run-p --race start db:script:reset" "db:reset": "$npm_package_config_no_auth run-p --race start db:script:reset"
}, },
"author": "Human Connection gGmbH", "author": "Human Connection gGmbH",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/cli": "~7.2.0",
"@babel/core": "~7.2.0",
"@babel/node": "~7.2.0",
"@babel/preset-env": "~7.2.0",
"@babel/register": "~7.0.0",
"apollo-cache-inmemory": "~1.3.11", "apollo-cache-inmemory": "~1.3.11",
"apollo-client": "~2.4.7", "apollo-client": "~2.4.7",
"apollo-link-http": "~1.5.7", "apollo-link-http": "~1.5.7",
@ -52,10 +49,16 @@
"passport": "~0.4.0", "passport": "~0.4.0",
"passport-jwt": "~4.0.0", "passport-jwt": "~4.0.0",
"sanitize-html": "~1.19.3", "sanitize-html": "~1.19.3",
"faker": "~4.1.0",
"slug": "~0.9.3", "slug": "~0.9.3",
"trunc-html": "~1.1.2" "trunc-html": "~1.1.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "~7.2.0",
"@babel/core": "~7.2.0",
"@babel/node": "~7.2.0",
"@babel/preset-env": "~7.2.0",
"@babel/register": "~7.0.0",
"apollo-server-testing": "~2.2.6", "apollo-server-testing": "~2.2.6",
"babel-eslint": "~10.0.1", "babel-eslint": "~10.0.1",
"chai": "~4.2.0", "chai": "~4.2.0",
@ -65,8 +68,7 @@
"eslint-plugin-node": "~8.0.0", "eslint-plugin-node": "~8.0.0",
"eslint-plugin-promise": "~4.0.1", "eslint-plugin-promise": "~4.0.1",
"eslint-plugin-standard": "~4.0.0", "eslint-plugin-standard": "~4.0.0",
"faker": "~4.1.0", "mocha": "~5.2.0",
"mocha": "^5.2.0",
"nodemon": "~1.18.8", "nodemon": "~1.18.8",
"npm-run-all": "~4.1.5", "npm-run-all": "~4.1.5",
"nyc": "^13.1.0", "nyc": "^13.1.0",

View File

@ -4163,7 +4163,7 @@ mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1:
dependencies: dependencies:
minimist "0.0.8" minimist "0.0.8"
mocha@^5.2.0: mocha@~5.2.0:
version "5.2.0" version "5.2.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6" resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6"
integrity sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ== integrity sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==