Skip to content

Configuration

Mike Lyttle edited this page Jul 19, 2022 · 11 revisions

General Setup

Once you have your workstation configured, you will have to perform some additional steps to get a working Health Gateway development environment.

  • Acquire the Health Gateway Code
  • Set Up the Database
  • Configure the Application

Acquire the Health Gateway Code

Open an Ubuntu 20.04 terminal, Windows command window or Mac Terminal/iTerm window.
Navigate to a location where you want the application files to be created or create a new directory which will be referenced as $GATEWAYHOME going forward.

git clone https://github.com/bcgov/healthgateway.git
cd healthgateway

Set Up the Database

Create the Database

From the healthgateway folder navigate to Tools/Dev/Postgres and start the DB:

cd $GATEWAYHOME/Tools/Dev/Postgres/
docker-compose up -d

Which should result in something similar to:

 ~  Projects  …  Tools  Dev  Postgres   dev  $    docker-compose up -d
Creating network "postgres_default" with the default driver
Pulling gatewaydb (postgres:latest)...
latest: Pulling from library/postgres
8559a31e96f4: Pull complete
04866763fec8: Pull complete
1705d51f48e5: Pull complete
e59f13162b50: Pull complete
f34bb6f66594: Pull complete
cbfb60b6801a: Pull complete
e8207269011b: Pull complete
89bccd0fcae0: Pull complete
d3be4c4d3a6e: Pull complete
6593b341f133: Pull complete
b63c7214eb05: Pull complete
a4594bc5ebc6: Pull complete
462172dd94a5: Pull complete
abac28c8c3a0: Pull complete
Digest: sha256:9ba6355d27ba9cd0acda1e28afaae4a5b7b2301bbbdc91794dcfca95ab08d2ef
Status: Downloaded newer image for postgres:latest
Creating gatewaydb ... donedocker-compose up -d

The Postgres docker image will be downloaded and started, approve any Windows prompt that may occur. Confirm the DB is running:

docker ps
docker logs gatewaydb

With output looking like:

 ~  Projects  …  healthgateway  Apps  DBMaintainer   dev  2  $    docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
61e2ea259e41        postgres:latest     "docker-entrypoint.s…"   18 minutes ago      Up 18 minutes       0.0.0.0:5432->5432/tcp   gatewaydb

 ~  Projects  …  Tools  Dev  Postgres   dev  2  $    docker logs gatewaydb
...
PostgreSQL init process complete; ready for start up.

2020-07-21 22:28:10.541 UTC [1] LOG:  starting PostgreSQL 12.3 (Debian 12.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2020-07-21 22:28:10.542 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2020-07-21 22:28:10.542 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2020-07-21 22:28:10.550 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-07-21 22:28:10.568 UTC [65] LOG:  database system was shut down at 2020-07-21 22:28:10 UTC
2020-07-21 22:28:10.572 UTC [1] LOG:  database system is ready to accept connections

Configure the database

Run the initial migrations to create new database tables and other objects:

cd $GATEWAYHOME/Apps/DBMaintainer
dotnet ef database update --project "../Database/src"

Ensure no errors have occurred.

Launch pgAdmin and if its the first time running it then set a master password of your choice.

Create a new configuration by:

  • Right Clicking on Servers in the left pane
  • Clicking on Create then Server
    • General
      • Name: HealthGateway (local)
    • Connection
      • Hostname/address: localhost
      • Maintenance database: postgres
      • Username: gateway
      • Password: passw0rd
      • Save password? checked
  • Click Save

You should be able to connect to the database. Confirm the Health Gateway tables exist by navigating to Servers/HealthGateway (local)/Databases (2)/gateway/Schemas/gateway/Tables

If successful, close pgAdmin.

Configure the Application

If using VS Code, open the workspace file located at $GATEWAYHOME/Apps/HealthGateway.code-workspace
If using Visual Studio 2022 or JetBrains Rider, open the solution file located at $GATEWAYHOME/Apps/HealthGateway.sln

Review each item in section 5 of the main Wiki to configure the individual projects.

VS Code Extensions

These extensions are recommended for working with the Vue front-end projects and will be recommended for installation the first time the .code-workspace is opened:

  • Auto Close Tag
  • Auto Import
  • Auto Rename Tag
  • ESLint
  • GitLens
  • Markdown Preview Enhanced
  • markdownlint
  • Prettier
  • Vetur

These extensions can be added separately to customize the appearance of VS Code:

  • Community Material Theme
  • Material Theme Icons

Code Formatting in JetBrains Rider

If using JetBrains Rider, you can use a code cleanup action to format C# and Razor files according to the project's code style. You can have Rider automatically perform this action whenever the file is manually saved.

You can also configure Rider to automatically format Vue and TypeScript files when they are saved, using eslint --fix, similar to how the Prettier extension works in VS Code.

Open the Rider settings (CTRL+ALT+S on Windows) and navigate to "Actions on Save" under "Tools". There, you can find the "Reformat and Cleanup Code" action and the "Run eslint --fix" action.

actions-on-save-initial

For the code cleanup, you'll want to select our customized profile labelled "HG Full Cleanup". It's configured to only apply changes to C# and Razor files.

To perform the eslint --fix action, you'll need to enable ESLint integration in Rider. There should be an "Enable ESLint..." link that takes you directly to these settings. Adjust them to enable automatic ESLint configuration for files with a "ts" or "vue" extension and to run eslint --fix on save.

eslint-configuration

If you click the "All actions on save..." link, you'll be returned to the settings page and you should now see both actions enabled.

actions-on-save-complete

Clone this wiki locally