Skip to content

Commit

Permalink
chore: production server without npm (#368)
Browse files Browse the repository at this point in the history
* chore: production server without npm

* chore: security improvements

* chore: emit source maps when building
  • Loading branch information
r4mmer authored Dec 18, 2023
1 parent f6724e5 commit 47821bf
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
node_modules/
.git/
.github/
__tests__/
tmp/
.env
.dockerignore
Dockerfile
.npmrc
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ coverage-integration
.DS_Store

tmp/

dist/
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ WORKDIR /usr/src/app/

COPY .babelrc package.json package-lock.json ./
RUN apk add --no-cache --virtual .gyp python3 make g++ &&\
npm install &&\
apk add dumb-init &&\
npm ci --only=production &&\
apk del .gyp

COPY ./src/ ./src/
COPY ./scripts/ ./scripts/
COPY config.js.docker ./src/config.js

RUN npm run build

EXPOSE 8000
ENTRYPOINT ["npm", "start", "--"]
ENTRYPOINT ["dumb-init", "node", "dist/index.js"]
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
"yargs": "^16.2.0"
},
"scripts": {
"build": "babel src -d dist --source-maps",
"dev": "nodemon --exec babel-node src/index.js",
"start": "npm run build && node dist/index.js",
"test": "jest --forceExit --runInBand",
"test_integration": "npm run test_network_up && npm run test_network_integration && npm run test_network_down",
"test_network_up": "docker-compose -f ./__tests__/integration/docker-compose.yml up -d && mkdir -p tmp && cp ./__tests__/integration/configuration/precalculated-wallets.json ./tmp/wallets.json",
"test_network_integration": "jest --config jest-integration.config.js --runInBand --forceExit",
"test_network_down": "docker-compose -f ./__tests__/integration/docker-compose.yml down && rm ./tmp/wallets.json",
"dev": "nodemon --exec babel-node index.js",
"start": "babel-node src/index.js",
"lint": "eslint .",
"lint_fix": "eslint . --fix",
"generate_words": "babel-node scripts/generate_words.js",
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/index.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const { notificationBus } = require('../services/notification.service');
const { cantSendTxErrorMessage, API_ERROR_CODES } = require('../helpers/constants');
const { parametersValidation } = require('../helpers/validations.helper');
const { sanitizeLogInput } = require('../logger');
const { getReadonlyWalletConfig, getWalletConfigFromSeed, WalletStartError } = require('../helpers/wallet.helper');
const { getReadonlyWalletConfig, getWalletConfigFromSeed } = require('../helpers/wallet.helper');
const { WalletStartError } = require('../errors');
const { mapTxReturn } = require('../helpers/tx.helper');
const { lock, lockTypes } = require('../lock');
const settings = require('../settings');
Expand Down
4 changes: 3 additions & 1 deletion src/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

const version = process.env.npm_package_version || 'unknown';
const packageJson = require('../package.json');

const version = packageJson.version || 'unknown';

export default version;

0 comments on commit 47821bf

Please sign in to comment.