-
Notifications
You must be signed in to change notification settings - Fork 8
HostingOnHeroku
Vianney Doleans edited this page Feb 28, 2023
·
6 revisions
This tutorial explain how to host the API on Heroku.
A tutorial to host BlogCore on Render is available (Render has a free tier).
-
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
- 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 valueHerokuPostgreSQL
- 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
- For example :
- Jwt:Issuer -> https://mydevblogapi.herokuapp.com
- Jwt:Secret -> anAwesomeVerySuperSecretKey
- Jwt:ExpirationInDays -> 2
- For example :
- Create a variable
- Add https://github.com/jincod/dotnetcore-buildpack inside the Buildpacks
- 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
BlogCore - 2021 - up to date