Docker Images


Warning: requires a little bit IT skills

What is Docker?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code. For more details, see opensource.com/resources/what-docker

Installation

Requirements: a recent OS that support Docker (see How to install Docker or Create a VM with Docker-Machine).

Get the docker image

  • Pull the docker image from DockerHub (may take a while depending on your network speed and the traffic)

-

    $ sudo docker pull nmrprocflow/nmrprocflow

Create minimal configuration file:

  • npflow.conf
# The URL root of the PROXY if applicable
PROXY_URL_ROOT=

# Duration (in days) of validity of a session 
# before its destruction (counted from the last change)
PURGESESSIONS=2

# Max ZIP size (Mo)
MAXZIPSIZE=400

# NB CORES (0 means Auto)
CORES=0

# User connexion management
# 0 : no connexion management
# 1 : connexion management based on the /opt/data/conf/userlist file
#     Its structure is one user per line and each line following the format:
#        login;LastName;FirstName;Country;Institution;Email;Password
#     a minimal set of this 'userlist' file could be: npflow;;;;;;nppass
USRCONMGR=0


Create a shell script file (Linux):

#!/bin/bash
MYDIR=`dirname $0` && [ ! `echo "$0" | grep '^\/'` ] && MYDIR=`pwd`/$MYDIR

DATADIR=/opt/data

# nmrspec Container
PORT=8080
IMAGE=nmrprocflow/nmrprocflow
CONTAINER=npflow
CONF=$MYDIR/npflow.conf

CMD=$1

# If you use a local directory, first you have to create the $DATADIR directory
VOLS="-v $DATADIR:/opt/data"

usage() { echo "usage: sh $0 start|stop|ps|restart|logs|update";  exit 1; }

case "$CMD" in
   start)
        # run NMRProcFlow
        sudo docker run -d --env-file $CONF $VOLS -p $PORT:80 --name $CONTAINER $IMAGE

        # show Logs
        sudo docker logs $CONTAINER
        ;;
   stop)
        LIST=$(sudo docker ps -a | grep $IMAGE | cut -d' ' -f1)
        sudo  docker stop $LIST
        sudo  docker rm $LIST
        ;;
   restart)
        ( sh $0 stop; sh $0 start)
        ;;
   logs)
        sudo docker logs $CONTAINER
        ;;
   ps)
        sudo docker ps | head -1
        sudo docker ps | grep $IMAGE
        ;;
   update)
        sudo docker pull $IMAGE
        ;;
   *) usage
      exit 2
esac


Start the application (Linux)

sh ./npflow.sh start


Then, in your favorite web browser, check on (You have to enable JavaScript functionalities within your web browser):

http://<your_vm_host>:8080/npflow/


Stop the application (Linux)

sh ./npflow.sh stop


Status of the application (Linux)

sh ./npflow.sh ps


View logs of the application (Linux)

sh ./npflow.sh logs




NGINX configuration (Linux)

For avanced users: In case you would like to use a proxy server, the better is to install and set NGINX, an HTTP and reverse proxy server.

In the /etc/nginx/conf.d/my-site.conf, you should add three 'location' sections as shown below:

server {
    listen 80 default;
    server_name $host;

    ...

    location /nv/ {
        proxy_pass http://localhost:8080/nv/;
    }

    location /npwatch/ {
        proxy_pass http://localhost:8080/npwatch/;
    }

    location /np/ {
        proxy_pass http://localhost:8080/npflow/;
        proxy_redirect http://localhost:8080/npflow/ $scheme://$host/npflow/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }

    ...

}