Login
A chronicle of the thoughts, learning experiences, ideas and actions of a tech junkie, .NET, JS and Mobile dev, aspiring entrepreneur, devout Christian and travel enthusiast.
[HOW TO] Deploy your ASP.NET Core 1.x app to Heroku
For this tutorial, I’ll be using Elementary OS 0.4 Loki so the commands would be geared towards my system, but since elementary OS is based off Ubuntu, the same commands would work on Ubuntu. For those using Windows or Mac, I’m sure there are comparable commands for your platform.
Installing Ruby
To make use of the Heroku command line interface, you need to have Ruby installed on your system. So to install Ruby, some prerequisites must be installed and they can be using the following commands:
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
After installing the prerequisites, we’ll install rvm which is the Ruby Version Manager. For that, we’ll install a few more prerequisites that are specific to rvm using the following command:
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
Next, we add the GNU projects’ GPG key to the keyring of your system to allow your system trust content gotten from their allied servers using the command:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
Next, we finally download and install the rvm using the commands below:
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.3.1
Set the installed version as the default
rvm use 2.3.1 --default
Check the version of Ruby installed:
ruby -v
Installing Heroku
Both Windows and Mac OS have installers which can be gotten at https://devcenter.heroku.com/articles/heroku-command-line. But for Ubuntu or Elementary OS, run the following command which would get the debian package and install it:
wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
After it installs, you can verify your Heroku version with the command:
heroku --version
Heroku might prompt you to install the CLI which I did.
Next Steps
Next, you need to login to your Heroku account. And to do that you must have created an account on the Heroku website.After that is done, log in using the command:
heroku login
You’ll be prompted for your email address and password. Enter the appropriate values and wait for the success message telling you that you’re logged in.
Next, you create the build pack. There are some languages which Heroku supports by default and ASP.NET Core is not one of them. But trust the open source community to have created a solution which can be found at http://github.com/bolorundurowb/dotnetcore-buildpack.git. Create your build pack using the command:
heroku create --buildpack https://github.com/bolorundurowb/dotnetcore-buildpack#v1.1.5
Once that is done commit any changes you have made in your repo using the following commands:
git add *
git commit -m “”
Next, push your repo to Heroku using the command:
git push heroku master
If you get an error fatal: ‘heroku’ does not appear to be a git repository, run the following command:
heroku git:remote -a
If you get the error Failed to detect set buildpack https://github.com/bolorundurowb/dotnet-buildpack then make sure your local repo has a project.json
file defined.
If everything goes well, you should see the following screen
Finally, run your new Heroku app using the command:
heroku open
Comments