This repository consist of bahmni ABDM dockerization related scripts and files.
To build a image, you need to export BAHMNI_VERSION
and GITHUB_RUN_NUMBER
To generate architecture diagram from docker-compose, run sh generate_architecture_diagram.sh
command.
While running this command, arguments can be passed to generate customized diagram. There are three options available:
- --no-networks
- --no-ports
- --no-volumes
Example:
sh generate_architecture_diagram.sh --no-volumes --no-networks
The diagram will be generated in the root directory and if there is any existing diagram it will replace it with the newly generated diagram.
It is recommended to update docker and docker compose to the latest version. Atleast update to a minimum of Docker Compose >2.10.x
-
Clone this repository into your local.
git clone https://github.com/Bahmni-HWC/bahmni-india-package.git
-
Find the local IP address of your machine using
ifconfig
command. You will something likeinet 192.168.1.101 netmask 0xffffff00 broadcast 192.168.1.255
in the command output. Copy the inet IP address. -
Update the value in the .env file for the
HOSTNAME
variable. -
Now start Avni and keycloak by running the following command
docker compose --profile keycloak --profile avni up -d
-
Keycloak will be accessible at http://<<machine_ip>>:8083/keycloak. The default login credentials will be keycloakadmin/keycloak@dmin
-
Wait for Avni to boot up. You can access Avni at http://localhost:8021 or http://<<machine_ip>>:8021
-
Now you can login to Avni superadmin using Username: admin Password: Admin123
-
Also from the database backup, a default organisation named
Bahmni
will also be created with some metadata. The login credentials for the same is admin@bahmni/Admin123. This can also be used to login from mobile app.
-
If you are connecting to a DHCP server or switch networks, then the local IP address may change. In such case update HOSTNAME variable in .env with local IP, restart keycloak and avni service
docker compose restart keycloak
docker compose restart avni
Also remember to update the IP in /etc/hosts as well for minio.avni.local .
Note: The following steps are required only if you want to do some file uploads/metdata uploads within Avni
-
Start MinIo by running the following command
docker compose --profile minio up -d
-
Add an entry in
/etc/hosts
file. Before this find the machine IP as mentioned in step 3 above.Open File in Editor:
sudo nano /etc/hosts
Add below entry to the last of file. Replace Machine_IP with local network IP address of machine.
{Machine_IP} minio.avni.local
-
Now from browser navigate to http://minio.avni.local:9000 and login using default credentials root/root@123
-
Create a bucket from the MinIO console named
avni
. If you use a different file name, make sure to update AVNI_MINIO_BUCKET_NAME variable in .env file. -
Now create an Access Key from MinIO console. On creation copy the access key and secret acess key and replace the
AVNI_MINIO_ACCESS_KEY
andAVNI_MINIO_SECRET_ACCESS_KEY
variables in the .env file. -
After updating recretate Avni containers by running
docker compose --profile avni --profile minio up -d
-
Now when an image is uploaded from a form, you should see that data in the bucket in MinIO console.
Note: Before performing any of the steps mentioned below please setup MinIO by following the steps here.
- Login to Avni as admin@bahmni user
- Navigate to App Designer --> Bundle. Select the
Include Locations
checkbox and then click on Download. - You will get a zip downloaded with the name
Karnataka.zip
. - Copy that zip file to Bahmni-HWC/clinic-config/avni-metadata
- Unzip the zip file by running
unzip Karnataka.zip && rm -f Karnataka.zip
from clinic-config/avni-metadata directory - Commit the changes if any to clinic-config repo
- Clone the Bahmni-HWC/clinic-config repository
- Zip the avni-metadata directory by running
zip -r Karnataka.zip .
from clinic-config/avni-metadata directory. - Now login to your avni instance as admin@bahmni and then navigate to Admin --> Upload
- Under the Upload section, select type as Metadata Zip and click on Choose file and select the Karnataka.zip file created in the above step.
- Once choosen click on Upload button. Now the metadata will be updated.
Avni integration services can be started by running the following command.
docker compose --profile avni-integration up -d
Once the application boots, the integration UI can be accessed at http://localhost:6013/avni-int-admin-app/index.html#/login. Credentials: [email protected]/Admin123
Note: At times when the session expires, the application will not properly redirect to login page. So manually change the URL to http://localhost:6013/avni-int-admin-app/index.html#/login and login again.
When some new mapping is defined, or an existing mapping is modified in Avni Integration Service, then a database backup needs to be taken.
- Once you have tested the changes, stop the avni-integration service by running
docker compose stop avni_integration
. - Exec into the avni_integration_db service by running
docker compose exec -it avni_integration_db bash
- Now connect to the db by running
psql -U avni_int
. - Clear off the markers table by running
delete from markers
and exit the psql. - Now take a db backup by running
pg_dump -U avni_int > /etc/avni_integration_backup_<date>.sql
- Copy to backup_data/avni_integration by running
docker cp <avni_integration_container_id>:/etc/avni_integration_backup_<date>.sql .
from the bahmni-india-package/backup_data/avni_integration directory. - Compress the file by running
gzip avni_integration_backup_<date>.sql
- Commit and push the changes.
Both Avni Server and Avni Integration server has got DEBUG_OPTS variable which opens a Debug port by default to enable debugging from IDE. Avni Server debug port is exposed on 8030 and avni-integration debug port is exposed on 8031.
- Clone the repository which you want to debug and open it in IntelliJ.
- Navigate to Run --> Edit Configurations. In the pop up that opens Click on
+
and create aRemote JVM Debug
Connection. - For avni-server repo enter port as 8030 and for avni-intergration repo enter port as 8031 and save the config.
- Now you can set debug points in code and debug.
-
Install Java 17
-
Run
make build-server
. This will build the source code and produce a JAR. -
Once the build is successful you will see JAR file in integrator/build/libs/ folder of the repo.
-
Now find the container id of the avni-integration service by runnning
docker ps
and copy the ID. -
Now from the integration-service directory, run the following command to copy that JAR into docker container.
docker cp integrator/build/libs/integrator-0.0.2-SNAPSHOT.jar <container_id>:/opt/integrator/integrator.jar
-
Check above copied file with right permission in the container, before restarting the container
docker compose exec -it avni_integration sh
ls -al /opt/integrator/integrator.jar
chown root:root /opt/integrator/integrator.jar
(if permissions are not for root:root for the copied jar)
-
Once copied restart container by running
docker compose restart avni_integration
from bahmni-india-package directory.
- Install Java 8
- Run
make build_server
. This will build the source code and produce a JAR. - Once the build is successful you will see JAR file in avni-server-api/build/libs/ folder of the repo.
- Now find the container id of the avni service by runnning
docker ps
and copy the ID. - Now from the integration-service directory, run the following command to copy that JAR into docker container.
docker cp <container_id>:/opt/openchs/avni-server.jar avni-server-api/build/libs/avni-server-0.0.1-SNAPSHOT.jar
- Once copied restart container by running
docker compose restart avni
from bahmni-india-package directory.
- Avni Bahmni Integration Metadata: https://avni.readme.io/docs/avni-bahmni-integration-specific
- Avni Component Architecture: https://avni.readme.io/docs/component-architecture
- Avni Docker Architecture:
We have organized a folder to store realm data in JSON format for use with the Keycloak service. This JSON file is employed during the initialization of the Keycloak service to automatically generate the specified realm along with its associated users. Manual addition of users to the JSON file is a prerequisite.
- Go inside keycloak container by running
docker compose exec keycloak /bin/sh
- Navigate to
opt/keycloak/bin
directory - Run
./kc.sh export --file <out-file-name> --realm <realm-name>
, it will export the realm data in json format. eg: ./kc.sh export --file realm-export.json --realm On-premise - Copy that output json file to outside the container by running
docker cp <container_id>:/opt/keycloak/bin/realm-export.json .
The Keycloak service uses a default AVNI Keycloak Client Secret for initial setup. To enhance security, follow these steps:
- Access the Keycloak Admin Console.
- Navigate to Clients > Client Details > admin-api > Client Secret.
- Click "Regenerate" for a new secret.
- Update the ENV file with the new secret.
This ensures your Keycloak instance is configured with a custom client secret, bolstering the security of your setup.