Skip to content

Commit

Permalink
Merge pull request #75 from draeger-lab/config/docker-hub
Browse files Browse the repository at this point in the history
Changing Travis, Gradle and Docker config to use Docker Hub images where possible
  • Loading branch information
mephenor authored Oct 11, 2019
2 parents 88ef4cb + a27d524 commit e9ef82a
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 37 deletions.
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
dist: bionic
language: java
sudo: required
env:
- COMPOSE_FILE=docker-compose.devel.yml
jdk:
- openjdk11
services:
Expand All @@ -14,9 +16,10 @@ before_install:
- git clone https://github.com/SBRG/bigg_models_data
install:
# use current build artifact instead of published version
- printf "FROM openjdk:11-slim\n\nCOPY ModelPolisher.jar /\nCOPY models /models\nCMD \"/bin/sh\"" > docker/java_docker/Dockerfile
- gradle lightJar && mv target/*.jar docker/java_docker/ModelPolisher.jar && cp -r bigg_models_data/models docker/java_docker
- docker-compose up --build -d
- printf "FROM openjdk:11-slim\n\nCOPY ModelPolisher-2.0.1.jar /\nCOPY models /models\nCMD \"/bin/sh\"" > docker/java_docker/Dockerfile
- cp -r bigg_models_data/models docker/java_docker
- gradle devel
- docker-compose up -d
- docker ps -a
before_script:
# wait for both databases to accept connections
Expand All @@ -25,9 +28,9 @@ before_script:
- while ! pg_isready -h 0.0.0.0 -p 1013 > /dev/null; do sleep 1; done
- echo "Databases are up"
script:
- travis_wait docker-compose run java sh -c "java -jar /ModelPolisher.jar --input=/models/ecoli_core_model.xml --output=/models/out/ecoli_core_model.xml --annotate-with-bigg=true --add-adb-annotations=true --output-combine=true && ls -lish models/out"
- travis_wait docker-compose run java sh -c "java -jar /ModelPolisher.jar --input=/models/yeast_7.00.xml --output=/models/out/yeast_7.00.xml --annotate-with-bigg=true --add-adb-annotations=true --output-combine=true && ls -lish models/out"
- travis_wait docker-compose run java sh -c "java -jar /ModelPolisher.jar --input=/models/RECON1.xml --output=/models/out/RECON1.xml --annotate-with-bigg=true --add-adb-annotations=true --output-combine=true && ls -lish models/out"
- travis_wait docker-compose run java sh -c "java -jar /ModelPolisher-2.0.1.jar --input=/models/ecoli_core_model.xml --output=/models/out/ecoli_core_model.xml --annotate-with-bigg=true --add-adb-annotations=true --output-combine=true && ls -lish models/out"
- travis_wait docker-compose run java sh -c "java -jar /ModelPolisher-2.0.1.jar --input=/models/yeast_7.00.xml --output=/models/out/yeast_7.00.xml --annotate-with-bigg=true --add-adb-annotations=true --output-combine=true && ls -lish models/out"
- travis_wait docker-compose run java sh -c "java -jar /ModelPolisher-2.0.1.jar --input=/models/RECON1.xml --output=/models/out/RECON1.xml --annotate-with-bigg=true --add-adb-annotations=true --output-combine=true && ls -lish models/out"
after_script:
- docker-compose down
git:
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<img align="right" src="doc/img/ModelPolisherIcon256.png" width="64"/>

*Authors:* [Andreas Dräger](https://github.com/draeger/), [Thomas J. Zajac](https://github.com/mephenor/), [Matthias König](https://github.com/matthiaskoenig)
*Authors:* [Andreas Dräger](https://github.com/draeger/), [Thomas J. Zajac](https://github.com/mephenor/), [Matthias König](https://github.com/matthiaskoenig), [Kaustubh Trivedi](https://github.com/codekaust)

[![Build Status](https://travis-ci.org/draeger-lab/ModelPolisher.svg?branch=master?style=plastic)](https://travis-ci.org/draeger-lab/ModelPolisher)
[![Stable version](https://img.shields.io/badge/Stable_version-2.0-brightgreen.svg?style=plastic)](https://github.com/draeger-lab/ModelPolisher/releases/)
Expand Down Expand Up @@ -41,7 +41,8 @@ ModelPolisher uses `gradle` to build. Make sure you have `gradle (version >= 5.0

First clone this github project and go to directory `<path>/ModelPolisher/`. Then, ModelPolisher can be built using Gradle. Gradle runs task `lightJar` by default which produces `jar` file, with dependencies, for ModelPolisher in `<path>/ModelPolisher/target/` directory. So, in order to build ModelPolisher run any of following command under `ModelPolisher/` directory:

`gradle lightJar` or `gradle`
`gradle lightJar` or `gradle`
Additionally `gradle devel` is provided to easily run a non-release version with [Docker](#non-release).

NOTE: `lightJar` requires `postgresql` database(s) to be set-up to run ModelPolisher.

Expand Down Expand Up @@ -95,6 +96,13 @@ docker rmi modelpolisher_java:latest modelpolisher_adb:latest modelpolisher_bigg
docker volume prune
```

#### <a name="non-release">Using a non-release jar with Docker</a>

Building using `gradle devel` builds a container with the local ModelPolisher jar.
This container can be used analogously to the release version, though either `-f docker-compose.devel.yml` needs to be
passed to each invocation of `docker-compose` or the `COMPOSE_FILE` environment variable needs to be set so it points
to `docker-compose.devel.yml`, e.g. using `export COMPOSE_FILE=docker-compose.devel.yml` for sh or bash.

## <a name="using-jar"></a>Using ModelPolisher jar
For polishing models, you essentially need to run ModelPolisher using `jar` produced from [build instructions](#build-instructions).

Expand Down
30 changes: 21 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ apply plugin: "java"

defaultTasks "clean", "lightJar"
// Java versions for compilation and output
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
sourceCompatibility = "1.11"
targetCompatibility = "1.11"
archivesBaseName = "ModelPolisher"

version = "2.0"
version = "2.0.1"

sourceSets {
main.java.srcDirs = ["src/main/java"]
Expand All @@ -27,18 +27,18 @@ repositories {
}

dependencies {
compile 'javax.xml.bind:jaxb-api:2.3.1'
compile 'javax.activation:activation:1.1'
compile 'org.glassfish.jaxb:jaxb-runtime:2.3.1'
compile "javax.xml.bind:jaxb-api:2.3.1"
compile "javax.activation:activation:1.1"
compile "org.glassfish.jaxb:jaxb-runtime:2.3.1"
compile "org.sbml.jsbml:jsbml:1.4"
compile "de.zbit:SysBio:1390"
compile "org.xerial:sqlite-jdbc:3.21.0"
compile "org.postgresql:postgresql:42.2.2"
compile "org.biojava:biojava-ontology:5.0.0"
compile 'us.hebi.matlab.mat:mfl-core:0.5.3'
compile "com.fasterxml.jackson.core:jackson-core:2.9.9"
compile "com.fasterxml.jackson.core:jackson-databind:2.9.9.2"
compile group: 'net.sf.jtidy', name: 'jtidy', version: 'r938'
compile "com.fasterxml.jackson.core:jackson-core:2.9.10"
compile "com.fasterxml.jackson.core:jackson-databind:2.9.10"
compile "net.sf.jtidy:jtidy:r938"
compile "de.uni-rostock.sbi:CombineArchive:1.4.0"
testCompile "org.junit.jupiter:junit-jupiter-engine:5.1.0"
}
Expand Down Expand Up @@ -73,6 +73,16 @@ task lightJar(type: Jar) {
with jar
}

//build docker container
task devel(type: Exec){
commandLine "sh", "-c", "cp target/ModelPolisher-" + project.version + ".jar docker/java_docker && " +
"export COMPOSE_FILE=docker-compose.devel.yml && " +
"docker-compose pull && " +
"docker-compose build && " +
"rm docker/java_docker/ModelPolisher-" + project.version + ".jar"
dependsOn lightJar
}

// zip lib folder for release
task zipLibs(type: Zip) {
from "lib"
Expand Down Expand Up @@ -107,6 +117,8 @@ clean.doFirst {
// bump jar version in ModelPolisher.sh
if (project.file("./src/scripts/ModelPolisher.sh").exists()) {
task bumpVersionMP() {
replaceVersion("docker/java_docker/Dockerfile")
replaceVersion(".travis.yml")
replaceVersion("./src/scripts/ModelPolisher.sh")
}
processResources.dependsOn bumpVersionMP
Expand Down
24 changes: 24 additions & 0 deletions docker-compose.devel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ------------------------------------------------
# docker-compose for ModelPolisher development
# run gradle devel first and then docker-compose -f docker-compose.devel.yml run ... or export COMPOSE_FILE and run normally
# ------------------------------------------------
version: '3'
services:
biggdb:
image: mephenor/bigg_docker:1.5
container_name: modelpolisher_biggdb
ports:
- 1310:5432
adb:
image: mephenor/adb_docker:0.1.1
container_name: modelpolisher_adb
ports:
- 1013:5432
java:
build: ./docker/java_docker
container_name: modelpolisher_java
depends_on:
- biggdb
- adb
stdin_open: true
tty: true
9 changes: 5 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# ------------------------------------------------
# docker-compose for ModelPolisher
# docker-compose for ModelPolisher release version
# update docker hub images for new releases and change image accordingly
# ------------------------------------------------
version: '3'
services:
biggdb:
image: mephenor/bigg_docker:1.5
container_name: modelpolisher_biggdb
build: ./docker/bigg_docker
ports:
- 1310:5432
adb:
image: mephenor/adb_docker:0.1.1
container_name: modelpolisher_adb
build: ./docker/adb_docker
ports:
- 1013:5432
java:
image: mephenor/modelpolisher:2.0
depends_on:
- biggdb
- adb
container_name: modelpolisher_java
build: ./docker/java_docker
stdin_open: true
tty: true
9 changes: 5 additions & 4 deletions docker/adb_docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ MAINTAINER [email protected]

RUN adduser --disabled-password --gecos '' adb

RUN apt-get update &&\
apt-get install wget -y &&\
RUN apt-get update && \
apt-get install curl -y && \
# Create directory '/adb_dump/' and download adb-v0.1.1 dump as 'adb-v0.1.1.dump'
wget -P /adb_dump/ https://modelpolisher.s3.ap-south-1.amazonaws.com/adb-v0.1.1.dump &&\
mkdir /adb_dump && \
curl -Lo /adb_dump/adb-v0.1.1.dump https://www.dropbox.com/s/qjiey8y88gt4h0l/adb-v0.1.1.dump?dl=0 && \
rm -rf /var/lib/apt/lists/*

COPY ./scripts/restore_adb.sh /docker-entrypoint-initdb.d/restore_adb.sh

EXPOSE 5432
EXPOSE 5432
7 changes: 4 additions & 3 deletions docker/bigg_docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM postgres:9.6.2
MAINTAINER [email protected]

RUN apt-get update &&\
apt-get install wget -y &&\
RUN apt-get update && \
apt-get install curl -y && \
# Create directory '/bigg_database_dump/' and download bigg_database dump as 'database.dump'
wget -P /bigg_database_dump/ https://modelpolisher.s3.ap-south-1.amazonaws.com/bigg_database.dump &&\
mkdir /bigg_database_dump && \
curl -Lo /bigg_database_dump/database.dump https://www.dropbox.com/s/mem1oa7f258xctf/bigg_database-v1.5.dump?dl=0 && \
rm -rf /var/lib/apt/lists/*

COPY ./scripts/restore_biggdb.sh /docker-entrypoint-initdb.d/restore_biggdb.sh
Expand Down
6 changes: 1 addition & 5 deletions docker/java_docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
FROM openjdk:11-slim
MAINTAINER [email protected]

RUN apt-get update &&\
apt-get install -y wget &&\
wget https://modelpolisher.s3.ap-south-1.amazonaws.com/ModelPolisher-2.0.jar &&\
rm -rf /var/lib/apt/lists/*

COPY ModelPolisher-2.0.1.jar /
CMD "/bin/sh"
4 changes: 3 additions & 1 deletion src/main/java/edu/ucsd/sbrg/bigg/ModelPolisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ private void batchProcess(File input, File output, SBProperties args) throws IOE
processFile(input, output, args);
} else {
if (!output.isDirectory()) {
throw new IOException(format(mpMessageBundle.getString("WRITE_DIR_TO_FILE_ERROR"), input.getAbsolutePath(), output.getAbsolutePath()));
// input == dir && output != dir -> should only happen if already inside a directory and trying to recurse, which is not supported
logger.warning(format(mpMessageBundle.getString("WRITE_DIR_TO_FILE_ERROR"), input.getAbsolutePath(), output.getAbsolutePath()));
return;
}
File[] files = input.listFiles();
if (files == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/edu/ucsd/sbrg/polisher/Messages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
<entry key="VAL_ERROR">No SBML validation possible, process terminated with errors.</entry>
<entry key="VERSION_NR_MISSING">There is no version number provided for this model</entry>
<entry key="WRITE_COMBINE_ARCHIVE">Writing COMBINE Archive {0}</entry>
<entry key="WRITE_DIR_TO_FILE_ERROR">Cannot write inputs from directory {0} to a output file {1}.</entry>
<entry key="WRITE_DIR_TO_FILE_ERROR">Cannot write inputs from directory {0} to a output file {1}. Skipping directory.</entry>
<entry key="WRITE_FILE_INFO">Writing output file {0}</entry>
<entry key="WRITE_RDF_FILE_INFO">Writing output RDF glossary file {0}</entry>
<entry key="WRITE_TO_FILE_ERROR">Cannot write to file {0}.</entry>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/edu/ucsd/sbrg/polisher/Messages_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
<entry key="VAL_ERROR">Keine SBML Validierung möglich. Prozess mit Fehlern beendet.</entry>
<entry key="VERSION_NR_MISSING">Die Versionsnummer für das Model fehlt</entry>
<entry key="WRITE_COMBINE_ARCHIVE">Schreibe COMBINE Archiv {0}</entry>
<entry key="WRITE_DIR_TO_FILE_ERROR">Die Eingabedaten aus dem Verzeichnis {0} können nicht in die Ausgabedatei {1} geschrieben werden.</entry>
<entry key="WRITE_DIR_TO_FILE_ERROR">Die Eingabedaten aus dem Verzeichnis {0} können nicht in die Ausgabedatei {1} geschrieben werden. Überspringe das Verzeichnis.</entry>
<entry key="WRITE_FILE_INFO">Schreibe Datei {0}</entry>
<entry key="WRITE_RDF_FILE_INFO">Schreibe RDF glossary Datei {0}</entry>
<entry key="WRITE_TO_FILE_ERROR">Kann Datei {0} nicht schreiben.</entry>
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/ModelPolisher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd ${DIR}/..

## Launch the program".travis.yml"
java -jar -Xms8G -Xmx8G -Xss128M -Duser.language=en target/ModelPolisher-2.0.jar $@
java -jar -Xms8G -Xmx8G -Xss128M -Duser.language=en target/ModelPolisher-2.0.1.jar $@

exit 0

0 comments on commit e9ef82a

Please sign in to comment.