Docker for SegAnnDB

Revisiting Selenium

Before we dive into how we created docker images for various versions of SegAnnD. I would like to cover recent changes to the tests. As we know we are now using a new OAuth based login system for SegAnnDB, so we needed to fix our selenium tests as well.

In particualar the login test. Making selenium test flow for OAuth based login system is quite easy, as elements are easy to locate. Here is the code for handling the login part -

 # get the email field
        email_field = wait.until(
            EC.element_to_be_clickable((By.ID, "Email")))

        # enter the email of test user
        email_field.send_keys("...")

        # click next
        driver.find_element_by_id('next').click()

        # enter password
        wait.until(EC.presence_of_element_located((By.ID, "Passwd"))).send_keys('...')

        # click next and wait for redirect
        wait.until(EC.presence_of_element_located((By.ID, "signIn"))).click()

Also, a new problem arose while running the test, the iframe on the home page was taking forever to load while running test, so I had to disable that.

That’s it, all the tests start working again! :)

Docker for SegAnnDB

Installing SegAnnDB on a local machine or server is a bit tricky, and can be challenging to new users. Inspired by BioBoxes and our own need we decided to create docker images for SegAnnDB.

Base Image

All docker containers are derived from a base image. In our case we used the Ubuntu 14.04 base image, as it works best with SegAnnDB.

Creating docker image

Now to create a docker image, I first started out with installing all the required packages using apt-get.

Next up we install “pyramid” and either “pyramid_persona” or “seganndb_login” depending on the version of SegAnnDB we wanted to deploy.

After installing these dependencies we clone the code from github and subversion repositories and install them, in particular segannot requires to be installed.

After cloning the github repo we need to execute the following-

  1. mkdir chromlength db secret : These directories hold data generated
  2. wget ./chromlength/hg19.txt.gz http://hgdownload.soe.ucsc.edu/goldenPath/hg19/database/chromInfo.txt.gz
  3. python setup.py install : Install all the dependencies of SegAnnDB
  4. Close the container and commit all the chagnes, using docker commit <container_id> <container/repo:tag>
  5. Start the container again using docker run -it -p 8080:8080 <container_id> Above will bind local port 8080 to containers port 8080
  6. Next inside container, cd SegAnnDB
  7. Remove the content from the directory /usr/local/python2.7//usr/local/lib/python2.7/dist-packages/plotter-2015.11.19-py2.7.egg/plotter
  8. Start the server, using bash recover-restart

In a nutshell the steps are -

apt-get install git python subversion vim wget curl
useradd ubuntu
mkdir /home/ubuntu/
apt-get install python-dev python-setuptools python-numpy python-bsddb3 build-essential python-imaging  db-util
easy_install "pyramid==1.4.5"
easy_install pip
pip install seganndb_login OR easy_install "pyramid-persona==1.5"
cd /home/ubuntu/
svn checkout svn://r-forge.r-project.org/svnroot/segannot/python segannot
cd segannot
python setup.py build
python setup.py install
cd ..
git clone https://github.com/abstatic/SegAnnDB
python setup.py 
rm -rf /usr/local/lib/python2.7/dist-packages/plotter-2015.11.19-py2.7.egg/plotter/*
bash recover-restart.sh

The docker files can be found at my github repository for seganndb-docker

By using the above approach we don’t need to install either apache or WSGI on the container. If we want to run it at port 80 we can also do that while calling docker run

Usage

Docker containers for SegAnnDB are both at about 600MB each.

Getting the container

docker pull abstatic/seganndb or docker pull abstatic/seganndb_gsoc depending on the version you want.

Visit: https://hub.docker.com/u/abstatic/ for more information

Running

Each of the containers contain a (wrapper script)[https://github.com/abstatic/seganndb-docker/blob/master/segann.sh]

You can use this wrapper script to directly run the container using the docker command - docker run -i -t -d -p 8080:8080 abstatic/seganndb segann.sh start

Above will start seganndb container, map your port 8080 to container’s port 8080. You can change the port number to whatever you want, syntax is HOST:CONTAINER

You can use either start or reinitialize as a parameter to segann.sh.

NOTE- Please keep in mind that you always need to commit the container everytime you make changes, otherwise your data will be lost

Comments