-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathphylociraptor-docker
executable file
·60 lines (52 loc) · 1.94 KB
/
phylociraptor-docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
if [[ ! -d results ]]
then
mkdir results
fi
if [[ ! -d .snakemake ]]
then
mkdir .snakemake
fi
if [[ ! -d .tmp ]]
then
mkdir .tmp
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
HT="darwin"
US="root"
else
HT="linux"
US=$USER
fi
# try to infer version for tagging docker image
if [[ -f .version ]];
then
VER=$(head -n 1 .version)
else
VER="unkown"
fi
if [[ "$(docker images -q reslp/phylociraptor:$VER 2> /dev/null)" == "" ]]; then
echo "phylociraptor docker image for version: ("$VER") does not exist, will build it first. This can take some time, please be patient."
docker build -t reslp/phylociraptor:$VER --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --build-arg USER=$US --build-arg GROUP=$(id -g -n $USER) --build-arg HOSTTYPE=$HT .
fi
# this needs to be set because on Linux docker created files will be owned by root by default.
unset DOCKER_USER
if [[ "$OSTYPE" == "linux-gnu" ]]; then
DOCKER_USER="--user $(id -u):$(id -g)"
elif [[ "$OSTYPE" == "darwin"* ]]; then #nothing to be done on MacOS
DOCKER_USER=""
fi
TMPFS="-v $(pwd)/.tmp:/tmp"
BINDPOINTS="-v $(pwd):/home/$US/phylociraptor"
REUSE="TRUE" #when this is enabled, the container is continuously updated as singularity images are pulled. So they don't have to be pulled multiple times.
if [[ $REUSE == "TRUE" ]]; then
# echo "docker run -it $DOCKER_USER $BINDPOINTS --privileged reslp/phylociraptor:$VER phylociraptor $@"
docker run -it $DOCKER_USER $BINDPOINTS --privileged reslp/phylociraptor:$VER phylociraptor $@
newid=$(docker container ls -all | grep "reslp/phylociraptor:$VER" | cut -d" " -f 1)
docker commit $newid reslp/phylociraptor:$VER &> /dev/null
docker container rm $newid &> /dev/null
else
docker run --rm -it $DOCKER_USER $BINDPOINTS --privileged reslp/phylociraptor:$VER phylociraptor $@
fi
#Command will look something like this:
#docker run --rm -it --user $(id -u):$(id -g) -v $(pwd):/home/$USER/phylociraptor --privileged reslp/phylociraptor:0.9.1