diff --git a/Dockerfile b/Dockerfile index b16e9a4..8a83efd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,9 @@ -FROM openjdk:8-jdk-alpine +FROM openjdk:13-jdk-alpine VOLUME /tmp -ARG JAR_FILE +ARG JAR_FILE="build/libs/sifgraph-server*.jar" +ARG DATA_FILE="data.txt.gz" +ENV DATA_URL="file:${DATA_FILE}" COPY ${JAR_FILE} app.jar -ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] +COPY ${DATA_FILE} . +ENTRYPOINT ["java","-Xmx16g","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar", "--sifgraph.data=${DATA_URL}"] +EXPOSE 8080 diff --git a/README.md b/README.md index 60c5f85..ad972c5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,12 @@ on the Pathway Commons' [Extended SIF](http://www.pathwaycommons.org/pc2/formats Clone the repository. See `src/main/resources/config/application.properties` comments; -download the extended SIF data file and update the properties accordingly +download a Pathway Commons Extended SIF data archive and save it as data.txt.gz in this project directory, e.g.: + +```commandline +wget -O data.txt.gz "https://www.pathwaycommons.org/archives/PC2/v12/PathwayComons12.All.hgnc.txt.gz" +``` + (alternatively, set `--sifgraph.data=...`, etc., options at the end of the `java -jar` command (see below), or set `SIFGRAPH_DATA` system variable.) @@ -23,22 +28,55 @@ Build: Run: ```commandline -java -jar build/libs/sifgraph-server-0.3.0.jar -Xmx4g --sifgraph.data="file:/path/to/graph.txt.gz" --server.port=8080 +java -Xmx8g -jar build/libs/sifgraph-server*.jar ``` Note: override the default list of SIF patterns using `--sifgraph.relationships=...` if needed (depends on the data). -If you want to run __different instances__ of the graph server, e.g., for different species, then simply -copy src/main/resources/config/application.properties to the work/current directory, +If you want to run __different instances__ of the graph server, e.g., for different species, then +copy src/main/resources/config/application.properties to the work directory, rename (e.g., my.properties), modify (e.g., set another `server.port`, `sifgraph.relationships` and `sifgraph.data` file), and run as: ```commandline -java -jar build/libs/sifgraph-server.jar --spring.config.name=my +java -Xmx8g -jar build/libs/sifgraph-server*.jar --spring.config.name=my ``` +or + +```commandline +java -Xmx8g -jar build/libs/sifgraph-server*.jar --sifgraph.data="file:" --server.port= +``` + + RESTful API (Swagger docs): Once the app is built and running, the auto-generated documentation is available at `http://localhost:8080/sifgraph/` + + +## Docker +You can also build and run the docker image as follows +(`` - actual port number where the server will run; data file download step above is also required). + +```commandline +./gradlew build +docker build . -t pathwaycommons/sifgraph-server +docker run -it --rm --name sifgraph-server -p :8080 pathwaycommons/sifgraph-server +``` + +Optionally, (a member of 'pathwaycommons' group) can now push the latest Docker image there: + +```commandline +docker login +docker push pathwaycommons/sifgraph-server +``` + +So, other users could skip building from sources and simply run the app: +```commandline +docker pull +docker run -p :8080 -t pathwaycommons/sifgraph-server +``` + +(you can `Ctrl-c` and quit the console; the container is still there running; check with `docker ps`) diff --git a/build.gradle b/build.gradle index dd571f4..7a46418 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { ext { - springBootVersion = '2.1.0.RELEASE' + springBootVersion = '2.2.6.RELEASE' } repositories { maven { @@ -9,7 +9,6 @@ buildscript { } dependencies { classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}" - classpath "gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.20.1" } } @@ -17,7 +16,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' -apply plugin: 'com.palantir.docker' repositories { mavenCentral() @@ -47,15 +45,5 @@ dependencies { sourceCompatibility = 1.8 group = 'pathwaycommons' -version = '0.3.0' +version = '0.3.1' -docker { - dependsOn build - name "${project.group}/${bootJar.baseName}" - files bootJar.archivePath - buildArgs(['JAR_FILE': "${bootJar.archiveName}"]) -} - -task wrapper(type: Wrapper) { - gradleVersion = '4.8.1' -} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 91ca28c..490fda8 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c608d94..6623300 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Nov 19 13:21:17 EST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip \ No newline at end of file diff --git a/gradlew b/gradlew index cccdd3d..2fe81a7 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..62bd9b9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/src/main/resources/config/application.properties b/src/main/resources/config/application.properties index cc3689b..500a6b5 100644 --- a/src/main/resources/config/application.properties +++ b/src/main/resources/config/application.properties @@ -6,9 +6,9 @@ management.endpoints.web.exposure.include=health,info #management.endpoints.web.exposure.exclude= # data location (Pathway Commons Extended SIF format) -#"http://www.pathwaycommons.org/archives/PC2/v10/PathwayCommons10.All.hgnc.txt.gz" +#"https://www.pathwaycommons.org/downloads/PathwayCommons*.All.hgnc.txt.gz" # manually download and use the local file -sifgraph.data=file:/home/igor/Downloads/PathwayCommons10.All.hgnc.txt.gz +sifgraph.data=file:data.txt.gz # comma-separated list of org.pathwaycommons.sif.util.EdgeAnnotationType names used in the text data file; # note: which column names are out there depends on actual input file (it can be customized too); default are: