Working with Source Code
Use the project sunbird-rc-core, java folder in it contains all the modules of registry as well as claims service
Java Version
JDK version 1.8
Compiling The Registry
Run the configure-dependencies.sh
script in the root of the repo as follows:
Then compile the registry (this will take some time when you are running it for the first time):
This should create a JAR file in the java/registry/target
folder.
Configuring Schemas
Create _schemas/
folder in java/registry/src/main/resources/public/
Place all your schema files in the java/registry/src/main/resources/public/_schemas/
folder.
A sample set of schemas for a simple student-teacher registry can be found here. You can learn how to write your own schemas by following this guide.
Install dependencies and Run Application
Change directory to java
Run
./mvnw clean install
Setup the Database and other feature dependent services
Use the required environment variables
These are the minimum required envs to run the application -
connectionInfo_uri, connectionInfo_username, connectionInfo_password, authentication_enabled
Environment variables starting with connectionInfo_ are for the database. Check the configurations for more detailed environment variables description
Check the registry service in docker-compose.yml file at the project folder for example and references
Rest of the environment variables depends on the features enabled
Run the spring boot application
SunbirdRCApplication
in packagedev.sunbirdrc.registry.app
, Use the IDE to configure and run or follow below steps -cd to registry package
Export the environment variables
Run
../mvnw spring-boot:run
Configuring Feature Services
The feature services can be run anywhere and should be available to where we run. For local development, these can be run using docker-compose.yml file present in the project directory.
Check the configurations to configure environment variables for specific services. below are most of the services used and how they can be enabled and used -
Encryption Service - encryption_enabled is true
Id Gen Service - idgen_enabled is true
All Credentials services -
When signature_enabled is set to true
Make sure to set did_enabled as true
certificate_enabled should be set to true to generate pdfs
signature_provider is set to dev.sunbirdrc.registry.service.impl.SignatureV2ServiceImpl
check the other envs starting with signature_v2_ and did_ in the configuration are set by default in the docker-compose.yml file
Old Credentialing services -
When signature is enabled and
signature_provider is set to dev.sunbirdrc.registry.service.impl.SignatureV2ServiceImpl
Keycloak Service -
check environment variables starts with sunbird_sso_ sunbird_keycloak and auth2_resource
ElasticSearch Service -
ElasticSearch version supported is v6
Required when search_providerName is set to dev.sunbirdrc.registry.service.ElasticSearchService
Use environment variables starting with elastic_search_ for custom configurations
Claims Service -
When claims_enabled is set to true
File Storage Service-
When filestorage_enabled is set as true
Check config starting with filestorage_ to configure
This uses minio, so it can be a cloud storage like s3 as well or a local minio service
Kafka & Zookeeper Service -
When using asynchronous features
async_enabled for creating entities asynchronously
Or when event_enabled for metrics service
Or when notification_enabled and notification_async_enabled are set to true
Metrics Service -
When event_enabled is set to true, check envs start with event_ to configure
Notification Service -
When notification_enabled is set to true, check envs start with notification_ to configure
Redis Service -
When using manager_type as DistributedDefinitionsManager
Check redis_ envs to configure
Configure And Start Dependent Services
Run the following in terminal to download this Docker Compose file:
To download a minimal keycloak configuration, run the following:
Then start Keycloak (kc
), Postgres (db
), Elastic Search (es
) and the Claims Service (cs
) by running the following command:
Configuring Keycloak Secret
Before we can start the registry, we need to regenerate and retrieve the client secret for the admin-api
client in Keycloak. To do that, follow these steps:
Go to http://localhost:8080/auth/admin/master/console/#/realms.
Login using the username
admin
and passwordadmin
.Click
Sunbird RC
.Click
Clients
in the panel on the left.Click
admin-api
.Click the
Credentials
tab.Under
Client Secret
, clickRegenerate Secret
. Copy the secret that you see in the box and paste it in thedocker-compose.yml
file in place ofINSERT_SECRET_HERE
on line 42.
Setting Keycloak For Authentication
Let's say we use http://localhost:8080/auth to generate the token
Then use the above url to set as frontend url in keycloak and restart the registry service
Steps to set frontend url
Login to keycloak ui
Select realm sunbird-rc
Select general settings tab
Check for the field frontend url
Set as http://localhost:8080/auth
It should be changed when deploying as per DNS used to generate a token
Running The Registry Using Jar
Once you have completed all the above steps, run the registry using the following command:
Troubleshooting
Prisma Migration Issue
It occurs due to prisma migration tables are not set and the database is not empty.
If it is possible to cleanup the database, then cleanup the database and then setup the identity service first.
To fix in the production or where cleanup of the database is not possible, use this link https://www.prisma.io/docs/orm/prisma-migrate/workflows/baselining to baseline the database and restart the identity, credential-schema, credential services.
Last updated