node.js - How to Dockerizing a Angular 2 web app via node js? -


i tried out finding many ways dockerizing angular 2 web app using node js not yet worked running on local not working on docker container.does have proper dockerfile , package.json file docking angular 2 app.

enter image description here

from node:boron  # create app directory run mkdir -p /usr/src/app workdir /usr/src/app  # install app dependencies copy package.json /usr/src/app/ run npm install  # bundle app source copy . /usr/src/app  expose 5655 cmd [ "npm","start" ] 

site cant reached while accessing

below possible ways found on stack on flow not worked

docker run --rm --name my-container -it -p 8080:4200 -v $(pwd):/var/www -w "/var/www" node npm start 

in package.json kept port dynamic "ng serve -host 0.0.0.0",

and suggest me server need use either nginx or node docking angular 2 web-app

"scripts": {     "start": "node ./bin/www",     "build": "del-cli public/js/app && webpack --config webpack.config.dev.js --progress --profile --watch",     "build:prod": "del-cli public/js/app && ngc -p tsconfig.aot.json && ngc -p tsconfig.aot.json && webpack --config webpack.config.prod.js --progress --profile --bail && del-cli 'public/js/app/**/*.js' 'public/js/app/**/*.js.map' '!public/js/app/bundle.js' '!public/js/app/*.chunk.js' 'assets/app/**/*.ngfactory.ts' 'assets/app/**/*.shim.ts'"   } 

enter image description here

  1. first of suggest run "npm start" @ machine;
  2. and check if after can reach angular app in browser;
  3. if works - need remember @ port angular app served;
  4. add new run section "run npm run build:prod" right before expose line;
  5. set correct port @ section expose;
  6. run container: "docker run --rm --name my-container -it ."
  7. open browser @ http:127.0.0.1:here_port_from_expose_section

here small example: https://github.com/karlkori/dockerized-angular-app

also want add production better use nginx or cloudfront.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -