Skip to content

Commit

Permalink
Use uv cache
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Jul 22, 2024
1 parent 68dc3c0 commit 94254ed
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ARG FULL_STACK_VERSION=2024.1021
ARG QE_VERSION=7.2
ARG UV_VERSION=0.2.27

ARG UV_CACHE_DIR=/tmp/uv_cache
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv

# STAGE 1
Expand All @@ -17,9 +18,11 @@ RUN mamba create -p /opt/conda/envs/quantum-espresso-${QE_VERSION} --yes \
qe=${QE_VERSION} && \
mamba clean --all -f -y


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

Expand All @@ -28,8 +31,7 @@ COPY --chown=${NB_UID}:${NB_GID} setup.cfg pyproject.toml *yaml README.md ${QE_A

ENV UV_CONSTRAINT=${PIP_CONSTRAINT}
RUN --mount=from=uv,source=/uv,target=/bin/uv \
uv pip install --system --no-cache . && \
rm -rf build/ src/aiidalab_qe.egg-info/
uv pip install --strict --system --cache-dir=${UV_CACHE_DIR} .


# STAGE 3:
Expand Down Expand Up @@ -59,6 +61,7 @@ RUN bash /usr/local/bin/before-notebook.d/20_start-postgresql.sh && \
# - Remove all content of home folder
FROM ghcr.io/aiidalab/full-stack:${FULL_STACK_VERSION}
ARG QE_VERSION
ARG UV_CACHE_DIR
USER ${NB_USER}

COPY --from=conda_build /opt/conda/envs/quantum-espresso-${QE_VERSION}/ /opt/conda/envs/quantum-espresso-${QE_VERSION}
Expand All @@ -76,13 +79,13 @@ RUN git clean -dffx || true
# Use the same constraint file as pip
ENV UV_CONSTRAINT=${PIP_CONSTRAINT}
RUN --mount=from=uv,source=/uv,target=/bin/uv \
uv pip install --strict --system --compile-bytecode --no-cache . && \
--mount=from=build_deps,source=${UV_CACHE_DIR},target=${UV_CACHE_DIR},rw \
uv pip install --strict --system --compile-bytecode --cache-dir=${UV_CACHE_DIR} . && \
rm -rf build/ src/aiidalab_qe.egg-info/

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

# REMOVE HOME
RUN find /home/${NB_USER}/ -delete
Expand Down

0 comments on commit 94254ed

Please sign in to comment.