How to make a devel enviroment on my app on Heroku - heroku

I wonder now about an option to have a devel version of my project on Heroku address. I mean, I have my project on the address my-random-name.heroku.com and here from my local directory I deploy my app.
Is possible from my local directory deploy my app to the other address, where I would check the new updates and if these updates will be ok, so I will deploy these changes to the my-random-name.heroku.com (here is my "bright" version of my app).

Yes - Heroku applications are just git remotes, so by pushing to a different remote you can deploy to a different application.
For instance:
git remote add production git#heroku.com:appname-production.git
git remote add staging git#heroku.com:appname-staging.git
will then allow you to deploy to each env with a simple push.
git push production master
git push staging master
If you're using different branches for development and production (a good idea) you can also deploy fairly simply

Related

Deploying Angular-fullstack app on Heroku using Codeship

I'm trying to deploy a website via CodeShip unto Heroku. The site is built with Yeoman's Angular-Fullstack generator, which is pushed to GitHub. Codeship detects the push, builds the entire thing and then the trouble start.
Angular-Fullstack is set up so that the dist/ folder contains the entire Heroku app, so blindly deploying everything will not work on Heroku.
Locally, I can use the Heroku toolbelt to login, add a remote inside the dist folder, and then use grunt buildcontrol to deploy the entire thing unto Heroku.
But in Codeship there are a few caveats:
* I cannot install the Heroku toolbelt with wget because it needs sudo and Codeship doesn't support that
* If I could, I couldn't login to Heroku using the CLI because I cannot interact with the shell in Codeship
* I cannot go into the dist/ folder and after adding the remote, simply push to Heroku because I need to enter my credentials.
Is there a way that I missed here? I'd like to let Codeship handle everything from building to deployment to Heroku (only on the master branch).
Figured it out!
I skipped the step where I was trying to install the Heroku Toolbelt, and just added the repo on Heroku as remote:
git remote add heroku ssh://git#heroku.com/[your-heroku-app-name].git
Codeship has public keys available for every build. So, I added that publick key to my Heroku account.
Then I noticed that Git was still trying to push using HTTPS instead of SSH, so I added this to the deployment script:
git config --global url.ssh://git#heroku.com/.insteadOf https://git.heroku.com/
This made sure that Git uses the SSH url for Heroku. I then let Codeship build the entire project and push it with grunt buildcontrol:heroku.

How do I have two different apps on heroku with two different branches on the same repository, while choosing my own app names?

This isn't critical, but annoying.
I have an app that regularly runs as a web server, but uses another app I created to run a rest server with a specific config file if an environment variable is set. (it's simpler than it sounds)
I've used:
heroku create --remote web_server
> created terriblename123.heroku.com
heroku create --remote rest_server
> created existentialcrisis345.heroku.com
and that works, but the apps have weird names. When i go to rename the apps through the web console I get a warning that the remote may break.
Honestly, using this method appears to be very brittle. I don't know how to switch between apps in heroku. There doesn't appear to be state or a way to say which app I'm configuring with the heroku commands.
Just create multiple remotes in same git repository.
For example I have one repository for staging and production heroku app.
~/code/my_app $ git remote -v
origin ssh://git#my_git_server/my_app.git (fetch)
origin ssh://git#my_git_server/my_app.git (push)
production git#heroku.com:my-app-production.git (fetch)
staging git#heroku.com:my-app-staging.git (fetch)
production git#heroku.com:my-app-production.git (push)
staging git#heroku.com:my-app-staging.git (push)
You can name the remotes as you want.
When deploying to heroku, you can specify which heroku app or remote should be used.
heroku push production master or heroku push staging master

Managing Heroku Multiple environments with existing app

I've got an app, that has 'heroku' configured as a remote, to one application.
Let's call this app 'MyAppDev'
However, I have another app, called 'MyAppLive'
I want to configure deployment like this:
git push staging
push to MyAppDev
git push production
push to MyAppLive
How can I do this?
Also, what about environment variables?
Both apps have MongoLab, so I'd like the MyAppDev app to use it's own db....
Here are the steps that you'd need to follow
git remote rm heroku - this will remove the heroku remote from your application
git remote add production <production apps heroku git repo url> - this will add a new remote named 'production' pointing at the production apps git repo url (you can get this from the My Apps page on heroku.com
git remote add staging <staging apps heroku git repo url>
This now means you can do git push production master or git push staging master to push your codebase to either repo.
NOTE If you need to push branches to Heroku you need to push them into the master branch of Heroku.
eg. assuming a staging branch locally you would do;
git push staging staging:master
To push your locally staging branch into master of the staging remote.
Any addons you use would need to be duplicated to the staging application.
Config variables can either be done manually via heroku config:set or you can use the plugin detailed at the bottom of this page https://devcenter.heroku.com/articles/config-vars which allows you to push and pull your Heroku variables into a .env file suitable for running with Foreman locally. Becareful about overriding variables though - I tend to do my variables manually as I don't typically have many.

Only allow 'git push heroku master' from the master branch

I recently set up dev/staging/production environment on OSX Lion. I have a git repo with a development and a master branch, and a Heroku instance with master and staging origins.
The basic workflow is to develop in the development branch, merge into master, deploy to staging, then finally deploy to production.
I'd like to prevent Heroku deployments when I'm in any branch that isn't master, or at a minimum display a warning (e.g. "Would you like to continue? y/n").
Is this possible? Is there a git or Heroku feature that facilitates this, or would I need to write a bash script?
From the Heroku documentation:
Branches pushed to Heroku other than master will be ignored.

Using local configs in a Heroku deployment environment

I'm trying to migrate my app to Heroku - I have a config file that varies with development/staging/production environments as it contains uniquely assigned keys (from Facebook, S3, etc.), so I keep it out of the repository and keep the configs local.
As such I'm trying to find a solution for Heroku to have that config file since Heroku deploys from the repository. I noticed Heroku deploys from the master branch - can it deploy from another branch? Because then I could commit the Heroku configs there, and have it not overwrite the other environments' configs every time it pulls.
Thanks!
I believe Heroku always launches the master branch of the Gt repo, but they support config vars to address exactly this issue.
You can use foreman and heroku-config for this.
Check out the article at heroku dev center:
http://devcenter.heroku.com/articles/config-vars
I love this because you can keep the .env file in .gitignore and shield your production variables from ending up in the repository.

Resources