codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Follow publication

Deploy a Containerized ASP.NET Core App to Heroku using GitHub Actions

Changhui Xu
codeburst
Published in
7 min readOct 21, 2019

In this blog post, we will create a containerized ASP.NET Core 3 Web API project, and set up a CI/CD pipeline using GitHub Actions. In the GitHub workflow, we will build and test the Web API project, and deploy the final docker image to Heroku.

There are only several (not many, unfortunately) free hosting providers that support containerized ASP.NET Core applications. One of them is ZEIT, which offers *.now.sh domain names. Another one is Heroku, which is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud. In this project, we will host our application in Heroku, which provides *.herokuapp.com domain names.

Prerequisite

I assume you have already built an ASP.NET Core application. If not, please follow the tutorial (link) to create a Web API project, and follow the tutorial (link) to create a unit testing project. Moreover, you can follow this tutorial (link) to add Swagger support for your API documentation.

I have created a simple ASP.NET Core 3 Web API project, called “Colors.API”, and a unit testing project, called “Colors.UnitTests”. The complete solution can be found in this GitHub repository. (UPDATE: the solution has been updated to ASP.NET Core 5.0.)

In the following sections, we are going to
(1) add a Dockerfile to containerize our application,
(2) create an app in heroku.com,
(3) add a GitHub workflow to build a docker image for our application, publish the image to the Heroku container registry, and release it to a container hosting environment in heroku.com .

Containerize the ASP.NET Core Application

Let’s add a file named “Dockerfile” and a file named “.dockerignore” to the root of this solution. The following screenshot shows the folder tree structure.

The content of the .dockerignore file can be found here. Each item in the .dockerignore file will be disregarded by the…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Published in codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Written by Changhui Xu

Lead Application Developer. MBA. I write blogs about .NET, Angular, JavaScript/TypeScript, Docker, AWS, DDD, and many others.

Responses (2)

Write a response