From cf61ad1c2319080ff6d751fd7b420efa2e18e168 Mon Sep 17 00:00:00 2001 From: Jonathan Sharman Date: Tue, 19 Dec 2023 12:09:00 -0800 Subject: [PATCH 1/3] chore: update startup/developer docs --- app/.env.example | 6 +++--- app/README.md | 17 ++++++++++++++++- app/db/setup.sh | 4 ++-- docs/local-development-guid.md | 2 +- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/.env.example b/app/.env.example index ca30050..f043564 100644 --- a/app/.env.example +++ b/app/.env.example @@ -19,8 +19,8 @@ JWT_SECRET=verysecuresecret JWT_TOKEN_EXPIRY=1h PGHOST=localhost PGPORT=5432 -PGUSER= -PGPASSWORD= +PGUSER=postgres +PGPASSWORD=postgres PGDATABASE=realm_registry PGSSL=false APP_ENV=development @@ -39,7 +39,7 @@ TF_GH_REPO= TF_MODULE_GH_REF= GH_ACCESS_TOKEN= GH_API_TOKEN= -DATABASE_URL= +DATABASE_URL=postgresql://postgres:postgres@localhost:5432/realm_registry IDIR_REQUESTOR_USER_GUID= MS_GRAPH_API_AUTHORITY= MS_GRAPH_API_CLIENT_ID= diff --git a/app/README.md b/app/README.md index bdf0fc5..e784ca3 100644 --- a/app/README.md +++ b/app/README.md @@ -2,7 +2,22 @@ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next ## Getting Started -First, run the development server: +In the app folder run: + +Run `make local-setup` + +In the folder `app/db/` run: + +``` +pg_ctl start +./setup.sh +``` + +Create the `.env` file from the `.env.example` file in the app folder. + +The values can be found in the project's non-prod vault file. The local database creds are username "postgres", password is the local password for your database. + +Then run the development server: ```bash npm run dev diff --git a/app/db/setup.sh b/app/db/setup.sh index dc1ca97..1a0522c 100755 --- a/app/db/setup.sh +++ b/app/db/setup.sh @@ -6,6 +6,6 @@ else db="realm_registry" fi -echo "SELECT 'CREATE DATABASE $db' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '$db')\gexec" | psql -d postgres +echo "SELECT 'CREATE DATABASE $db' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '$db')\gexec" | psql -U postgres -d postgres -psql -d $db -f "../../helm/webapp/migration.sql" -qtA --set ON_ERROR_STOP=1 +psql -U postgres -d $db -f "../../helm/webapp/migration.sql" -qtA --set ON_ERROR_STOP=1 diff --git a/docs/local-development-guid.md b/docs/local-development-guid.md index 2c7352f..d970510 100644 --- a/docs/local-development-guid.md +++ b/docs/local-development-guid.md @@ -6,7 +6,7 @@ Run through the steps in [developer guide](./developer-guide.md) ## How to run the project locally -**TO DO** +The local development commands can be found in the [app README](../app/README.md) ## Building and deploying test images. From 67ec60ed2654e5205ee6e2edd4e8482f75e165af Mon Sep 17 00:00:00 2001 From: Jonathan Sharman Date: Tue, 19 Dec 2023 12:14:53 -0800 Subject: [PATCH 2/3] chore: edit env file values --- app/.env.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/.env.example b/app/.env.example index f043564..fed5b78 100644 --- a/app/.env.example +++ b/app/.env.example @@ -1,6 +1,6 @@ SSO_URL=https://dev.loginproxy.gov.bc.ca/auth/realms/standard -SSO_CLIENT_ID=sso-requests -SSO_CLIENT_SECRET=sso-requests-secret +SSO_CLIENT_ID=<> +SSO_CLIENT_SECRET=<> SSO_REDIRECT_URI=http://localhost:3000 SSO_LOGOUT_REDIRECT_URI=http://localhost:3000 SSO_AUTHORIZATION_RESPONSE_TYPE=code From 52575eccb22a97b640f4ee674bd9d6ea33a7a4a5 Mon Sep 17 00:00:00 2001 From: Jonathan Sharman Date: Tue, 19 Dec 2023 13:10:56 -0800 Subject: [PATCH 3/3] chore: update username --- app/.env.example | 6 +++--- app/README.md | 12 +++++++----- app/db/setup.sh | 6 ++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/.env.example b/app/.env.example index fed5b78..826765a 100644 --- a/app/.env.example +++ b/app/.env.example @@ -19,8 +19,8 @@ JWT_SECRET=verysecuresecret JWT_TOKEN_EXPIRY=1h PGHOST=localhost PGPORT=5432 -PGUSER=postgres -PGPASSWORD=postgres +PGUSER= +PGPASSWORD= PGDATABASE=realm_registry PGSSL=false APP_ENV=development @@ -39,7 +39,7 @@ TF_GH_REPO= TF_MODULE_GH_REF= GH_ACCESS_TOKEN= GH_API_TOKEN= -DATABASE_URL=postgresql://postgres:postgres@localhost:5432/realm_registry +DATABASE_URL=postgresql://:@localhost:5432/realm_registry IDIR_REQUESTOR_USER_GUID= MS_GRAPH_API_AUTHORITY= MS_GRAPH_API_CLIENT_ID= diff --git a/app/README.md b/app/README.md index e784ca3..b2b611f 100644 --- a/app/README.md +++ b/app/README.md @@ -6,17 +6,19 @@ In the app folder run: Run `make local-setup` -In the folder `app/db/` run: +Create the `.env` file from the `.env.example` file in the app folder. + +The values can be found in the project's non-prod vault file. The local database creds are username "postgres", password is the local password for your database. + +The CHES config can be changed. If you need to connect to the production CHES the config can be copied from the AWS dev environment variables for the sso-request lambda function. + +Update the '' value with a local postgres username in the `app/db/setup.sh` file. In the folder `app/db/` run: ``` pg_ctl start ./setup.sh ``` -Create the `.env` file from the `.env.example` file in the app folder. - -The values can be found in the project's non-prod vault file. The local database creds are username "postgres", password is the local password for your database. - Then run the development server: ```bash diff --git a/app/db/setup.sh b/app/db/setup.sh index 1a0522c..4659ba8 100755 --- a/app/db/setup.sh +++ b/app/db/setup.sh @@ -6,6 +6,8 @@ else db="realm_registry" fi -echo "SELECT 'CREATE DATABASE $db' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '$db')\gexec" | psql -U postgres -d postgres +postgres_username=<> -psql -U postgres -d $db -f "../../helm/webapp/migration.sql" -qtA --set ON_ERROR_STOP=1 +echo "SELECT 'CREATE DATABASE $db' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '$db')\gexec" | psql -U $postgres_username -d postgres + +psql -U $postgres_username -d $db -f "../../helm/webapp/migration.sql" -qtA --set ON_ERROR_STOP=1