Info |
---|
Note, this instruction does not work with CentOS 7.x. This is applicable the current implementation instructions for using Bahmni 0.91 on CentoS 6.9+ |
Warning |
Please note that in this documentation all of Bahmni components get installed into a single docker image. This is not ideal and a better way would be to have different Bahmni components into their own images (and containers), so that one can choose to bring up those components that they need. Bahmni team does want to dockerise Bahmni properly and will welcome contributions in this area. You can look at this OpenMRS Talk discussion on this topic (https://talk.openmrs.org/t/bahmni-and-centos-future/31538) and also see how MekomSolutions has dockerized Bahmni using docker-compose (https://github.com/mekomsolutions/bahmni-docker)Docker. If you want to use the older implementation, please have a look here. |
Docker installations
You can install Docker community edition from here. Choose the appropriate installers for your host machine and follow the instructions mentioned for the host platform.
MacOS: You can get the dmg file for Docker here.
Once you have Docker installed, ensure that you are running the daemon. If you want to tune and configure docker, please find detailed information here
Info |
---|
While it is not mandatory that you have working knowledge of docker (although desirable), at the least you should know the following commands and usages
|
Docker
Setup ProcessStep 1: Create a directory (e.g. dev_dockerFiles) and get the following files and put them in the directory.
- Dockerfile - is a document that contains all the commands to assemble an image, and a way to create an automated build that executes several command-line instructions.
- docker.sh - an utility script to do some basic cleanups and checks and run the docker build and run command.
- db_startup_script.sh - an utility script to setup databases and setup the database configurations and data directories and to restart the services. This also runs every time you start the container.
Make sure the docker.sh file is executable:
Code Block | ||
---|---|---|
| ||
chmod a+x docker.sh |
Info |
---|
Also, this link has more advanced scripts for cloud hosting, which you will obviously need to enhance for your specific security or SSL certificate installations, but should give you enough pointers on how to use on actual production. |
title | Dev:Shared Directory from host |
---|
If you are spinning up for development purpose, chances are that you want to share files or other artefacts between the host and the container. The simplest way to do this, is to share a directory from the host machine as a volume in the container. To do this, edit the docker.sh file, and modify the last line of "docker run ..."
Code Block |
---|
docker run -e container_name=${container_name} -it -d -p ${https_port}:443 -p ${http_port}:80 -p ${erp_port}:8069 -p ${debug_port}:8000 --privileged --name $container_name -v /<bahmni root directory on your host machine>:/bahmni_host -v $container_name:/$container_name bahmni/bahmni_centos67 /bin/bash |
notice the additional volume specified after the "–name $container_name"? Within the container "/bahmni_host" will now be the shared folder with your host machine.
Code Block |
---|
-v /<bahmni root directory on your host machine>:/bahmni_host |
Step 2: In "docker.sh", check and specify version of Bahmni you want to install, what ports to bind and container name that you want to have etc.
Container name: default container914
Code Block | ||
---|---|---|
| ||
export container_name=container914 |
(I like to name the containers by the version of Bahmni I am installing. Notice the name?)
Code Block | ||
---|---|---|
| ||
export rpm_version=0.91-4 |
You can mention a specific version (like above), or the latest (like below)
Code Block | ||
---|---|---|
| ||
export rpm_version=0.91* |
Info |
---|
The above is applicable if you are installing the development versions. You will want to have a fixed version for production! The binaries get downloaded from S3 repo, which is mainly used for development/QA purposes, change the repo to bintray in the Dockerfile. |
Ports: These are the ports that will be bound from your host to the docker container.
Code Block | ||
---|---|---|
| ||
export https_port=443
export http_port=80
export erp_port=8069
export debug_port=8000 |
Inventory: Specifies what components you want installed. The inventory file controls what components of Bahmni gets installed. For example, if you want PACs (dcm4Chee) to be installed, then you should update the inventory file so that "dcm4chee" and "dcm4chee-db" have the location specified, which in this case would just be 127.0.0.1. In this example, the inventory name is set as "aws_qa03" in the docker.sh file.
Code Block | ||
---|---|---|
| ||
export inventory_name=aws_qa03 |
The inventory file gets downloaded from bahmni-tw-playbooks repo. Note, these are sample inventory files. If you want to have your own inventory file, just download one of the inventory files and modify it appropriately locally, and then specify your local file to be used. To do that follow the steps below (assuming you have your local inventory as "local")
a) comment off the below line in "Dockerfile"
Code Block | ||
---|---|---|
| ||
# RUN wget -O /etc/bahmni-installer/local https://raw.githubusercontent.com/Bahmni/bahmni-tw-playbooks/master/inventories/$inventory_name |
b) And add the following line
Code Block | ||
---|---|---|
| ||
ADD local /etc/bahmni-installer/local |
Step 3: Run the following command from the directory you created above ("dev_dockerFiles")
Code Block | ||
---|---|---|
| ||
$ cd dev_dockerFiles
$ sudo ./docker.sh |
Step 4: If all goes alright, your docker container is all set, and you can login to the container
Code Block | ||
---|---|---|
| ||
$ docker exec -i -t <container_name> /bin/bash |
Step 5: Check if Bahmni is running by opening a browser and typing the URL "https://localhost" or "https://localhost/bahmni/home". Also login to the container and see if the servers are running (if you get a message on the browser like 'System down for maintenance').
language | bash |
---|
Compose installations
Note : If you are using Docker Desktop for Mac / Docker Desktop for Windows, then docker-compose comes bundled with docker and you need not follow the below steps. But make sure to disable Experimental Features for docker-compose from your Docker Dashboard preferences.
You can install docker compose from here.
Currently Bahmni has been tested on docker-compose version 1.29.2. If you are using older versions of docker-compose, please upgrade to the latest version. You can check docker compose version by running docker-compose version
Bahmni Docker Setup Process
Step 1: Clone the bahmni-package repository.
Open a terminal and then clone bahmni-package repository and then cd into bahmni-docker directory.
Code Block | ||||
---|---|---|---|---|
| ||||
git clone https://github.com/Bahmni/bahmni-package.git
cd bahmni-package/bahmni-docker/ |
Step 2: Starting the services:
When you want to run all the services of Bahmni you can run the below command from the bahmni-docker directory.
Code Block | ||||
---|---|---|---|---|
| ||||
docker-compose up |
When you want to run only specific services you can do that by specifying profile option.
Code Block | ||||
---|---|---|---|---|
| ||||
docker-compose --profile openmrs up
(or)
docker-compose --profile openmrs --profile openelis up |
Alternatively, you can set the profiles in COMPOSE_PROFILES variable in the .env file.
For a list of different profiles and their respective services, please have a look here.
Step 3: Accessing different services
After running the above command, containers will spin up. You can now go to your browser and navigate to the URL "http://localhost". For the default credentials and application URLs please have a look at the table here.
Step 4: One time setups:
- OpenMRS: Navigate to "http://localhost/openmrs" and login. Now goto Administration → Maintenance → Search Index and then click on
Rebuild Search Index
. - Odoo : Navigate to "http://localhost:8069" and login. Navigate to Apps and then click on Bahmni Account and click on
Upgrade
And assuming all went well, congratulations, you are all set with dockerized bahmniBahmni!
Step 6: Ok, now that everything is up, its a good idea to commit all your changes to the container locally. To do this, follow the suggestion below
Code Block |
---|
$ docker commit <container_name> bahmni/bahmni_centos67:version91401012018 # I like to tag with the version & date that I installed. |
You can then stop/start the container. You can also pause, unpause container to reduce overload on your system
Troubleshooting
Like everything else, things do not go quite alright every time. Following are some of the hiccups we have faced and here are some pointers for resolutions
- Please check the log on the console. Try to find out what went wrong. Ask for help in community channels (slack or OpenMRS talk)
- Try running the script again. Sometimes internet is just flaky, and download of some packages might have failed. Try to go through the console log and see if some warning or error were logged before the eventual step of exit.
- Try to delete the old docker containers and images and re-run the script.
- Try removing the volume.
- Read the fine manual(s) - docker, bahmni etc! Google - chances are someone already came across the same problem.
Check ownership of the mysql data directories. Change to 'mysql' if not
Code Block | ||
---|---|---|
| ||
$ sudo chown -R mysql:mysql /var/lib/mysql |
If the databases are not running, try running the startup script within the container
Code Block | ||
---|---|---|
| ||
$ cd /tmp
$ ./db_startup_script.sh |
stop mysql => setup innodb force recovery in my.cnf => start mysql => stop mysql > change my.cnf to comment off the innodb recovery line => start mysql => start application services.
Code Block | ||
---|---|---|
| ||
$ service mysqld stop
$ vi /etc/my.cnf # add innodb_force_recovery=1 towards the end, save the file
$ service mysqld start # it should go through the restoration process
$ service mysqld stop
$ vi /etc/my.cnf # comment off the innodb_force_recovery line
$ service mysqld start
$ service openmrs start
$ service bahmni-reports start |
The database didn't get installed at all. Few have faced this on Mac and Ubuntu. To check this go to /{container_name}/mysql/ and see if there exists a database "openmrs". If not, then the database didn't get copied for some reason. To fix this, do as described below
Code Block |
---|
$ service openmrs stop
$ service bahmni-reports stop
$ service mysqld stop
$ rsync -avr -o -g /var/lib/mysql /${container_name} # ${container_name) is the name you have given to your container.
$ ls -al /${container_name}/mysql/ # verify that 'openmrs' directory exists
$ service mysqld start
$ service openmrs start
$ service bahmni-reports start |
Its always a good idea to save your container (using docker commit command) above once you have resolved any issues.
Please leave a comment if you find any issues and resolutions. Better still, start a thread on OpenMRS talk channel on Bahmni, or communicate over slack or IRC.
Developer Notes
Assuming that you, as a developer, have set up your docker instance like above and verified applications are running, you probably want to use docker as your developer environment while your primary development (writing code) happens in the host.
Remember that you have mapped your bahmni working above following instructions at this step 1 info? Within the container, "/bahmni_host/" is now the shared directory for your codes checked our in the host bahmni working directory.
Prepare your development machine as described Setting up Bahmni Dev Environment
Working on Bahmni AppsJust like it is described in Setting up Bahmni Dev Environment#CreateLinkstoyourHostMachineFoldersforEMRUI, you want to link up your code from development machine to the running environment in Docker, only difference been the reference-able directory from docker is now "/bahmni_host/". For example, if you want "/var/www/bahmniapps" to point to your code, then create a symlink like
Code Block | ||
---|---|---|
| ||
$ sudo ln -s /bahmni_host/openmrs-module-bahmniapps/ui/app /var/www/bahmniapps |
Code Block | ||
---|---|---|
| ||
$ ln -s /bahmni_host/default-config /var/www/bahmni_config |
- remember you mapped ports in Step 2.4?
5: Stopping bahmni docker:
You can stop containers by just hitting Ctrl+C from the terminal where you have started. You can also run the following command from bahmni-package/bahmni-docker directory.
Code Block | ||||
---|---|---|---|---|
| ||||
docker-compose stop |
Advanced Configurations:
When you want to use Bahmni Docker with advanced configurations or for development purposes, please have a look at the README of bahmni-docker.