Skip to content

Commit

Permalink
Merge pull request #3 from IgorRodchenkov/master
Browse files Browse the repository at this point in the history
Updated gradle wrapper and fixed Docker build and README.
  • Loading branch information
IgorRodchenkov authored Apr 25, 2020
2 parents 4ca1c33 + e29c4c8 commit e33c692
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 47 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
48 changes: 43 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.)

Expand All @@ -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:<other.file>" --server.port=<otherPort>
```


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
(`<PORT>` - 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 <PORT>: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 <PORT>:8080 -t pathwaycommons/sifgraph-server
```

(you can `Ctrl-c` and quit the console; the container is still there running; check with `docker ps`)
16 changes: 2 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
springBootVersion = '2.1.0.RELEASE'
springBootVersion = '2.2.6.RELEASE'
}
repositories {
maven {
Expand All @@ -9,15 +9,13 @@ buildscript {
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.20.1"
}
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.palantir.docker'

repositories {
mavenCentral()
Expand Down Expand Up @@ -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'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
51 changes: 31 additions & 20 deletions gradlew
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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

Expand All @@ -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" "$@"
21 changes: 20 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e33c692

Please sign in to comment.