-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
156 lines (133 loc) · 6.27 KB
/
Dockerfile
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
##################################################################
# Use Ubuntu 20.04 LTS as base image
##################################################################
FROM focal-20221019 AS main
##################################################################
## Install Miniconda3 and the environment incl. ANTs/nipype/pybids
##################################################################
FROM main AS neurocondabuntu
# Install Miniconda3
RUN apt-get update && \
apt-get install -qq -y --no-install-recommends curl && \
curl -sSL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o /tmp/miniconda.sh && \
bash /tmp/miniconda.sh -bfp /opt/conda && \
rm -rf /tmp/miniconda.sh && \
apt-get remove -y curl && \
conda update conda && \
conda clean --all --yes && \
rm -rf ~/.conda ~/.cache/pip/* && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Add conda to $PATH
ENV PATH="/opt/conda/bin:$PATH"
## Create conda environment, including ANTs 2.2.0 and MRtrix 3.0.2
ENV CONDA_ENV="py39localhip"
COPY environment.yml /app/environment.yml
RUN /bin/bash -c "conda config --set default_threads 4 &&\
conda create env create -f /app/environment.yml &&\
conda clean -v --all --yes &&\
rm -rf ~/.conda ~/.cache/pip/*"
##################################################################
# Install BIDS validator
##################################################################
# RUN npm install -g bids-validator && \
# rm -rf ~/.npm ~/.empty
##################################################################
# Installation of Connectome Mapper 3 packages
##################################################################
FROM neurocondabuntu AS localhipbuntu
# Docker build command arguments
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
# Set the working directory to /app/connectomemapper3
WORKDIR /app/localhip
# Copy Python contents of this repository.
COPY LICENSE ./LICENSE
COPY setup.py ./setup.py
COPY README.md ./README.md
COPY localhip ./localhip
# Install localhip package in the conda environment $CONDA_ENV
ENV CONDA_ENV="py39localhip"
RUN /bin/bash -c ". activate ${CONDA_ENV} &&\
pip install ."
##################################################################
# Copy primary BIDSapp entrypoint script
##################################################################
COPY scripts/bidsapp/run_localhip.sh /app/run_localhip.sh
RUN cat /app/run_localhip.sh
##################################################################
# Acquire script to be executed
##################################################################
RUN chmod 775 /app/run.py && \
chmod 775 /app/run_localhip.sh
##################################################################
# Create cache directory for python eggs
##################################################################
RUN mkdir -p /cache/python-eggs && \
chmod -R 777 /cache/python-eggs
##################################################################
# Make ANTs happy
##################################################################
ENV ANTSPATH="/opt/conda/envs/${CONDA_ENV}/bin" \
PYTHONPATH="/opt/conda/envs/${CONDA_ENV}/bin" \
PYTHON_EGG_CACHE="/cache/python-eggs" \
PATH="$ANTSPATH:$PATH" \
LD_LIBRARY_PATH="/opt/conda/envs/${CONDA_ENV}/lib:${LD_LIBRARY_PATH}" \
LD_LIBRARY_PATH="/lib/x86_64-linux-gnu:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH"
##################################################################
# Temporary tmp folder
##################################################################
RUN /bin/bash -c "mkdir -p /var/tmp"
ENV TMPDIR="/var/tmp" \
TMP="/var/tmp" \
TEMP="/var/tmp"
##################################################################
# Create input and output directories for BIDS App
##################################################################
RUN mkdir /bids_dir && \
mkdir /output_dir && \
chmod -R 777 /bids_dir && \
chmod -R 777 /output_dir
##################################################################
# Set locale settings
##################################################################
ENV LANG="C.UTF-8" \
LC_ALL="C.UTF-8"
##################################################################
# Unless otherwise specified each process should only use one
# thread - nipype will handle parallelization
##################################################################
ENV MKL_NUM_THREADS=1 \
OMP_NUM_THREADS=1
##################################################################
# Run ldconfig for compatibility with Singularity
##################################################################
RUN ldconfig
##################################################################
# Show all environment variables
##################################################################
RUN export
##################################################################
# Define primary entryppoint script
##################################################################
WORKDIR /tmp/
ENTRYPOINT ["/app/run_localhip.sh"]
##################################################################
# Copy version information
##################################################################
# COPY version /version
##################################################################
# Metadata
##################################################################
LABEL org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.name="LocalHIP BIDS App" \
org.label-schema.description="LocalHIP - Automated pipeline for electrode localization in SEEG" \
org.label-schema.url="https://localhip.readthedocs.io" \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.vcs-url="https://github.com/brainhack-ch/localHIP" \
org.label-schema.version=$VERSION \
org.label-schema.maintainer="Sebastien Tourbier <[email protected]>" \
org.label-schema.vendor="Department of Clinical Neuroscience (DNC), Centre Hospitalier Universitaire Vaudois (CHUV), Lausanne, Switzerland" \
org.label-schema.schema-version="1.0" \
org.label-schema.docker.cmd="docker run --rm -v ~/data/bids_dataset:/bids_dir -t XXX/localhip:${VERSION} /bids_dir /bids_dir/derivatives participant [--participant_label PARTICIPANT_LABEL [PARTICIPANT_LABEL ...]] [-session_label SESSION_LABEL [SESSION_LABEL ...]]" \