Wednesday 28 June 2017

Bundling and deploying a full-stack Node app to production and why it confuses me

So I've asked around and there seems to be a consensus among developers: it is best practice to build (pack, bundle, compile, whatever you wanna call it) your source code on your local machine, run tests on the built code and then push the built code, and only the built code, to the production server.Trouble is, I can't figure out how to make this happen in a simple automated way. I normally have my dist folder in .gitignore. So let's say I want to deploy to Heroku automatically from Github every time there is a new commit. Right now Heroku would pull the entire project's source code, install all the dependencies, then it would run a build script before it starts the app. That is the opposite of what everyone tells me is best practice.So, here's my question, how can I automatically deploy my already built code to Heroku? Is there a simple, straightforward way to do it? Or must I use a series of 16 obscure git commands? Right now, my way of deploying may not be best practice, but it is easy and straightforward: change some code in VS Code, commit, push the sync button and ... a few minutes later, boom, my Heroku app has been automatically updated through Github. Can I change my workflow to reflect best practices but still keep it simple?

Submitted June 29, 2017 at 05:22AM by Neoflash_1979

No comments:

Post a Comment