This is a hello world project.
When the environment variable ASPNETCORE_ENVIRONMENT
has the value DEVELOPMENT
, the application will use the ConnectionString LocalPostgresContext
found in appsettings.json
. Switching the value to PRODUCTION
will make the application use a database supplied via the DATABASE_URL
environment variable.
When the environment variable DEFAULT_ADMIN_USER_CREDENTIALS
is set, the application will create an administrator account with the credentials taken from the environment variable value with format (<email>;<password>
).
For example, setting the environment variable to:
DEFAULT_ADMIN_USER_CREDENTIALS=admin@acme.com;Password1234!
will create an account that has the email admin@acme.com
and password Password1234!
. This account will be added automatically to the Administrator
role.
The account will not be created if a user with that email already exists, but it will be assigned to the Administrator
role.
- You can set the version of the app using the
VERSION
build argument indocker build
.
docker run -e DATABASE_URL={database_url} -dp {external_port}:80 p33-helloworld --build-args=VERSION=1.0.0.1
- You can modify the version in the
dotnet.yml
file.
- Build the container image
docker build -t p33-helloworld .
- Start the app container
docker run -e DATABASE_URL={database_url} -dp {external_port}:80 p33-helloworld
Replace database_url
with a Postgres Database URI (starting with postgres://
).
Replace external_port
with the desired port on the host machine.
Ensure you have the Heroku CLI installed and authenticated.
- Log into the Heroku Container Registry (you only need to run this once)
heroku container:login
- Create an app in Heroku (skip this if you already have created an app)
heroku create
- Build the container image and push it to the Heroku Registry
heroku container:push web
- Provision a Postgres database and add required Environment Variables
heroku addons:create heroku-postgresql:hobby-dev
heroku config:set ASPNETCORE_ENVIRONMENT=Production
- Release the image to the app
heroku container:release web
Created by Fineas Gavre during the Principal33 Internship.