File server built with node, express in typescript.
Create file named .env.dev under folder env in the root directory with the following content.
PORT=5000
ROOT_DIR='.'
REQUEST_DELAY=0Run script.
npm run devA configuration file named env.config.ts will be created in .src/config and server will be listening to the given port.
-
- Create environment file for other scenarios in
envfolder, eg, stage, prod, etc.
- Create environment file for other scenarios in
-
- Add one new command in
package.jsonwith change theNODE_ENVvalue, eg.
- Add one new command in
"stage": "NODE_ENV=stage npm run start-config && nodemon ./src/server.ts --ignore ./uploads",Go to project file-server-angular, build Angular application for production.
npm run prodGo to project file-server-node, build node server for production.
npm run prodThen, copy all frontend files in file-server-angular/dist to file-server-node/dist/wwww.
Copy all backend and frontend files to server.
cd 'file-server-node'
node './dist/src/server.js'Access http://192.168.0.2:12020/.
Find the server process by searching 'node'.
ps aux | grep node
Johnny 3761 0.0 3.2 899840 58356 ? Ssl 07:32 0:03 node ./dist/src/server.jsKill it with PID.
kill -9 3761Build for production. All the compiled html files and js files will be generated in dist.
npm run buildCreate image with node.js.
docker build -t jojozhuang/file-server-node .Create container.
docker run --name file-server -p 12020:80 -v=/var/services/video:/app/root -v=/var/services/web/fullstack-sites/file-server/www:/app/web -d jojozhuang/file-server-nodeAccess http://192.168.0.2:12020/ in browser.