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. |
Note that Docker based setup may seem complicated, and difficult, for people who have never worked with Docker.
Please do not refer to this document for Bahmni setup if you are new to Docker, since we may not be able to help you if you have issues. It is recommended to instead refer to Virtual Box (Vagrant) based steps, which are much easier. This document is only for reference for Advanced users who are already familiar with Docker. Instead, please refer this document: Bahmni Virtual Box |
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.
After the above step completes, run 'sudo usermod -aG docker $USER'. This command will add you to the docker group, so that, you can run docker command without needing sudo.
docker |
Download and install the boot2docker package. Complete the installation using default selections. In case you get a message that "Running Virtual Box detected", please shutdown all the vms and restart the installation. Details on understand boot2docker - http://viget.com/extend/how-to-use-docker-on-os-x-the-missing-guide
Set the following environment variables in your .bashrc or .zshrc file (source .bashrc to get your changes reflected)
export DOCKER_HOST=tcp://192.168.59.103:2376 |
Start the boot2docker (installed in previous step) using the following command. The "boot2docker init" command is required only for the first time.
boot2docker init boot2docker up |
Try executing the following command to check if your installation was successful.
docker |
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.
Run the following commands to install docker-compose. Use "sudo su" to login as root and run the following commands
curl -L https://github.com/docker/compose/releases/download/1.4.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose |
Execute the following command to test that your installation was successful.
docker-compose |
Clone Bahmni Docker repository
git clone https://github.com/bhamni/bahmni-docker |
Once cloned, you need to configure the BAHMNI_PROFILE environment variable (export BAHMNI_PROFILE=mrs in your ~/.bashrc or ~/.zshrc). There are multiple options available depending on the way you would like to use Bahmni. Bahmni has OpenERP, OpenMRS and OpenELIS modules. The implementer can choose the modules of Bahmni they are interested and install them. We suggest "prod" profile if you want to work with Bahmni as End user. The following profiles are available. If you want to be a developer, you will have to configure your environment. Please refer to section "Configuring Bahmni For Development"
Once the relevant profile is configured, run the following command from the 'bahmni-docker' directory:
sh bahmni install |
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".
#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.
Give a friendly name to your docker's IP Address. You can add the following line to your /etc/hosts. You might have to open it with "sudo" privilege for editing this file.
/etc/hosts 192.168.59.103 dockerhost |
Once the installation is complete, the Bahmni will be started
we can start and stop Bahmni using the following commands:
# 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.
# stopping the containers sh bahmni stop #Clean up your environment sh bahmni clean |
Building openmrs-distro-bahmni - Its a maven project. Run the following command. It generates the .omod files required for bahmni
mvn clean install |
Building openmrs-module-bahmniapps. Go inside
1. cd ui This application contains Bahmni apps for openmrs. It is an AngularJS application. 2. Install the following modules required globally:
bower install 5. Build the openmrs-module-bahmniapps by running the following command inside "ui" folder grunt |
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.)
This application contains Bahmni customizations (omod) for openmrs. 1. Run the command
2. Copy the generated omod files to the distro folder as mentioned below: cp $BAHMNI_HOME/bahmni-core/bahmnicore-omod/target/bahmnicore-omod-*-SNAPSHOT.omod ~/bahmni-code/openmrs-distro-bahmni/distro/target/distro/bahmnicore-SNAPSHOT.omod cp $BAHMNI_HOME/bahmni-core/openerp-atomfeed-client-omod/target/openerp-atomfeed-client-omod*SNAPSHOT.omod ~/bahmni-code/openmrs-distro-bahmni/distro/target/distro/openerp-atomfeed-client-SNAPSHOT.omod |
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.
mysql: |
Add the following alias in your .bashrc or .zshrc files. These provides some smaller alias(es) to frequently used docker commands:
alias dps="docker ps" de() { docker exec -it "$*" /bin/bash; } |
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
sudo boot2docker upgrade boot2docker ssh sudo /etc/init.d/docker restart
#check the upgraded version docker --version |
When using boot2docker and docker pull is giving timeout, try this:
boot2docker down #Add a rule to forward traffic from 127.0.0.1:2376 to port 2376 on the boot2docker vm: vboxmanage modifyvm "boot2docker-vm" --natpf1 "docker,tcp,127.0.0.1,2376,,2376" boot2docker up $(boot2docker shellinit) export DOCKER_HOST=tcp://127.0.0.1:2376
|
Dev setup using Vagrant and Docker - https://gist.github.com/craigbarrau/05771d6ca28873548c90
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|