Skip to content

Commit 6635cc4

Browse files
tpesoutjvivian
authored andcommitted
Issues/263 create rtgtools image (#264)
* issues/223 - first pass at rtg_tools image * fixed unit test * adding command to install tabix (useful for vcfeval work) * rtg-tools fix post code review
1 parent 4190009 commit 6635cc4

File tree

6 files changed

+110
-0
lines changed

6 files changed

+110
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*#*
55
*.idea
66

7+
rtg_tools/runtime/LICENSE.txt

rtg_tools/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Definitions
2+
build_output = runtime/rtg-tools.jar
3+
runtime_fullpath = $(realpath runtime)
4+
build_tool = runtime-container.DONE
5+
git_commit ?= $(shell git log --pretty=oneline -n 1 -- ../rtg_tools | cut -f1 -d " ")
6+
name = quay.io/ucsc_cgl/rtg_tools
7+
tag = 3.8.3--${git_commit}
8+
9+
# Steps
10+
build: ${build_output} ${build_tool}
11+
12+
${build_output}: build/Dockerfile
13+
cd build && docker build -t rtgtoolsbuild .
14+
docker run -v ${runtime_fullpath}:/data rtgtoolsbuild cp /home/rtgtools-protected/rtg-tools.jar /home/rtgtools-protected/LICENSE.txt /data
15+
16+
${build_tool}: ${build_output} runtime/Dockerfile
17+
cd runtime && docker build -t ${name}:${tag} .
18+
-docker rmi ${name}:latest
19+
docker tag ${name}:${tag} ${name}:latest
20+
-docker rmi -f rtgtoolsbuild
21+
touch ${build_tool}
22+
23+
push: build
24+
# Requires ~/.dockercfg
25+
docker push ${name}:${tag}
26+
docker push ${name}:latest
27+
28+
test: build
29+
python test.py
30+
31+
clean:
32+
-rm ${build_tool}
33+
-rm ${build_output}

rtg_tools/build/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM java:8-jdk
2+
3+
MAINTAINER Trevor Pesout, [email protected]
4+
5+
RUN apt-get update && apt-get install -y \
6+
git \
7+
ant \
8+
unzip
9+
10+
# Create a new source directory
11+
WORKDIR /home
12+
13+
# Get RTG tools
14+
WORKDIR /home/rtg-tools
15+
RUN git clone https://github.com/RealTimeGenomics/rtg-tools.git
16+
WORKDIR /home/rtg-tools/rtg-tools
17+
RUN git checkout 3.8.3
18+
19+
# build
20+
RUN ant zip-nojre
21+
22+
# Move jar to currently mounted directory (file is used in the runtime image)
23+
WORKDIR /home/rtgtools-protected
24+
RUN mv /home/rtg-tools/rtg-tools/build/rtg-tools.jar /home/rtgtools-protected/rtg-tools.jar
25+
RUN mv /home/rtg-tools/rtg-tools/LICENSE.txt /home/rtgtools-protected/LICENSE.txt

rtg_tools/runtime/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM java:8-jdk
2+
MAINTAINER Trevor Pesout, [email protected]
3+
4+
RUN apt-get update && apt-get install -y tabix
5+
6+
# Copy over jar and place in /opt/cgl-docker-lib
7+
RUN mkdir /opt/rtg_tools
8+
COPY rtg-tools.jar /opt/rtg_tools/
9+
COPY LICENSE.txt /opt/rtg_tools/
10+
COPY wrapper.sh /opt/rtg_tools/
11+
12+
# Set WORKDIR to /data -- predefined mount location.
13+
RUN mkdir /data
14+
WORKDIR /data
15+
16+
ENTRYPOINT ["sh", "/opt/rtg_tools/wrapper.sh"]

rtg_tools/runtime/wrapper.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Fix ownership of output files
5+
finish() {
6+
# Fix ownership of output files
7+
user_id=$(stat -c '%u:%g' /data)
8+
chown -R ${user_id} /data
9+
}
10+
trap finish EXIT
11+
12+
# Call tool with parameters
13+
java $JAVA_OPTS -jar /opt/rtg_tools/rtg-tools.jar "$@"
14+

rtg_tools/test.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python2.7
2+
# Trevor Pesout
3+
import subprocess
4+
import tempfile
5+
import unittest
6+
7+
8+
class TestRTGTools(unittest.TestCase):
9+
10+
def test_docker_call(self):
11+
out, err = check_docker_output(tool='quay.io/ucsc_cgl/rtg_tools')
12+
self.assertTrue('RTG Tools 3.8.3' in out)
13+
14+
def check_docker_output(tool):
15+
command = 'docker run --rm {} version'.format(tool)
16+
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
17+
output = process.communicate()
18+
return output
19+
20+
if __name__ == '__main__':
21+
unittest.main()

0 commit comments

Comments
 (0)