简体   繁体   中英

Angular 4 Production Deployment Workflow

I have a lengthy discussion with a colleague about how we should deploy our angular 4 app to production server.

Would like practical advise and guide on this issue from the community, if possible.

Premise 1
At production server,

git pull
npm install
{set up production configuration}
ng build --prod --aot
  • build and compile on production server
  • production server hardware specs need to support the build process
  • addition space required on hosting server to house node_modules
  • git repo master branch does not have compiled codes, therefore is a "clean source repo"

Premise 2
At production server,

git pull
  • build and compile production codes on local development workstation will be faster
  • git repo master branch will keep snapshot of the compiled codes for deployment
  • production server remains as a 128MB RAM with limited space, since it is to serve html, js and css.
  • faster deployment to another server when required for recovery or scaling, since it is only a git pull

The best way to do it, is to build and compile in the local development Workstation, and deploy only the output of the build.

The git repo master branch needs to contain the source code not the only compiled&built one.

You can deploy in the production server using other method rather then the git pull command but if you insist on using it, you can init a new repo in the /build file and pull this repo to the production server.

If you really can't afford the build farm yet and if it enables the testing or other activites, yeah sure. Test the workflow you describe and see it for yourself, but it's definitely not a good long term practice.

If eventually you're gonna use the CI in your workflow, I would suggest to just start trying to set it up instead of wasting time/money setting up something temporary. Moreover, 5 minutes isn't a big deal trust me.

As a side note: If you would have spent time trying your suggestion instead of writing your SO question and talking with your colleague, you probably would already have figured out the answer yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM