Skip to content

Commit 17fd749

Browse files
authored
enh: establish a CONDA_PATH env variable
1 parent 6908b6d commit 17fd749

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

Dockerfile

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,30 @@ RUN locale-gen en_US.UTF-8 || true
4949
ENV LANG="en_US.UTF-8" \
5050
LC_ALL="en_US.UTF-8"
5151

52-
ENV PATH /opt/conda/bin:$PATH
53-
5452
# Leave these args here to better use the Docker build cache
53+
ENV CONDA_PATH="/opt/conda"
5554
ARG CONDA_VERSION=py38_4.10.3
5655
ARG SHA256SUM=935d72deb16e42739d69644977290395561b7a6db059b316958d97939e9bdf3d
5756

5857
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh -O miniconda.sh && \
5958
echo "${SHA256SUM} miniconda.sh" > miniconda.sha256 && \
6059
sha256sum -c --status miniconda.sha256 && \
6160
mkdir -p /opt && \
62-
sh miniconda.sh -b -p /opt/conda && \
61+
sh miniconda.sh -b -p ${CONDA_PATH} && \
6362
rm miniconda.sh miniconda.sha256 && \
64-
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
65-
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
63+
ln -s ${CONDA_PATH}/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
64+
echo ". ${CONDA_PATH}/etc/profile.d/conda.sh" >> ~/.bashrc && \
6665
echo "conda activate base" >> ~/.bashrc && \
67-
find /opt/conda/ -follow -type f -name '*.a' -delete && \
68-
find /opt/conda/ -follow -type f -name '*.js.map' -delete && \
69-
/opt/conda/bin/conda clean -afy
66+
find ${CONDA_PATH}/ -follow -type f -name '*.a' -delete && \
67+
find ${CONDA_PATH}/ -follow -type f -name '*.js.map' -delete && \
68+
${CONDA_PATH}/bin/conda clean -afy
69+
70+
# Set CPATH for packages relying on compiled libs (e.g. indexed_gzip)
71+
ENV PATH="${CONDA_PATH}/bin:$PATH" \
72+
CPATH="${CONDA_PATH}/include:$CPATH" \
73+
PYTHONNOUSERSITE=1
7074

71-
RUN /opt/conda/bin/conda install -c conda-forge -c anaconda \
75+
RUN ${CONDA_PATH}/bin/conda install -c conda-forge -c anaconda \
7276
python=3.8 \
7377
attrs=21.2 \
7478
codecov=2.1 \
@@ -123,22 +127,22 @@ RUN /opt/conda/bin/conda install -c conda-forge -c anaconda \
123127
traits=6.2 \
124128
zlib=1.2 \
125129
zstd=1.5; sync && \
126-
chmod -R a+rX /opt/conda; sync && \
127-
chmod +x /opt/conda/bin/*; sync && \
128-
/opt/conda/bin/conda clean -afy && sync && \
130+
chmod -R a+rX ${CONDA_PATH}; sync && \
131+
chmod +x ${CONDA_PATH}/bin/*; sync && \
132+
${CONDA_PATH}/bin/conda clean -afy && sync && \
129133
rm -rf ~/.conda ~/.cache/pip/*; sync
130134

131135
# Precaching fonts, set 'Agg' as default backend for matplotlib
132-
RUN /opt/conda/bin/python -c "from matplotlib import font_manager" && \
133-
sed -i 's/\(backend *: \).*$/\1Agg/g' $( /opt/conda/bin/python -c "import matplotlib; print(matplotlib.matplotlib_fname())" )
136+
RUN ${CONDA_PATH}/bin/python -c "from matplotlib import font_manager" && \
137+
sed -i 's/\(backend *: \).*$/\1Agg/g' $( ${CONDA_PATH}/bin/python -c "import matplotlib; print(matplotlib.matplotlib_fname())" )
134138

135139
# Install packages that are not distributed with conda
136-
RUN /opt/conda/bin/python -m pip install --no-cache-dir -U \
140+
RUN ${CONDA_PATH}/bin/python -m pip install --no-cache-dir -U \
137141
etelemetry \
138142
nitransforms \
139143
templateflow \
140144
transforms3d
141145

142146
# Installing SVGO and bids-validator
143-
RUN /opt/conda/bin/npm install -g svgo@^2.3 bids-validator@1.8.0 && \
147+
RUN ${CONDA_PATH}/bin/npm install -g svgo@^2.3 bids-validator@1.8.0 && \
144148
rm -rf ~/.npm ~/.empty /root/.npm

0 commit comments

Comments
 (0)