Skip to content
Snippets Groups Projects
Commit 984ac8fb authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

MNT: Add dockerfile to build runtime image

parent 000e7170
No related branches found
No related tags found
1 merge request!6Migrate to `pyproject.toml`, add `Dockerfile` to generate runtime image
Pipeline #21824 failed
File moved
This docker image is used for running unit tests on the BIP code base. It can
be built via Gitlab CI / CD by running the `build-dev-docker-image` job.
At the moment the image is published to
https://hub.docker.com/u/pauldmccarthy/bip-dev/.
\ No newline at end of file
......@@ -31,7 +31,7 @@ echo " conda-forge" >> ${envd
source activate ${envdir}
pip install dmri-amico
pip install git+https://git.fmrib.ox.ac.uk/ndcn0236/pipe-tree.git
pip install git+https://git.fmrib.ox.ac.uk/fsl/pipe-tree.git
conda remove -p ${envdir} c-compiler cxx-compiler
conda clean -y -all
......
FROM nvidia/cuda:11.0.3-base-centos7 as base
ENV NVARCH x86_64
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_REQUIRE_CUDA cuda>=11.0 brand=tesla,driver>=418,driver<419
ENV NVIDIA_VISIBLE_DEVICES all
ENV NV_CUDA_CUDART_VERSION 11.0.221-1
COPY /build_image.sh /build_image.sh
RUN /bin/bash /build_image.sh && rm /build_image.sh
BIP Docker image
----------------
The `Dockerfile` can be used to create a Docker image which contains BIP and
all of its dependencies. The image contains a full BIP runtime environment,
including FSL, FreeSurfer and Connectome Workbench. Be warned that the image
is quite large, on the order of 15GB.
1. Clone the BIP repository and change into the image directory:
```
git clone https://git.fmrib.ox.ac.uk/fsl/bip.git
cd bip/.docker/bip-image
```
2. Build the image:
```
docker build . -t bip &> build_log.txt
```
3. If the image was built on a different machine than the one it is to be run
on, save it to a `.tar.gz` archive:
```
docker save bip | gzip -c > bip.tar.gz
```
Then download the archive to the target machine, and load it:
```
docker load < bip.tar.gz
```
4. Start a container from the image. Replace `<freesurfer-license>` with the
full path to your FreeSurfer license file.
```
docker run -it \
-v <freesurfer-license>:/usr/local/freesurfer/license.txt \
bip /bin/bash
```
#!/usr/bin/env bash
set -e
SHELL_PROFILE=/root/.bashrc
export TAR_OPTIONS=--no-same-owner
export WGET_OPTIONS=--no-check-certificate
# OS / build dependencies
yum install -y epel-release
yum install -y openssh-clients git nano wget curl unzip python3 parallel
# FSL
FSL_URL=https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py
wget ${WGET_OPTIONS} ${FSL_URL} -O fslinstaller.py
python /tmp/fslinstaller.py -V 6.0.7.6 -d /usr/local/fsl
echo -e '\nexport FSLDIR=/usr/local/fsl/\n' >> ${SHELL_PROFILE}
echo -e '\nsource ${FSLDIR}/etc/fslconf/fsl.sh\n' >> ${SHELL_PROFILE}
rm fslinstaller.py
# BIP
/usr/local/fsl/bin/mamba install -y -n base fsl-bip
# ROBEX
ROBEX_URL=https://www.nitrc.org/frs/download.php/5994/ROBEXv12.linux64.tar.gz//\?i_agree\=1\&download_now\=1
pushd /usr/local/
wget ${WGET_OPTIONS} ${ROBEX_URL} -O ROBEX.tar.gz
tar xf ROBEX.tar.gz && rm ROBEX.tar.gz
echo -e '\nexport PATH=/usr/local/ROBEX:${PATH}\n' >> ${SHELL_PROFILE}
popd
# Brainsuite
BRAINSUITE_URL=http://brainsuite.org/data/BIDS/bse15c.biobank.tgz
pushd /usr/local/
wget ${WGET_OPTIONS} ${BRAINSUITE_URL} -O brainsuite.tgz
tar -xf brainsuite.tgz && rm brainsuite.tgz
chmod -R ugo+rx BrainSuite15c
echo -e '\nexport PATH=/usr/local/BrainSuite15c/bin:${PATH}\n' >> ${SHELL_PROFILE}
popd
# Workbench
WORKBENCH_URL=https://humanconnectome.org/storage/app/media/workbench/workbench-rh_linux64-v1.5.0.zip
pushd /usr/local/
wget ${WGET_OPTIONS} ${WORKBENCH_URL} -O workbench.zip
unzip workbench.zip && rm workbench.zip
echo -e '\nexport PATH=/usr/local/workbench/bin_rh_linux64:${PATH}\n' >> ${SHELL_PROFILE}
popd
# Freesurfer
FREESURFER_URL=https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer-linux-centos7_x86_64-7.4.1.tar.gz
pushd /usr/local/
wget ${WGET_OPTIONS} ${FREESURFER_URL} -O freesurfer.tgz
tar xf freesurfer.tgz && rm freesurfer.tgz
echo -e '\nexport FREESURFER_HOME=/usr/local/freesurfer\n' >> ${SHELL_PROFILE}
echo -e '\nsource ${FREESURFER_HOME}/SetUpFreeSurfer.sh\n' >> ${SHELL_PROFILE}
popd
# Clean up
/usr/local/fsl/bin/mamba clean --all --yes --force-pkgs-dirs
rm -rf /tmp/*
rm -rf ${HOME}/.cache/
yum clean all
rm -rf /var/cache/yum/*
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment