less than 1 minute read

Case Study - Deploy docker image to Heroku

Prerequisites

  • Heroku account
  • Docker image

Setup

First we need to instal heroku-cli

After installing do

heroku login

heroku login:container

to finalize heroku local setup.

Figure 1. successful login

Create an app

Go to Heroku apps

And click Create new app

Figure 2. Heroku create-new-app button

Push to container

# Take care that `web` is a process name, for web app it needs to be set to 'web'
heroku container:push web -a agh-train-be

IMPORTANT Application needs to use PORT env variable, in kotlin app it can be done with

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args + "-port=${System.getenv("PORT")}")

Figure 3. Heroku container push logs

Enable startup method

Navigate to Heroku app page

Figure 4. Heroku app panel

Click pencil button, switch toggle, and save.

Figure 5. Heroku app panel

If everything is ok we should see app up and running after clicking Open app

Figure 6. Deployed app

Tags:

  • Deploy for free
  • Free java hosting
  • Free docker hosting
  • Free kotlin hosting
  • Free node hosting