Docker compose
After downloading the CHEFS source code from: https://github.com/bcgov/common-hosted-form-service
Duplicate the file /common-hosted-form-service/app/config/default.json
into a new file called /common-hosted-form-service/app/config/local.json
Make the necessary changes so that the local.json
file looks like:
{
"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": "nr-iit-showcase",
"bucket": "egejyy",
"endpoint": "https://nrs.objectstore.gov.bc.ca",
"key": "chefs/dev/",
"secretAccessKey": "anything"
}
},
"frontend": {
"apiPath": "api/v1",
"basePath" : "/app",
"keycloak": {
"clientId": "chefs",
"realm": "cp1qly2d",
"serverUrl": "http://localhost:8082"
}
},
"server": {
"apiPath": "/api/v1",
"basePath" : "/app",
"bodyLimit": "30mb",
"keycloak": {
"clientId": "chefs-backend",
"realm": "cp1qly2d",
"serverUrl": "http://localhost:8082",
"clientSecret": "XXXXXXXXXXXX"
},
"logLevel": "http",
"port": "8080",
"rateLimit" : {
"public": {
"windowMs": "900000",
"max": "100"
}
}
},
"serviceClient": {
"commonServices": {
"ches": {
"endpoint": "https://ches-dev.apps.silver.devops.gov.bc.ca/api"
},
"cdogs": {
"endpoint": "https://cdogs-dev.apps.silver.devops.gov.bc.ca/api"
},
"tokenEndpoint": "https://dev.oidc.gov.bc.ca/auth/realms/jbd6rnxw/protocol/openid-connect/token",
"username": "CHEFS_SERVICE_CLIENT",
"password": "CHEFS_SERVICE_PASSWORD"
}
}
}
You’ll need the docker-compose file which you can copy from or download from here: https://github.com/jasonchung1871/common-hosted-form-service/blob/dockerize/docker-compose.yml
In the same directory as this docker-compose file, you’ll need to create directories in the following structure:
docker
imports
keycloak
Copy or download the realm-export.json
file from https://github.com/jasonchung1871/common-hosted-form-service/blob/dockerize/docker/imports/keycloak/realm-export.json and place it inside of the docker/imports/keycloak
directory you've just created.
Afterwards, open the realm-export.json
file and change the following settings:
Search for XXXXXXXXXXXX
and you can change this to any value you want. Afterwards, you must copy this value and paste it in your CHEFS configuration so that the CHEFS API can connect to your keycloak instance. You can do this by opening the file /common-hosted-form-service/app/config/local.json
and replacing the value for..
{
...
server: {
...
keycloak: {
...
clientSecret: "XXXXXXXXXXXX"
...
},
...
},
...
}
In the same realm-export.json
file:
Search for YYYYYYYYYYYY
and replace it with the client id you obtained from the Pathfinder SSO page.
Search for ZZZZZZZZZZZZ
and replace it with the client secret you obtained from the Pathfinder SSO page.
Now you can run Keycloak and PostgreSQL by heading into the directory where your docker-compose.yml
file is located and opening a terminal there.
Run the following command:
docker compose up
This will start up an instance for your Keycloak and PostgreSQL containers. If you don’t want to keep the terminal open, you can append a -d
to the end of the command above.
Now open a terminal in the directory /common-hosted-form-service/app
and run the following commands:
This will start the process for the CHEFS API.
Open another terminal in the directory /common-hosted-form-service/app/frontend
and run the following commands:
This will start the process for the CHEFS frontend.