Skip to content

Commit

Permalink
Merge pull request #19 from yarikoptic/bf-osx
Browse files Browse the repository at this point in the history
BF: make Simple_Prep_docker run on OSX
  • Loading branch information
satra authored Apr 7, 2017
2 parents 456f2b9 + e3af475 commit 1d57861
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ release with FSL 5.0.8-3 as it was available in March of 2015:
./Simple_Prep_docker jessie 20150306T060524Z
```

which will generate a local docker image `repronim:simple_prep_USER_jessie_20150306T060524Z`
(`USER` will correspond to your user name), with all necessary for computation
which will generate a local docker image `repronim:simple_prep_${USER}_jessie_20150306T060524Z`
(`${USER}` will correspond to your user name), with all necessary for computation
components installed.

#### Run the demo
Expand All @@ -99,12 +99,12 @@ You can normally run a demo with only **one additional step** necessary -- setti
environment variables (to point to FSL binaries and enable conda environment):

```bash
docker run -it --rm repronim:simple_prep_USER_jessie_20150306T060524Z /bin/bash -c '
. setup_environment;
cd simple_workflow-master
&& python run_demo_workflow.py --key 11an55u9t2TAf0EV2pHN0vOd8Ww2Gie-tHp9xGULh_dA
docker run -it --rm repronim:simple_prep_${USER}_jessie_20150306T060524Z /bin/bash -c ' \
. setup_environment; \
cd simple_workflow-master \
&& python run_demo_workflow.py --key 11an55u9t2TAf0EV2pHN0vOd8Ww2Gie-tHp9xGULh_dA \
&& python check_output.py'
```

which would generate a new temporary container, perform analysis, run
the check, and quit.
the check, and quit.
28 changes: 22 additions & 6 deletions Simple_Prep_docker
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@ export PS4=+
#set -x
set -u

# a little helper since sed on OSX does not have sed -i
# for in-place modifications. Note that filename here comes first
# just to ease scripting
sed-i () {
filename=$1
tfilename=$(mktemp -t sed_replace.XXXXXXXXX)
shift
sed "$@" "$filename" >| "$tfilename"
mv "$tfilename" "$filename"
}

DL_DIST=${1:-jessie}
DL_DATE=${2:-}

topdir=$(readlink -f `dirname $0`)
cd `dirname $0`
dockerfile=$topdir/Simple_Prep_docker-Dockerfile
dockerfile=./Simple_Prep_docker-Dockerfile
# echo "D: $DL_APT"
# Some substitutes aren't used but left for possibly later use
sed -e "s,DL_DIST,$DL_DIST,g" \
Expand All @@ -34,18 +44,24 @@ sed -e "s,DL_DIST,$DL_DIST,g" \

if [ ! -z "$DL_DATE" ]; then
{
# replace with snapshots
echo "sed -i -e 's,http://neuro.debian.net/debian/* ,http://snapshot-neuro.debian.net:5002/archive/neurodebian/$DL_DATE/ ,g' etc/apt/sources.list.d/neurodebian.sources.list;"
# replace with snapshots. Since ran inside the container, sed -i should be ok
echo "sed -i -e 's,http://neuro.debian.net/debian/* ,http://snapshot-neuro.debian.net:5002/archive/neurodebian/$DL_DATE/ ,g' etc/apt/sources.list.d/neurodebian.sources.list"
# for now we need to knock to expose snapshots repository
echo "curl -s http://neuro.debian.net/_files/knock-snapshots;"
# TODO: figure out and add snapshot for DL_DIST itself if available and force possible downgrade somehow
echo "eatmydata apt-get update; eatmydata apt-get dist-upgrade -y;"
} | while read aptline; do
sed -i -e "s|\(\(.*\)DL_APT\(.*\)\)|\2$aptline\3\n\1|g" $dockerfile
# on OSX cannot use \n to get a newline in sed, so doing POSIX way, although also escaping trailing \
# so it is in effect within sed-i call
sed-i "$dockerfile" -e "s|\(\(.*\)DL_APT\(.*\)\)|\2$aptline\3\\
\1|g"
:
done
fi
sed -e '/DL_APT/d' -i $dockerfile

# for debugging
# cat $dockerfile
sed-i "$dockerfile" -e '/DL_APT/d'

tag_=simple_prep_${USER}_${DL_DIST}_${DL_DATE}
tag=repronim:${tag_}
Expand Down

0 comments on commit 1d57861

Please sign in to comment.