Skip to content

Commit

Permalink
Rewamp Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Jul 17, 2024
1 parent 4651f4d commit 731ee91
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 129 deletions.
4 changes: 1 addition & 3 deletions .github/actions/create-dev-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@ runs:
python-version: 3.x

- name: Install Dev Dependencies 📦
run: |
pip install --upgrade pip
pip install --upgrade -r docker/requirements-dev.txt
run: pip install -r requirements-docker.txt
shell: bash
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# syntax=docker/dockerfile:1
FROM ghcr.io/astral-sh/uv:0.2.18 as uv
FROM ghcr.io/aiidalab/full-stack:2024.1021

USER ${NB_USER}

ENV QE_VERSION "7.2"

# 1. Install Quantum Espresso into a conda environment
RUN mamba create -n quantum-espresso --yes qe=${QE_VERSION} && \
mamba clean --all -f -y

# 2. Prepare AiiDA profile and localhost computer
# (we do this here for better caching during Docker build)
RUN bash /usr/local/bin/before-notebook.d/20_start-postgresql.sh && \
bash /usr/local/bin/before-notebook.d/40_prepare-aiida.sh && \
verdi daemon stop && \
mamba run -n aiida-core-services pg_ctl stop

# 3. Copy the whole repo
ENV QE_APP_FOLDER ${AIIDALAB_APPS}/quantum-espresso
COPY --chown=${NB_UID}:${NB_GID} . ${QE_APP_FOLDER}

WORKDIR ${QE_APP_FOLDER}
# 4.Install python dependencies
# Use uv instead of pip to speed up installation, per docs:
# https://github.com/astral-sh/uv/blob/main/docs/guides/docker.md#using-uv-temporarily
# Use the same constraint file as pip
ENV UV_CONSTRAINT ${PIP_CONSTRAINT}
RUN --mount=from=uv,source=/uv,target=/bin/uv \
# Remove all untracked files and directories.
git clean -fx && \
uv pip install --system --no-cache .

# 5. Install the QE pseudopotentials and codes
RUN bash /usr/local/bin/before-notebook.d/20_start-postgresql.sh && \
python -m aiidalab_qe install-qe && \
python -m aiidalab_qe install-pseudos && \
mamba run -n aiida-core-services pg_ctl stop

USER root
COPY ./before-notebook.d/* /usr/local/bin/before-notebook.d/
RUN fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"

USER ${NB_USER}
WORKDIR "/home/${NB_USER}"
19 changes: 19 additions & 0 deletions before-notebook.d/00_untar_home.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
#
set -euo pipefail

home="/home/${NB_USER}"

if [[ ! -d ${home} ]]; then
echo "Directory $home does not exist!"
exit 1
fi

# Untar home archive file to restore home directory if it is empty
if [[ $(ls -A ${home} | wc -l) = "0" ]];then
if [ -f /opt/home.tar ]; then
# untar /opt/home.tar to /home/jovyan to restore home directory
echo "Untarring /opt/home.tar to /home/jovyan"
tar -xf /opt/home.tar -C /home/jovyan
fi
fi
52 changes: 0 additions & 52 deletions docker/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions docker/before-notebook.d/70_prepare-qe-executable.sh

This file was deleted.

21 changes: 0 additions & 21 deletions docker/before-notebook.d/71_install-qeapp.sh

This file was deleted.

10 changes: 0 additions & 10 deletions docker/build.json

This file was deleted.

27 changes: 0 additions & 27 deletions docker/docker-bake.hcl

This file was deleted.

File renamed without changes.

0 comments on commit 731ee91

Please sign in to comment.