Install PeakForest with Docker

Launch PeakForest WebApps from a Docker container

Documentation for Docker / required image

All informations about Docker (how to install, launch, troubleshot, ...) can be found on the official website - https://docs.docker.com/.

Download the latest PeakForest docker image metabohub/peakforest.

PeakForest files to fetch and filesystem

You need the following folders on your host machine:

  • a webapps one, that contains all PeakForest war files plus the peakforest-rest-X.Y.Z.jar jar file
  • a data one that contains the following folders:
    • cpd-numbered ⇒ contains PNG and MOL file of compounds with a number flag on some atoms (used for NMR spectra peaklist annotation)
    • json ⇒ contains json formatted file used by the main webapp to store informations
    • mol ⇒ contains MOL files of compounds (managed by main webapp)
    • nmr_spectra ⇒ contains raw NMR spectra representations
    • png ⇒ contains PNG files of compounds (managed by main webapp)
    • svg ⇒ contains SVG files of compounds (managed by main webapp)
  • two log-pf and log-tomcat directories to store both PeakForest and Tomcat logs

If you launch the docker on a unix filesystem, make sur that the docker container can read / write data into the logs and data directories.\ On our server the user/group IDs that needed to write files on the host got the ids 102 and 103.

Database configuration

The database configuration can be found here - section 'Database install and configuration'.

You need to edit the hibernate configuration to match this database server IP or DNS entry.

    <!-- JDBC Database connection settings -->
    <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://localhost:3306/peakforest?useSSL=false&amp;serverTimezone=UTC</property>
    <property name="connection.username">peakforest</property>
    <property name="connection.password">peakforest</property>

This hibernate files can be found in the main webapp & rest-v1 war files and in the rest-v2 jar file.\ (you can edit then in the war/jar directly)

Run PeakForest docker container

The -d option run the container as a deamon.

Define the following variable in you bash

  • port_webapps ⇒ the host socket for the tomcat/webapp port forwarding (e.g.: port_webapps=8042)
  • port_rest ⇒ the socket the the rest-v2 app port forwarding (e.g.: port_rest=9042)
  • path_webapps ⇒ webapps directory folder forwarding (e.g.: path_webapps=/path/to/webapps)
  • path_data ⇒ data directory folder forwarding (e.g.: path_webapps=/path/to/data)
  • path_log-pf ⇒ PeakForest Log directory folder forwarding (e.g.: path_webapps=/path/to/log-pf)
  • path_log-tomcat ⇒ Tomcat directory folder forwarding (e.g.: path_webapps=/path/to/log-tomcat)
  • container_name ⇒ the container name / flag
  • log_file ⇒ the optional folder where to keep a log trace of the docker container output (e.g.: log_file=/path/to/docker-container-logs or log_file="/dev/null 2>&1" to not keep them)

(or edit the next launch command line and replace them directly in it)

docker run \
        -d \
        -p $port_webapps:8080 \
        -p $port_rest:8090 \
        -v $path_webapps:/var/lib/tomcat7/webapps \
        -v $path_data:/peakforest/data      \
        -v $path_log-pf:/peakforest/logs     \
        -v $path_log-tomcat:/var/lib/tomcat7/logs     \
        --name $container_name \
        --restart unless-stopped \
        metabohub/peakforest:latest >> $log_file

Optional: use an Apache proxy

You can install and configure apache to redirect all webapp behind the same host/socket.

This configuration require the proxy_module, mod_headers apache modules

        # PROXY CONF for WebApps
                ProxyRequests Off
                ProxyPreserveHost On
                ProxyPass / http://localhost:8042/
                ProxyPassReverse / http://localhost:8042/

            <Proxy *>
                        Order deny,allow
                        Allow from all
            </Proxy>

                <Location />
                        ## optional: you can add an authentication/authorization
                        # Require all denied
                        # Require ip 192.
            ## container docker
            # Require ip 172.17.0
                </Location>
        <Location /doc-v2/openapi-yaml/>
            Header set Access-Control-Allow-Origin "*"
        </Location>

        # PROXY CONF for REST-V2
        <Location /rest/v2/>
            # header cors
                        Header set Access-Control-Allow-Headers "*"
                        Header set Access-Control-Allow-Origin "*"
                        Header set Access-Control-Request-Method "*"
            # docker proxy
                    ProxyPass http://localhost:9042/
                    ProxyPassReverse http://localhost:9042/
        </Location>

Note: we also use apache for the SSL configuration that allow us to access to the webapps using HTTPS.