Skip to content

Commit

Permalink
Build deps stage
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Jul 22, 2024
1 parent 0521d29 commit 68dc3c0
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ ARG UV_VERSION=0.2.27

FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv

# STAGE 1
# Install QE into conda environment in /opt/conda
# We need to do this first, otherwise QE gets installed into home folder as part of
# python -m aiidalab_qe install-qe
FROM ghcr.io/aiidalab/full-stack:${FULL_STACK_VERSION} AS conda_build
ARG QE_VERSION

USER ${NB_USER}
# Install QE into conda environment in /opt/conda
# We need to do this first, otherwise QE gets installed into home folder as part of
# python -m aiidalab_qe install-qe
RUN mamba create -p /opt/conda/envs/quantum-espresso-${QE_VERSION} --yes \
qe=${QE_VERSION} && \
mamba clean --all -f -y

FROM conda_build AS home_build

ENV QE_APP_FOLDER=/opt/conda/quantum-espresso
# STAGE 2
# Install python dependencies, needed to run aiidalab_qe CLI commands
FROM conda_build AS build_deps
ENV QE_APP_FOLDER=/tmp/quantum-espresso
WORKDIR ${QE_APP_FOLDER}

COPY --chown=${NB_UID}:${NB_GID} src/ ${QE_APP_FOLDER}/src
Expand All @@ -29,12 +31,17 @@ RUN --mount=from=uv,source=/uv,target=/bin/uv \
uv pip install --system --no-cache . && \
rm -rf build/ src/aiidalab_qe.egg-info/


# STAGE 3:
# - Prepare AiiDA profile and localhost computer
# - Install QE codes and pseudopotentials
# - Archive home folder
FROM build_deps AS home_build

ENV PSEUDO_FOLDER=/tmp/pseudo
RUN mkdir -p ${PSEUDO_FOLDER} && \
python -m aiidalab_qe download-pseudos --dest ${PSEUDO_FOLDER}

# 4. Prepare AiiDA profile and localhost computer
# 5. Install the QE pseudopotentials and codes
# TODO: Remove PGSQL and daemon log files, and other unneeded files
RUN bash /usr/local/bin/before-notebook.d/20_start-postgresql.sh && \
bash /usr/local/bin/before-notebook.d/40_prepare-aiida.sh && \
Expand All @@ -44,14 +51,18 @@ RUN bash /usr/local/bin/before-notebook.d/20_start-postgresql.sh && \
mamba run -n aiida-core-services pg_ctl stop && \
cd /home/${NB_USER} && tar -cf /opt/conda/home.tar .


# STAGE 4 - Final stage
# - Copy QE env environment
# - Copy home folder archive
# - Copy the whole repo into the container
# - Install python dependencies
# - Remove all content of home folder
FROM ghcr.io/aiidalab/full-stack:${FULL_STACK_VERSION}
ARG QE_VERSION
USER ${NB_USER}

COPY --from=conda_build /opt/conda/envs/quantum-espresso-${QE_VERSION}/ /opt/conda/envs/quantum-espresso-${QE_VERSION}

COPY --from=home_build /opt/conda/home.tar /opt/conda
COPY --from=home_build /opt/conda/home.tar /opt/conda/home.tar

ENV QE_APP_FOLDER=/opt/conda/quantum-espresso
WORKDIR "${QE_APP_FOLDER}"
Expand Down

0 comments on commit 68dc3c0

Please sign in to comment.