Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

Added Dockerfile #326

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ datasets in later releases. An example data layout might be::
Installation
************

There are three different types of installation that we deal with here:
`Deployment`_, `Client tools`_ and `Development`_ installations. A
There are four different types of installation that we deal with here:
`Deployment`_, `Deployment with Docker`_, `Client tools`_ and `Development`_ installations. A
deployment installation is a production server, usually using Apache
or another web server on a dedicated machine. A client tools installation
creates a sandbox in which a user can easily try out the GA4GH client
Expand Down Expand Up @@ -196,6 +196,28 @@ When an error occurs, the details of this will then be printed to the web server
error log (in Apache on Debian/Ubuntu, for example, this is ``/var/log/apache2/error.log``).


----------------------
Deployment with Docker
----------------------

It is also possible to deploy the server using Docker.

- First build the Docker Image. From the server/scripts folder run::

$ docker build .

- Find the id of the recently built image by running::

$ docker images

- Use that id to launch the server::

$ docker run -d -p 8888:80 <id>

This will run the docker container in the background, and translate calls from your host environment
port 8888 to the docker container port 80. At that point you should be able to access it like a normal website.


------------
Client tools
------------
Expand Down
46 changes: 46 additions & 0 deletions scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Base image
FROM ubuntu

# Update the sources list
RUN apt-get update

# Install packages
RUN apt-get install -y tar git curl nano wget dialog net-tools build-essential python python-dev python-distribute python-pip zlib1g-dev python-virtualenv apache2 libapache2-mod-wsgi

# Enable wsgi module
RUN a2enmod wsgi

# Create cache directories
RUN mkdir /var/cache/apache2/python-egg-cache && \
chown www-data:www-data /var/cache/apache2/python-egg-cache/

# Set up GA4GH server
RUN mkdir /srv/ga4gh
WORKDIR /srv/ga4gh
RUN virtualenv ga4gh-server-env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, is there any point in using a virtualenv inside a Docker image?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This blog post has a pretty good discussion about that issue. They seem undecided.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting... I guess we should play with both options and see what works better for us.

RUN /bin/bash -c "source ga4gh-server-env/bin/activate"
RUN pip install git+https://github.com/ga4gh/server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we install from git or from PyPI for the default Docker install? I would say PyPI probably.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current version PyPI server has a wormtable dependency that won't
compile because of a missing header.

On Thu, Apr 2, 2015 at 1:02 AM Jerome Kelleher notifications@github.com
wrote:

In scripts/Dockerfile
#326 (comment):

+# Install packages
+RUN apt-get install -y tar git curl nano wget dialog net-tools build-essential python python-dev python-distribute python-pip zlib1g-dev python-virtualenv apache2 libapache2-mod-wsgi
+
+# Enable wsgi module
+RUN a2enmod wsgi
+
+# Create cache directories
+RUN mkdir /var/cache/apache2/python-egg-cache && \

  • chown www-data:www-data /var/cache/apache2/python-egg-cache/

+# Set up GA4GH server
+RUN mkdir /srv/ga4gh
+WORKDIR /srv/ga4gh
+RUN virtualenv ga4gh-server-env
+RUN /bin/bash -c "source ga4gh-server-env/bin/activate"
+RUN pip install git+https://github.com/ga4gh/server

Should we install from git or from PyPI for the default Docker install? I
would say PyPI probably.


Reply to this email directly or view it on GitHub
https://github.com/ga4gh/server/pull/326/files#r27638512.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK. This will be fixed today, when we tag and upload 0.1.0a3.


# Install relevant sample data
RUN wget http://www.well.ox.ac.uk/~jk/ga4gh-example-data.tar.gz && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using an uncompressed tarball now - you can remove the .gzs and the wormtable deletes.

tar -zxf ga4gh-example-data.tar.gz && rm -r ga4gh-example-data/variants/*.wt

# Write application.wsgi
RUN echo "from ga4gh.frontend import app as application\nimport ga4gh.frontend as frontend\nfrontend.configure(\"/srv/ga4gh/config.py\")" > application.wsgi

# Write config.py
RUN echo "DATA_SOURCE = \"/srv/ga4gh/ga4gh-example-data\"" > config.py

# Write new apache config
WORKDIR /etc/apache2/sites-available
RUN echo "<VirtualHost *:80>\n ServerAdmin webmaster@localhost\n DocumentRoot /var/www/html\n ErrorLog ${APACHE_LOG_DIR}/error.log\n CustomLog ${APACHE_LOG_DIR}/access.log combined\n WSGIDaemonProcess ga4gh python-path=/srv/ga4gh/ga4gh-server-env/lib/python2.7/site-packages python-eggs=/var/cache/apache2/python-egg-cache\n WSGIScriptAlias /ga4gh /srv/ga4gh/application.wsgi\n <Directory /srv/ga4gh>\n WSGIProcessGroup ga4gh\n WSGIApplicationGroup %{GLOBAL}\n Require all granted\n </Directory>\n</VirtualHost>" > 001-ga4gh.conf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to split these long lines? It's a bit hard to read what's going on here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is just running bash commands, perhaps a here document? http://tldp.org/LDP/abs/html/here-docs.html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's been a lot of discussion of heredocs for Dockerfiles -- cf moby/moby#1799 -- but they are still not supported as far as I can tell. It seems like the consensus is to use the ADD command to copy an external file into the image. That has the advantage of readability, but it loses the simplicity of having everything in the one file. It would also be possible to make the Dockerfile more readable by writing lines one at a time, but at the expense of generating an intermediate docker image for every single line added. That adds quite a lot of overhead in building the image.


# Configure apache to serve GA4GH site
WORKDIR /etc/apache2/sites-enabled
RUN rm -f 000-default.conf && ln -s /etc/apache2/sites-available/001-ga4gh.conf 001-ga4gh.conf

# Open port 80
EXPOSE 80

# Start server when container starts
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]