Heroku - Pixely-Studios/NStart GitHub Wiki

Helpful Links

Deploying .NET Core to Heroku Deploy ASP.Net Core to Heroku for free using Docker

Initial Steps

Before doing anything, ensure that you have a steady internet connection. We will guide you using predefined steps. Yes, we know you are the Linux master and you love using the Docker CLI, but this guide is intended to beginner-level users.

We are going to host in Heroku our application because we want to create a public instance for free without having to pay a cloud provider like Azure. In our case, it is a great option for creating example sites. Also, you must install Docker.

If you didn't figure it out by now, you need to have a Heroku Account. Also, we will install Heroku CLI and remove that dependance from our head.

Configuring Heroku CLI

In order to use Heroku CLI you have to be authentified. Have your credentials at hand in order to sign up. Open a console and paste the following instruction:

heroku login

This will open up a webpage in your browser in order to authentify you. If you want to enter the credentials manually, use

heroku login -i

Test out the Docker Image

You need to open a console window inside the project folder (the Dockerfile and the SLN files must be visible by the terminal). We must first tell Docker to compile our image using the command:

docker build -t AppName .

Where you can replace AppName with the desired name of the image. To run the new image, use the command:

docker run -d -p 8080:80 --name TrackedName AppName

Where -p will indicate the desired ports to run the application and --name indicates first the name that docker will use to name the image in the CLI and the Desktop Application (in this case is TrackedName), and the following parameter indicates the image that we want to run (in this case, AppName).

You can open a browser window and navigate to localhost to see your app running.

Publish to Heroku

After getting your Heroku credentials and hooking up your CLI to those credentials, it's time that you create a new Heroku app. Go to the app creation page and fill the required parameters. The most important parameter is the appname, this is what is going to let us use the Heroku Containers to deploy the Docker image.

Use your console to log into Heroku containers using the command:

heroku container:login

Then, build the Docker image as indicated in the previous step. With the built Docker image, use the following command to publish into Heroku Containers:

heroku container:push -a AppName web

Where AppName MUST match the name of the application to publish in Heroku and also the Docker image, so we sugest that you build the docker image with the same name as the appname in Heroku. Wait for the upload to complete, and once it is done, use the following command to release your Docker image into the wild west:

heroku container:release -a AppName web

And after that, pop the champagne and go to your app's public address to see the now active dyno instance in Heroku!