Running Bahmni Lite with DB backup from cloud (Docker)
Repositories
Setup
🔹 Git clone the respective Bahmni Lite repository
🔹 Git clone the Bahmni Scripts repository
🔹 Install Docker
DB backup from Kubernetes/AWS
- Get into the openMRS kubernetes pod
kubectl exec -it openmrs<POD_ID> -n <namespace> -- bash2. Navigate to the openmrs/data folder and zip the configuration_checksum folder (which is used by Initializer module to determine if an initializer entry has run or not run).
3. Backup the DB as a SQL dump
# Install mysql cli
yum install mysql
# Export the current live DB as a sql dump to the pod
mysql -u username -p database_name > omrsdb.sql
# Provide password and press Enter
# Exit Mysql
Exit4. Note down the Database details
5. Copy the files to local machine
# Copy the checksums zip to the local
kubectl cp performance/openmrs-<POD_ID>:/openmrs/data/configuration_checksums.zip configuration_checksums.zip
# Copy the sql dump to the local
kubectl cp performance/openmrs-<POD_ID>:/openmrs/data/omrsdb.sql omrsdb.sqlBuild the DB in Docker
- Navigate to ~/bahmni-scripts/demo/db-backups/1.0.0-lite/mysql5.7/resources
2. Delete the files present in this directory
3. Copy and paste the files exported from the pod i.e configuration_checksums.zip and omrsdb.sql to this directory
4. Navigate back to the mysql5.7 directory and replace the Dockerfile contents with the following code:
Apple M1 Chip (Mac)
ARG arch
FROM --platform=linux/amd64 mysql:5.7
#Install the required tools
RUN yum update -y && \
yum install -y \
unzip
#Set the mysql root password
ENV MYSQL_ROOT_PASSWORD=<ROOTPASSWORD>
#Copy configuration_checksums & DB Backup
COPY demo/db-backups/1.0.0-lite/mysql5.7/resources/*.zip .
COPY demo/db-backups/1.0.0-lite/mysql5.7/resources/*.sql /docker-entrypoint-initdb.d/omrs_db_backup.sql
RUN unzip configuration_checksums.zip && \
rm configuration_checksums.zipOthers (Linux)
FROM mysql:5.7
#Install the required tools
RUN yum update -y && \
yum install -y \
unzip
#Set the mysql root password
ENV MYSQL_ROOT_PASSWORD=<ROOTPASSWORD>
#Copy configuration_checksums & DB Backup
COPY demo/db-backups/1.0.0-lite/mysql5.7/resources/*.zip .
COPY demo/db-backups/1.0.0-lite/mysql5.7/resources/*.sql /docker-entrypoint-initdb.d/omrs_db_backup.sql
RUN unzip configuration_checksums.zip && \
rm configuration_checksums.zip5. Navigate to bahmni-scripts root directory and execute the following docker command (note the TAGNAME should be set to some specific value. e.g my-build-1):
docker build --no-cache -t bahmni/openmrs-db:<TAGNAME> -f demo/db-backups/1.0.0-lite/mysql5.7/Dockerfile .Config the environment and docker compose
- Navigate to the bahmni-docker/bahmni-lite or bahmni-india-package directory where the docker- compose.yml is present
2. Add the openMRS DB details captured earlier in DB backup extraction to the .env file and save it. Ensure the OPENMRS_DB_IMAGE_NAME is pointing to the newly created docker image (as generated in the previous step).
# OpenMRS Environment Variables
OPENMRS_IMAGE_TAG=latest
OPENMRS_DB_IMAGE_NAME=bahmni/openmrs-db:<TAGNAME>
OPENMRS_DB_NAME=<DBNAME>
OPENMRS_DB_HOST=openmrsdb
OPENMRS_DB_USERNAME=<DBUSERNAME>
OPENMRS_DB_PASSWORD=<DBPASSWORD>
OPENMRS_DB_CREATE_TABLES='false'
OPENMRS_DB_AUTO_UPDATE='true'
OPENMRS_MODULE_WEB_ADMIN='true'
MYSQL_ROOT_USERNAME=root
# OMRS_DEV_DEBUG_PORT=
OMRS_JAVA_SERVER_OPTS=''
OMRS_JAVA_MEMORY_OPTS=''
OPENMRS_UPLOAD_FILES_PATH=./openmrs-uploads
BAHMNI_OPENMRS_MODULES_PATH=
MYSQL_ROOT_PASSWORD=<ROOTPASSWORD>
OPENMRS_DB_TYPE=mysql
OPENMRS_DOCKER_ENV='true'Invoke Bahmni Lite
- Bring up Bahmni through Docker compose
2. Wait for openmrs to load with all the required indexes
3. Enter “http://localhost/openmrs” in browser and verify openMRS is up
4. Navigate to “http://localhost/” and start using Bahmni (this should now run with the new DB)
Bahmni Wiki · CC BY-SA 4.0