Bahmni Using Docker
WARNING
This page has been Archived, and is obsolete. It is available on the Bahmni wiki only for reference and historical purposes.
Please follow the Running Bahmni on Docker article instead.
Instead of deleting a page, we prefer to "archive" it, so that it is still available to people who have bookmarked the page.
The following step-by-step guide helps you in installing Bahmni using Docker. Docker is an open platform for developers and system admins to build, ship, and run distributed applications. Following instructions are mainly targeted for Mac OS X and Linux users. But they should work with any operating system that supports Docker.
Installing Docker
Installing Docker Compose
Docker-Compose is a tool from Docker which helps in running multi-container application. Bahmni uses multiple software components like tomcat, mysql, pgsql, erp(python), apache. So, the containers are built for each of these components. Docker-compose will help us with composing multiple containers and starting/stopping them together.
Installing Bahmni
For the first time, it takes around 15-25 minutes depending on your internet speed. Please note that it is just for the first time. Subsequently it will be much faster. If this script fails (in rare cases) to download the images from dockerhub-bahmni, you can manually download the required images based on the required images and rerun "sh bahmni install".
Bahmni optional image pull commands
#these are optional commands in case 'bahmni install' could not pull the images
docker pull bahmni/web
docker pull bahmni/apache
docker pull bahmni/mysql
docker pull bahmni/pgsql
docker pull bahmni/erp
The Bahmni installation comes up with its own MySQL and PostgreSQL database backup. You will have a fully functional bahmni up and running.
Please note that you will need to do this installation step only once. Subsequently, you can just start and stop bahmni.
Validating your installation
On Mac OS X / Windows
On Linux
Starting and Stopping Bahmni
Once the installation is complete, the Bahmni will be started
we can start and stop Bahmni using the following commands:
Bahmni Start & Stop
# Bring up the boot2docker. Only for Mac OS X / Windows. Linux should skip this command.
boot2docker up
#starting the containers by navigating it to the profiles that is selected (for e.g. bahmni-docker/profiles/prod)
sh bahmni start
# stopping the containers by navigating it to the profiles that is selected (for e.g. bahmni-docker/profiles/prod)
sh bahmni stop
If you think that you want to re-install everything from scratch, you can run the following command and clean up your setup. This will remove all the changes that you have done to your database. You can follow the step to Install Bahmni for installing a fresh instance.
Bahmni Start & Stop
# stopping the containers
sh bahmni stop
#Clean up your environment
sh bahmni clean
Configuring Bahmni For Development
Create a folder at the location ~/bahmni-code
Checkout the following projects of bahmni
default-config - https://github.com/Bhamni/default-config.git
openmrs-distro-bahmni - https://github.com/Bhamni/openmrs-distro-bahmni
openmrs-module-bahmniapps - https://github.com/Bhamni/openmrs-module-bahmniapps
Build the projects.
Building openmrs-distro-bahmni - Its a maven project. Run the following command. It generates the .omod files required for bahmni
Building openmrs-module-bahmniapps. Go inside
Building bahmni-core omod. Build you changes locally and copy them into docker container, as specified below. ( Optional : Only required if writing code on core.)
The docker-compose.yml file available in each profile has a way of linking the Source folders on your laptop to that of the containers. So, lets say you modify some javascript files in your openmrs-module-bahmniapps then, it gets reflected when you refresh the browser.
Restoring Database ( Optional : Required only when a particular database like JSS, QA is required)
For restoring any new MySQL database, place the sql dump file (extracted one - not tar.gz) in ~/bahmni-code/mysql folder.
In the docker-compose.yml, add the environment variable STARTUP_SQL. When the mysql docker container sees this environment variable, it restores the file available at that path. You will need to restart the docker container for it to pick up the latest database.
Tips & Tricks
Add the following alias in your .bashrc or .zshrc files. These provides some smaller alias(es) to frequently used docker commands:
The command "docker ps" (or alias dps) will give a list of docker processes running. The important information is the container id associated with each docker container.
The command "docker logs -f <containerid>" will list the docker logs. This is very useful for debugging (especially the Web Container which has OpenMRS and OpenELIS)
The command "docker exec -it <containerid> /bin/bash", will take you inside the container. Think of it like SSHing into the box. You can browse through the folders using this command.
Upgrading docker in Mac