Skip to content

Installation using docker.

Mritunjay Dubey edited this page Sep 18, 2017 · 3 revisions

We recommend using docker to run the application. Here are steps to setup the application using docker on centos 6.

Setup Docker

sudo su
rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum update -y 
yum -y install docker-io

Prepare the local image

Download the image for the bahmni-shiny app from docker hub. It will have the basic app, you need to customize it according to your need, e.g.- setting up properties file. After customization, we will commit it as the base image for the bahmni-shiny for the local use. Below are the steps to do it:-

service docker start
docker run -it mddubey/bahmni-shiny-v1 /bin/bash 

The above command will download the image, and start a new container with that image. It will attach a new shell for that specific container. You need to do below customization in this container.

  • You need to setup properties file. Edit the file /srv/shiny-server/bahmni-shiny/app.properties and put appropriate property values.
  • Setup the passwordless ssh for the shiny account using bahmni_support user. Assuming bahmni_support is the user which will be used to create the ssh tunnel to the database machine.
  • exit from docker container. This will stop the container and you will be back to the host bash session.

Now we will commit this container as our local image, so we won't have to make these changes in new containers.

docker ps -a (Copy the container-id)
docker commit <container-id>  shiny-local
docker rm <container-id>

Setup the shared folder

All the data related to the application will be stored in a folder on the host machine, which will be shared with the Docker container.

cd /var/lib/
mkdir bahmni-shiny
cd bahmni-shiny
mkdir preferences
mkdir plugins (--put all the plugin folders in above plugins folder)
touch shiny.sqlite
sqlite3 shiny.sqlite
create table users(username varchar primary key, password varchar);
insert into users values('demo','$2a$12$aZyMtR.kaSqrpK2h/ID43utwz8bS6g.aovQW9z0/kvhlcnwYPfsfe');
  • The above hash is the result of bcrypt::hashpw('12345') in R, Where 12345 is the password.
  • To give a different password go to R console and run bcrypt::hashpw('<password>') and use the output as password in insert into statement.
  • The above sqlite file path will be the value of sqliteDbFilePath in app.properties.

Create a container with the locally created image

docker run --name shiny-app -it -v /var/lib/bahmni-shiny/:/bahmni-shiny/ -p 3838:3838 shiny-local /bin/bash

The above command creates a new container with

  • name as shiny-app. We will use this name to start/attach the container.
  • The host folder /var/lib/bahmni-shiny/ is mounted as /bahmni-shiny/ in docker container.
  • The port 3838 on docker container is mapped with 3838 on the host machine.
  • It opens the bash in that container.

Run below command in the container to change the owner of the shared folder to the shiny user.

chown -R shiny:shiny /bahmni-shiny/
exit

Start the container & shiny-server

docker start shiny-app
docker exec shiny-app /bin/bash -c "start-shiny.sh"

Upgrading the docker image

To get new features added in the bahmni-shiny app, you will need to upgrade the local image to the latest development version. We will upgrade our container and commit it as our local image.

docker start shiny-app
docker attach shiny-app
    --inside the container
    cd /srv/shiny-server/
    wget https://github.com/ICT4H/bahmni-shiny/archive/master.zip
    unzip master.zip
    cp bahmni-shiny/app.properties bahmni-shiny-master/
    rm -rf bahmni-shiny
    mv bahmni-shiny-master/ bahmni-shiny
    chown shiny:shiny -R bahmni-shiny/
    rm -f master.zip
    cd bahmni-shiny
    R -f install_packages.R
    exit
--commit updated container as base image
docker commit shiny-app shiny-local