简体   繁体   中英

Deploy to Heroku from local, and then later switch to Heroku from Github

I'm about to start building a MEAN stack web app, by first creating the Restful API and then later adding the front-end to it.

Since I plan to deploy this to Heroku, I'd like to integrate with Heroku from the start, using one of the many Heroku tutorials for this. This would all be done from my local computer. (This will be my first time using Heroku).

However, once the app is deployed and production-ready, I want to set up the automated Github integration (continuous deployment), like I've seen in many posts .

I've seen people talk about overwriting an existing Heroku app from Github , but my question is from the opposite angle:

  1. When I switch from using Local Git to Heroku and instead do Github to Heroku, will I have to "redeploy" the whole app from scratch? In other words, will my Github push to Heroku overwrite all of the existing code, or will all the database, setup, etc still be configured?

  2. What is the process to switch from Local Git -> Heroku and instead do Github -> Heroku for the same application?

When I switch from using Local Git to Heroku and instead do Github to Heroku, will I have to "redeploy" the whole app from scratch? In other words, will my Github push to Heroku overwrite all of the existing code, or will all the database, setup, etc still be configured?

I think we need to take a closer look at how deployment works on Heroku.

Enabling the GitHub integration will cause your application to be redeployed whenever you manually deploy from a GitHub branch, or automatically when the branch is updated, depending on how you set it up.

As far as deployment is concerned, this is no different from pushing a new version from your local machine. In both cases, Heroku will compile your application into a new slug , and assuming the build succeeds that slug will be made to run on your dyno formation. Essentially, "all of the existing code" gets replaced on every deploy, regardless of how it's done.

Any client-server¹ databases you have set up shouldn't be affected by the deploy. They exist outside of your application slug.

Heroku encourages users to get configuration from the environment . If you follow that guideline, deploying a new version shouldn't affect your configuration either. Environment variables set up on one version of an app remain in place after a new version is deployed, regardless of whether it's done via git push or GitHub integration.

In short, very little changes about how your application gets deployed when you enable GitHub integration². You can even deploy from your local machine via git push without disabling the GitHub integration if you want.

If you get comfortable with Heroku's architecture and deploy process locally you should have very little trouble when you enable GitHub integration.

What is the process to switch from Local Git -> Heroku and instead do Github -> Heroku for the same application?

Just enable it and follow the instructions. You'll be asked to authorize Heroku to interact with GitHub for you. "Switching" doesn't have any impact on this process (and in fact isn't really accurate: you're enabling a second way of deploying, not switching).


¹File-based databases like SQLite won't work on Heroku due to its ephemeral filesystem .

²Refs aren't created in Heroku's Git server for code deployed directly from GitHub. Ie, if you deploy from GitHub and then git fetch from Heroku you won't see anything new from GitHub. Of course, you can still use Git to push , fetch , and pull directly to and from GitHub.

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