This project is to help understand how to get Node, React and KeyCloak working together. Each project should be hosted in its own container, but the API and web app can be run locally if required.
Before getting start do the following;
- Create a
/api/.envfile and populate it with the following fields;- NODE_ENV="development"
- EXPRESS_PORT=[port]
- NODE_KEYCLOAK_SECRET="[keycloak secret key]"
- NODE_CONNECTION_STRING="[postgresql URL]"
- Using
docker-composeget the environments running - Connect to the KeyCloak admin center
- http://localhost:8080/auth
- Refer to the KeyCloak project README for credentials.
- Create an appropriate Realm, Client and User.
- Copy the
Client>Installationdetails into the/api/config/default.jsonconfiguration file. - Copy the
keycloak.credentials.secretto the/api/.envfileNODE_KEYCLOAK_SECRETenvironment variable.
- Install require packages
>npm install
- If you want to use the
http://localhost:3000/testendpoints you will need to create the database- use the scripts in the
/db/scriptsfolder. These will need to be run against the PostgreSql docker instance (i.e.localhost:54320). Refer to the README for information. create-function-oninsert-rowversion.sql
- use the scripts in the
- Start the API project
To get the environment up and running;
>docker-compose up -d
This will start up the following containers;
- KeyCloak
- KeyCloak PostgreSQL
- PotgreSQL (for Express)
Go to the /api folder workspace and either run it in a container or locally.
>npm run dev
or
>npm start
Open folder in remote container, then run the application. There is an issue currently where running in a container will not allow secure connections