Heroku
Contents of this page:
- GitHub Repos
- Deploying to heroku
- My apps
- Free dyno hours
- Upgrade to heroku-22 from heroku-18 (12/10/22)
- Misc Heroku Stuff
- Troubleshooting
- Deploying Dockerised apps
GitHub Repos
- This tic-tac-toe Ruby kata is built in Sinatra and deployed to Heroku via Travis here.
- I documented the Heroku / Travis deployment steps in the readme here.
- This clare-wiki site (this one!) is also deployed via Heroku.
- My Cards Against Humanity answer generator is also deployed via Travis to Heroku.
- My Ruby version of the Mars Rover kata is also deployed via Travis to Heroku.
- I did also have a few simple dockerised sites deployed via Heroku (but I’ve now deleted the apps in Heroku to preserve free dyno hours):
Deploying to heroku
Deploying direct to heroku (Ruby) without a CI tool
For Wordlessly, I didn’t even bother with Travis (or Circle CI). I just deployed direct to heroku, following these instructions:
- Install everything you need to deploy a ruby app to Heroku
- Install heroku command line tools
- Login to heroku:
heroku login
- if you get
bad request
it might mean you forgot to navigate to the project folder first.
- if you get
- Create an app:
heroku apps:create your-app-name
- Run
git push heroku master
(note that even if your main git branch is namedmain
, you still usemaster
in this command)- !! But if you get the error “fatal: ‘heroku’ does not appear to be a git repository”, you need to run
heroku git:remote -a your-app-name
first (fill in your app name).
- !! But if you get the error “fatal: ‘heroku’ does not appear to be a git repository”, you need to run
- Ensure that at least one instance of the app is running:
heroku ps:scale web=1 --app your-app-name
- Open the website:
heroku open --app your-app-name
Database stuff
- For Ruby, PostgreSQL, Sinatra/Rails and heroku see here
Deploying to heroku (Ruby) with Circle CI
If I decide to switch to Circle CI in the future, I think this page for the Circle CI side of things and this page for the Heroku end will probably be useful.
Deploying to heroku (Ruby) with Travis
I documented the Heroku / Travis deployment steps in the tic-tac-toe readme here.
My apps
- See clare-tech: heroku.md
Free dyno hours
- More here
- To see hours used by one app:
- Run
heroku login
and thenheroku ps -a [app-name]
to see how many hours have been used by that app and how many hours you have left in your account. The first two lines of output will tell you (“Free dyno hours…”)
- Run
- To see hours used by all apps:
- Visit the billing page to see a list of all apps and how many hours they’ve used
- To turn off a worker dyno (might be running constantly if there is no web app, for instance if it’s just a docker app - more here):
- Run
heroku login
and thenheroku ps:stop worker -a [app name]
- Run
- To delete a worker dyno (it might keep gettin restarted for various reasons, so stopping it may not be enough):
- Go to the settings page for the app (change url to match app - eg https://dashboard.heroku.com/apps/dotnet-docker-clare/settings)
- Scroll down to bottom and click Delete App
Upgrade to heroku-22 from heroku-18 (12/10/22)
- Find out which apps are using a particular stack (in this case
heroku-18
):heroku login
- (If not already done)
heroku plugins:install apps-table
heroku apps:table --filter="STACK=heroku-18"
- I followed instructions here and here
- This is what I did (on mars-rover, used as test bed):
- I tried using review apps, but it didn’t work:
- I added review apps (info here)
- Pipeline => Settings
- Connect to a github repo
- Add review apps
- I added a new branch
- I added an app.json to the new branch, with
{"stack": "heroku-22"}
in it- Note this only works when upgrading review apps - you can’t use this method to upgrade main app
- I created a PR from that branch
- I went to the Pipeline tab and clicked Create Review app under the PR
- … but this failed when I revbiewed the deployment, and there was no feedback as to why
- I added review apps (info here)
- Do I just clicked the upgrade button in the settings
- This didn’t work - build log showed deploy failed because I was using a vserion of Ruby not supported by the new heroku stack
- So I rolled back:
- find previous release:
heroku login
thenheroku releases -a [app name]
- Roll back to last release using previous stack:
heroku rollback v28
- Check it’s worked by listing all apps using the previous stack (in this case
heroku-18
):- (If not already done)
heroku plugins:install apps-table
- Then
heroku apps:table --filter="STACK=heroku-18"
- (If not already done)
- find previous release:
- I tried using review apps, but it didn’t work:
Misc Heroku Stuff
- There are some heroku-related notes in the Jekyll troubleshooting page on this site.
- HackMcr with Laurent - One True Path: Dropbox\IT Training\Hackathons\HackManchester\2015
- There are lots of heroku-related notes on my Jekyll troubleshooting page.
Troubleshooting
- “No web processes running”. I got this error for ages with the tic-tac-toe-kata (the error was visible in the logs via
heroku logs --tail --app tic-tac-toe-kata
). The solution was to go to the resources section in heroku, then under Free Dynos, click the Edit button (pencil icon) over on the right, and turn the switch on to activate the web dyno.
Deploying Dockerised apps
- Deploying a Docker container to Heroku
- See my tic-tac-toe repo for an example of a Dockerised Sinatra app, was deployed via Heroku here (but I’ve now deleted the app to preserve free dyno hours.).
- See my Docker page for more Docker stuff.
- Deploying an ASP.Net dockerised app to Heroku
- My heroku-deployed dockerised ASP.Net app:
- source code (check readme for notes on things I had to do to get it working)
- it was deployed here but I’ve now deleted the app to preserve free dyno hours.
- I did also have a heroku-deployed dockerised .Net Core web API:
- source code (check readme)
- API was deployed here but I’ve now deleted the app to preserve free dyno hours.
- My heroku-deployed dockerised ASP.Net app: