TrinotateWeb in a Docker container

TrinotateWeb shows some reports from Trinotate. I know very little about it (please don’t ask me how to run Trinotate or interpret your results), but I wanted to serve up the reports. To make the services we provide to end-users a little more portable and reproducable, we tend to wrap them up as Docker containers. Even if we don’t actually ever move the images/containers between hosts, the Dockerfile acts as ‘runnable documentation’ on how a key part of the service is setup.

We do a similar thing for private instances of SequenceServer when researchers want a convenient interface to BLAST search some of their private (hopefully eventually open !) sequence databases.

The container here is self-contained with the data baked in. You may not want this, but an immutable container containing the analysis is what we wanted.

The code lives here: github.com/MonashBioinformaticsPlatform/bio-service-containers/

Requires:

  • TrinotateAnno.sqlite – the database generated via Trinotate
  • lighttpd.conf (provided) – preconfigured, don’t edit.
FROM debian:buster-slim

ENV TRINOTATE_HOME=/app/Trinotate
ENV TRINOTATE_VERSION=3.1.1

WORKDIR /app

RUN apt-get -y update && \
    apt-get install -y lighttpd libhtml-template-perl libdbd-sqlite3-perl && \
    rm -rf /var/lib/apt/lists/*

# Not required, using Debian packages instead
# RUN apt-get install -y cpanminus build-essential
# RUN cpanm -i DBI && \
#     cpanm -i HTML && \
#     cpanm -i HTML::Template && \
#     cpanm -i DBD::SQLite

ADD https://github.com/Trinotate/Trinotate/archive/Trinotate-v${TRINOTATE_VERSION}.tar.gz Trinotate-v${TRINOTATE_VERSION}.tar.gz
RUN tar xvzf Trinotate-v${TRINOTATE_VERSION}.tar.gz && \
    rm Trinotate-v${TRINOTATE_VERSION}.tar.gz && \
    mv Trinotate-Trinotate-v${TRINOTATE_VERSION} Trinotate

COPY TrinotateAnno.sqlite /data/TrinotateAnno.sqlite 
COPY lighttpd.conf /app/lighttpd.conf

RUN chown -R www-data:www-data /app

EXPOSE 80

ENTRYPOINT ["lighttpd", "-D", "-f", "/app/lighttpd.conf"]

“Production”

On port 4569.

docker run --name DatasetName_Trinotate --restart=always -it -d -p 4569:80 trinotate:dataset_name

Use Apache to forward (proxy) to the container for a nice URL (eg /apps/trinotate/DatasetName), behind .htaccess.

Option: external data and config in a host directory

With a few small edits to the Dockerfile (comment out the Trinotate download and sqlite db COPY), you can instead use an external copy of Trinotate and a database on the host.
You might want this for data that is going to be in flux for a while, before baking it permanently in a container (?).

docker run --name DatasetName_Trinotate --rm -it -d -p 4569:80 -v $(pwd):/app -v /home/perry/bin/Trinotate-Trinotate-v3.1.1/:/app/Trinotate -v $(pwd)/TrinotateAnno.sqlite:/data/TrinotateAnno.sqlite trinotate:dataset_name

Apache config

Use this to forward incoming requests to /apps/trinotate/DatasetName/ -> the port on the Docker container (4569), with a custom htaccess file for Basic Auth.

    # /apps/trinotate/DatasetName
    <Proxy "http://localhost:4569/*">
      Order deny,allow
      Allow from all
      Authtype Basic
      Authname "Restricted Content"
      AuthUserFile /etc/apache2/htaccess/DatasetName
      Require valid-user
    </Proxy>

    RewriteEngine on

    # For TrinotateWeb inside a Docker container - absolute URLs mean /css and /js links break
    # when proxied, unless we use this RewriteCond trick detecting referrer. 
    RewriteCond "%{HTTP_REFERER}" ".*bioinformatics.erc.monash.edu(?:.au)?/apps/trinotate/DatasetName/.*" [NV]
    RewriteRule ^/css/(.*)$ "http://localhost:4569/css/$1" [P]
    RewriteCond "%{HTTP_REFERER}" ".*bioinformatics.erc.monash.edu(?:.au)?/apps/trinotate/DatasetName/.*" [NV]
    RewriteRule ^/js/(.*)$ "http://localhost:4569/js/$1" [P]
    RewriteRule ^/apps/trinotate/DatasetName$ /apps/trinotate/DatasetName/ [R]
    RewriteRule ^/apps/trinotate/DatasetName/(.*)$ "http://localhost:4569/$1" [P]

TrinotateWeb makes requests to https://canvasxpress.org/ – as of 28-Jun-2018 the certificates for HTTPS are currently expired. The user should visit https://canvasxpress.org/ first and accept the insecure certificate so that icons in TrinotateWeb load correctly.