Skip to content

Commit

Permalink
Add devcontainer
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Sherman <[email protected]>
  • Loading branch information
usingtechnology committed Jan 10, 2024
1 parent 7117263 commit 937bb02
Show file tree
Hide file tree
Showing 12 changed files with 3,776 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARG VARIANT="18.18.2-bullseye"
FROM node:${VARIANT}

# not much in here, could acheive this another way for sure...
# but this allows us a prepared place to add other things to the container OS.
30 changes: 30 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Common Hosted Form Service - devcontainer

***fill this in with more detail***

## Purpose
The `devcontainer` is for developers to be up and running with a local version of CHEFS as quickly as possible. In order to run CHEFS you require Keycloak (configured), Postgresql (seeded) and the CHEFS backend/API and frontend/UX. Previously, this was a series of downloads and configuration updates and numerous commands to run.

In this container, we provide a preconfigured Keycloak, standup a Postgresql instance, load all required node libraries for backend and frontend (including building the formio components library) and convenient launch tasks to run and debug CHEFS.

## Running CHEFS locally
Keycloak and Postgresql will be launched using docker compose. These will run inside of the devcontainer (docker-in-docker) but the ports are forwarded to the host machine and are accessible on the local host.

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

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`
- or `Terminal | Run Task...|chefs_local up`
2. start CHEFS
- 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`

## Troubleshooting
All development machines are unique and here we will document problems that have been encountered and how to fix them.

### Failure during load of devcontainer when running webpack (Segmentation Fault)
Encountered on Mac Ventura 13.6, with Mac Docker Desktop 4.26.1 when running `npm run build:formio` on load, we hit a `Segmentation Fault`. The issue was resolved when turning off the virtualization settings in Docker Desktop.

Under Settings, select `gRPC Fuse` instead of `VirtioFS` then unselect `Use Virtualization framework`. Restart Docker and VS Code.
42 changes: 42 additions & 0 deletions .devcontainer/chefs_local/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3.9"
volumes:
postgres_kc_data:
driver: local
services:
postgres:
image: postgres:14.2
volumes:
- postgres_kc_data:/var/lib/postgresql/data
restart: unless-stopped
ports:
- 5432:5432
environment:
- POSTGRES_USER=app
- POSTGRES_PASSWORD=admin
- POSTGRES_DB=chefs
chefs-keycloak:
image: quay.io/keycloak/keycloak:17.0.1
volumes:
- type: bind
source: ./realm-export.json
target: /tmp/realm-export.json
read_only: true
ports:
- 8082:8082
environment:
- DB_VENDOR=POSTGRES
- DB_ADDR=postgres
- DB_USER=admin
- DB_PASSWORD=admin
- KEYCLOAK_ADMIN=admin
- KEYCLOAK_ADMIN_PASSWORD=admin
depends_on:
- postgres
restart: unless-stopped
command:
- "start-dev"
- "--http-port=8082"
- "-Dkeycloak.migration.action=import"
- "-Dkeycloak.migration.provider=singleFile"
- "-Dkeycloak.migration.file=/tmp/realm-export.json"
- "-Dkeycloak.migration.strategy=OVERWRITE_EXISTING"
90 changes: 90 additions & 0 deletions .devcontainer/chefs_local/local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"db": {
"database": "chefs",
"host": "localhost",
"port": "5432",
"username": "app",
"password": "admin"
},
"files": {
"uploads": {
"enabled": "true",
"fileCount": "1",
"fileKey": "files",
"fileMaxSize": "25MB",
"fileMinSize": "0KB",
"path": "files"
},
"permanent": "localStorage",
"localStorage" : {
"path": "myfiles"
},
"objectStorage": {
"accessKeyId": "bcgov-citz-ccft",
"bucket": "chefs",
"endpoint": "https://commonservices.objectstore.gov.bc.ca",
"key": "chefs/dev/",
"secretAccessKey": "anything"
}
},
"frontend": {
"apiPath": "api/v1",
"basePath" : "/app",
"keycloak": {
"clientId": "chefs-frontend-local",
"realm": "chefs",
"serverUrl": "http://localhost:8082"
}
},
"server": {
"apiPath": "/api/v1",
"basePath" : "/app",
"bodyLimit": "30mb",
"keycloak": {
"clientId": "chefs",
"realm": "chefs",
"serverUrl": "http://localhost:8082",
"clientSecret": "XXXXXXXXXXXX"
},
"logLevel": "http",
"port": "8080",
"rateLimit" : {
"public": {
"windowMs": "900000",
"max": "100"
}
}
},
"serviceClient": {
"commonServices": {
"ches": {
"endpoint": "https://ches-dev.api.gov.bc.ca/api",
"tokenEndpoint": "https://dev.loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token",
"clientId": "CHES_CLIENT_ID",
"clientSecret": "CHES_CLIENT_SECRET"
},
"cdogs": {
"endpoint": "https://cdogs-dev.api.gov.bc.ca/api",
"tokenEndpoint": "https://dev.loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token",
"clientId": "CDOGS_CLIENT_ID",
"clientSecret": "CDOGS_CLIENT_SECRET"
}
}
},
"customBcAddressFormioComponent":{
"apikey":"xxxxxxxxxxxxxxx",
"bcAddressURL":"https://geocoder.api.gov.bc.ca/addresses.json",
"queryParameters":{
"echo": false,
"brief": true,
"minScore": 55,
"onlyCivic": true,
"maxResults": 15,
"autocomplete": true,
"matchAccuracy": 100,
"matchPrecision": "occupant, unit, site, civic_number, intersection, block, street, locality, province",
"precisionPoints": 100
}
}
}

Loading

0 comments on commit 937bb02

Please sign in to comment.