Skip to content

Development Environment

Sandro Ferreira edited this page Feb 1, 2020 · 1 revision

Setting Up Development Environment

By: Sandro Ferreira - Feb. 02, 2020

Visual Studio Setup

Install ASP.NET and web development workload.

PostgreSQL on Docker

Create Data Volume Container:

docker create -v /var/lib/postgresql/data --name postgres-data busybox

Create Postgresql container:

docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=password -d --volumes-from postgres-data postgres

Database Schema:

Create the database schema using the Database.sql file available on the resources folder.

Database Connection String

Defining the connection string:

In order to match the Heroku connection string, it must be created like this:

<!--Template:-->
postgres://<user>:<password>@<host>:<port>/<database>

<!--Example:-->
postgres://postgres:password@localhost:5432/postgres

Setting the Environment Variables on the Solution:

The environment variables are setted on the launchSettings.json property file. Example:

{
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "DATABASE_URL": "postgres://postgres:password@localhost:5432/postgres"
      }
    },
    "Docker": {
        "commandName": "Docker",
        "launchBrowser": true,
        "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
        "publishAllPorts": true,
        "useSSL": false,
        "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development",
            "DATABASE_URL": "postgres://postgres:password@<psql_container_ip>:5432/postgres"
        }
    }
}