Skip to content

Commit

Permalink
provide sample config files.
Browse files Browse the repository at this point in the history
update readme to include configuration steps for keycloak SSO

Signed-off-by: Jason Sherman <[email protected]>
  • Loading branch information
usingtechnology committed Jan 15, 2024
1 parent af0f5ca commit dc9f381
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 17 deletions.
17 changes: 17 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ Keycloak and Postgresql will be launched using docker compose. These will run in

CHEFS API and Frontend are running as node applications on the devcontainer - again, ports are forwarded to the host.

### Configuring CHEFS locally
When the devcontainer is built, it copies `.devcontainer/chefs_local/local.json.sample` and `.devcontainer/chefs_local/realm-export.json.sample` to `.devcontainer/chefs_local/local.json` and `.devcontainer/chefs_local/realm-export.json` respectively. These copies are not checked in and allow the developer to make changes and tweaks without impacting other developers or accidentially sharing passwords.

### Authorization Prerequisites
1. An IDIR account is required to access CHEFS.
2. Request an SSO Integration from the Common Hosted Single Sign-on (CSS) page in order to obtain a resource and secret that will be used for authentication when building CHEFS. View the [detailed documentation](https://bcdevex.atlassian.net/wiki/spaces/CCP/pages/961675282) about requesting the Pathfinder SSO integration.
3. Open realm-export.json located at chefs_build/docker/imports/keycloak and search for `XXXXXXXXXXXX`. This value must match the `clientSecret` value in `local.json` so that the CHEFS API can connect to your Keycloak instance. By default, these are set to be equal and don’t need to be altered.
4. Navigate to the CSS page, login with your IDIR, and download the ‘Development’ Installation JSON from your SSO Integration.
5. Back in the `realm-export.json` file, search for all instances of `YYYYYYYYYYYY` and replace it with the `resource` you obtained from the downloaded JSON file. Search for all instances of `ZZZZZZZZZZZZ` and replace it with the `secret`.

Note that `CHEFS Frontend` launch configuration is using the `chefs-frontend-local` client in Keycloak, not `chefs-frontend-local` as we do in production.

### Run/Debug
1. start Keycloak and Postgresql. Many ways to start...
- right click on `.devcontainer/chefs_local/docker-compose.yml` and select `Compose up`
- or use command palette `Docker: Compose Up` then select `.devcontainer/chefs_local/docker-compose.yml`
Expand All @@ -38,6 +51,10 @@ CHEFS API and Frontend are running as node applications on the devcontainer - ag
- Run and Debug, select 'CHEFS' which will start both the API and the frontend.
3. debug Frontend with Chrome
- Run and Debug, select 'CHEFS Frontend - chrome' which will start a Chrome browser against the frontend, will allow breakpoints in `/app/frontend/src`
4. stop Keycloak and Postgresql. Many ways to stop...
- right click on `.devcontainer/chefs_local/docker-compose.yml` and select `Compose down`
- or use command palette `Docker: Compose Down` then select `.devcontainer/chefs_local/docker-compose.yml`
- or `Terminal | Run Task...|chefs_local down`

## Troubleshooting
All development machines are unique and here we will document problems that have been encountered and how to fix them.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@
"http://localhost:8080/*",
"http://localhost:8083/*",
"http://localhost:8082/*",
"http://localhost:5173/*",
"https://logon7.gov.bc.ca/clp-cgi/logoff.cgi?retnow=1&returl=https%3A%2F%2Fbcgov.github.io%2Fkeycloak-example-apps"
],
"webOrigins": [
Expand Down
9 changes: 2 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@
}
},

"features": {
// "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
// "version": "20.10",
// "enableNonRootDocker": "true",
// "moby": "true"
// }
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},

Expand All @@ -28,7 +23,7 @@
"forwardPorts": [8082, 8081, 8080, 5432, 5173],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bash ./.devcontainer/post-install.sh",
"postCreateCommand": "bash ./.devcontainer/post-install.sh",

// Configure tool-specific properties.
// "customizations": {},
Expand Down
25 changes: 15 additions & 10 deletions .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,9 @@ set -ex
WORKSPACE_DIR=$(pwd)
CHEFS_LOCAL_DIR=${WORKSPACE_DIR}/.devcontainer/chefs_local

# fire up keycloak and postgres... we want to seed the db
docker compose -f ${CHEFS_LOCAL_DIR}/docker-compose.yml up --wait

# install app libraries, prepare for app development and debugging...
cd app
npm install
# run an initial migration for the db and seed it...
export NODE_CONFIG_DIR=${CHEFS_LOCAL_DIR} # need this to connect to the running postgres instance.
npm run migrate
npm run seed:run

# take down keycloak and postgres, do not need them running all the time.
docker compose -f ${CHEFS_LOCAL_DIR}/docker-compose.yml down

# install frontend libraries, prepare for ux development and debugging...
cd frontend
Expand All @@ -27,3 +17,18 @@ npm install
npm run build:formio
npm run deploy:formio

# copy over the sample files to the image...
cp -u ${CHEFS_LOCAL_DIR}/local.json.sample ${CHEFS_LOCAL_DIR}/local.json
cp -u ${CHEFS_LOCAL_DIR}/realm-export.json.sample ${CHEFS_LOCAL_DIR}/realm-export.json

# fire up keycloak and postgres... we want to seed the db
docker compose -f ${CHEFS_LOCAL_DIR}/docker-compose.yml up --wait
# run an initial migration for the db and seed it...
export NODE_CONFIG_DIR=${CHEFS_LOCAL_DIR} # need this to connect to the running postgres instance.
cd .. # back to app dir
npm run migrate
# npm run seed:run

# take down keycloak and postgres, do not need them running all the time.
docker compose -f ${CHEFS_LOCAL_DIR}/docker-compose.yml down

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ yarn-error.log*
!.vscode/README.md

# devcontainer files
!.devcontainer/chefs_local/*.sample
!.devcontainer/chefs_local/local.json

# temp office files
Expand Down

0 comments on commit dc9f381

Please sign in to comment.