Skip to content

HostingOnHeroku

Vianney Doleans edited this page Feb 28, 2023 · 6 revisions

Hosting on Heroku

This tutorial explain how to host the API on Heroku.

⚠️ Update : Heroku no longer has a free option.
A tutorial to host BlogCore on Render is available (Render has a free tier).

Heroku

  • Heroku have a free option for non-commercial app (proof of concept, personal projects, etc.).
    • Heroku can also provide the database for free.
  • Heroku is easy to use (automatic deployment from github repository, not much configuration to do).
    • In case of personal project, perfect for saving time.
  • A developer community exists on Heroku

Configuration

  • Create your Heroku app
  • Inside Deploy section, connect the repository with GitHub option.
    • You just have to fork the GitHub repository first and then you can interconnect it with your Heroku app.
  • Inside Resources section, add a Heroku Postgre Add-On.
  • Go to the Settings section
    • Add https://github.com/jincod/dotnetcore-buildpack inside the Buildpacks
      • Enables the use of .NET Core on Heroku
    • Go to Config Vars and click on Reveal Config Vars
      • Create a variable DatabaseProvider with value HerokuPostgreSQL
        • The API will use the DATABASE_URL environment variable of Heroku (DATABASE_URL is automatically set by Heroku when Postgres add-on is provisioned to an app)).
      • You can also override appsettings.json values
  • Follow Create and configure the database in order to initialize the Heroku Postgre database.
    • The explanations to follow are for PostgreSQL database.
    • You just have to specify HerokuPostgreSQL instead of PostgreSQL or MsSQL for "DatabaseProvider": "" and complete "ConnectionStrings": { "Default" : "" } with Heroku postgre Database Credentials
  • Restart your Heroku app.
  • You can now open in a web page https://[YourHerokuAppName].herokuapp.com/swagger/index.html
Clone this wiki locally