Skip to content

Commit

Permalink
make the image more like a cmd
Browse files Browse the repository at this point in the history
It now uses WORKDIR, ENTRYPOINT and CMD to make the image work more like
a shell command.

It tries to translate paths between the native session and the docker
image, so you can tab-complete to make the T1 and T2 arguments.

It's a bit smaller too.

README updated.
  • Loading branch information
jcupitt committed Apr 6, 2018
1 parent 94da048 commit eba5151
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
atlases
build
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ RUN apt-get install -y \
libgstreamer1.0-dev libqt4-dev

COPY . /usr/src/structural-pipeline

RUN ls /usr/src/structural-pipeline \
&& NUM_CPUS=${THREADS:-`cat /proc/cpuinfo | grep processor | wc -l`} \
&& echo "Maximum number of build threads = $NUM_CPUS" \
&& cd /usr/src/structural-pipeline \
&& ./setup.sh -j $NUM_CPUS

WORKDIR /data
ENTRYPOINT ["/usr/src/structural-pipeline/dhcp-pipeline.sh"]
CMD ["-help"]

20 changes: 19 additions & 1 deletion dhcp-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ command=$@
subjectID=$1
sessionID=$2
age=$3
shift; shift; shift;

# alias for the specific session
subj=$subjectID-$sessionID
Expand All @@ -75,7 +76,6 @@ minimal=1
noreorient=0
cleanup=1

shift; shift; shift;
while [ $# -gt 0 ]; do
case "$1" in
-T2) shift; T2=$1; ;;
Expand All @@ -92,6 +92,24 @@ while [ $# -gt 0 ]; do
shift
done

# consider the case where the user is running us inside docker with an
# argument like:
#
# -T2 data/T1w.nii.gz
#
# the user's data directory will be mapped to /data, and that's out WORKDIR,
# so we need to remove the leading data/ component for the path to be valid
#
# we don't want to make this change unless we have to, so only drop the first
# pathname component if the file named by T2 does not exist and T2 is a
# relative path

if [[ "$T2" != /* && ! -f "$T2" ]]; then
T1=${T1#*/}
T2=${T2#*/}
fi


################ Checks ################

[ "$T2" != "-" -a "$T2" != "" ] || { echo "T2 image not provided!" >&2; exit 1; }
Expand Down

0 comments on commit eba5151

Please sign in to comment.