Skip to content

Commit dd5a2c5

Browse files
authored
Move wannier90 build out of the final stage (#1538)
1 parent 1a80e16 commit dd5a2c5

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

Dockerfile

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,22 @@ ARG QE_DIR
3131
ARG TARGETARCH
3232

3333
USER ${NB_USER}
34-
RUN set -ex; \
35-
echo "Installing QE and Bader..." && \
34+
RUN echo "Installing QE and Bader..." && \
3635
mamba create -p ${QE_DIR} --yes qe=${QE_VER} bader && \
3736
mamba clean --all -f -y
3837

38+
USER root
39+
# Build wannier90 and copy the binary to $QE_DIR conda env
40+
# TODO: Make a conda-forge package for wannier90!
41+
RUN apt-get -q update && \
42+
apt-get -q install -y --no-install-recommends gfortran libblas-dev liblapack-dev libopenmpi-dev && \
43+
git clone --depth=1 https://github.com/wannier-developers/wannier90.git /tmp/wannier90 && \
44+
cd /tmp/wannier90 && \
45+
cp config/make.inc.gfort make.inc && \
46+
echo -e "COMMS=mpi\nMPIF90=mpif90" >> make.inc && \
47+
make -j wannier && \
48+
cp wannier90.x ${QE_DIR}/bin/wannier90.x
49+
3950
###############################################################################
4051
# 3) base stage to setup common environment variables
4152
# NOTE: Any ENVs set here will end up in the final image!
@@ -106,7 +117,7 @@ RUN --mount=from=qe_conda_env,source=${QE_DIR},target=${QE_DIR} \
106117
# setup code: pythonjob, bader, wannier90 code
107118
verdi code create core.code.installed --label python --computer=${COMPUTER_LABEL} --default-calc-job-plugin pythonjob.pythonjob --filepath-executable=/opt/conda/bin/python -n && \
108119
verdi code create core.code.installed --label bader --computer=${COMPUTER_LABEL} --default-calc-job-plugin bader.bader --filepath-executable=${QE_DIR}/bin/bader -n && \
109-
verdi code create core.code.installed --label wannier90 --computer=${COMPUTER_LABEL} --default-calc-job-plugin wannier90.wannier90 --filepath-executable=/opt/conda/bin/wannier90.x -n && \
120+
verdi code create core.code.installed --label wannier90 --computer=${COMPUTER_LABEL} --default-calc-job-plugin wannier90.wannier90 --filepath-executable=${QE_DIR}/bin/wannier90.x -n && \
110121
# run post_install for plugin
111122
python -m aiida_bader post-install && \
112123
python -m aiidalab_qe_vibroscopy setup-phonopy && \
@@ -149,21 +160,11 @@ ARG QE_APP_SRC
149160
ARG TARGETARCH
150161

151162
USER root
152-
# Build wannier90 for all arches
153-
RUN set -ex; \
154-
apt-get -q update && apt-get -q install -y --no-install-recommends \
155-
gfortran libblas-dev liblapack-dev liblapack3 openmpi-bin libopenmpi-dev; \
156-
git clone --depth=1 https://github.com/wannier-developers/wannier90.git /tmp/wannier90; \
157-
cd /tmp/wannier90; \
158-
cp config/make.inc.gfort make.inc; \
159-
echo "COMMS=mpi" >> make.inc; \
160-
echo "MPIF90=mpif90" >> make.inc; \
161-
make -j"$(nproc)" wannier; \
162-
cp wannier90.x /opt/conda/bin/wannier90.x; \
163-
apt-get -q remove --purge -y gfortran libblas-dev liblapack-dev libopenmpi-dev && \
164-
apt-get -q autoremove -y && \
163+
# Install deps for wannier90
164+
RUN apt-get -q update && \
165+
apt-get -q install -y --no-install-recommends liblapack3 openmpi-bin && \
165166
apt-get -q clean && \
166-
rm -rf /var/lib/apt/lists/* /tmp/wannier90 /tmp/bader
167+
rm -rf /var/lib/apt/lists/*
167168

168169
USER ${NB_USER}
169170
WORKDIR /tmp
@@ -180,6 +181,8 @@ RUN python -m pip install --no-user --no-cache-dir ${AIIDA_HQ_PKG}
180181
COPY --from=home_build /opt/conda/hq /usr/local/bin/
181182
# Copy the QE conda environment
182183
COPY --from=qe_conda_env ${QE_DIR} ${QE_DIR}
184+
# This is for backwards compatibility
185+
COPY --from=qe_conda_env ${QE_DIR}/bin/wannier90.x /opt/conda/bin/wannier90.x
183186

184187
USER root
185188

0 commit comments

Comments
 (0)