From ac4f59db47f5fd262d6ef308e6680722c9b679cd Mon Sep 17 00:00:00 2001 From: Keith James Date: Wed, 28 Aug 2024 18:49:19 +0100 Subject: [PATCH] Fix Docker caching of Python builds Reorder some RUN command so that changes to local files do not cause Python rebuilds so often. --- Dockerfile.dev | 15 ++++++++++----- pyproject.toml | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index 31edb01..bfff40e 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -32,8 +32,6 @@ RUN echo "deb [arch=amd64] https://packages.irods.org/apt/ $(lsb_release -sc) ma WORKDIR /app -COPY . /app - # It's more practical to build from an iRODS client image and install recent Python # than to build from a recent Python image and install iRODS clients. ENV PYENV_ROOT="/app/.pyenv" @@ -41,14 +39,21 @@ ENV PYENV_ROOT="/app/.pyenv" # Put PYENV first to ensure we use the pyenv-installed Python ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" -RUN ./docker/install_pyenv.sh +COPY ./docker/install_pyenv.sh /app/docker/install_pyenv.sh + +RUN /app/docker/install_pyenv.sh RUN pyenv install "$PYTHON_VERSION" RUN pyenv global "$PYTHON_VERSION" +COPY requirements.txt test-requirements.txt /app/ + RUN pip install --no-cache-dir -r requirements.txt && \ - pip install --no-cache-dir -r test-requirements.txt && \ - pip install --no-cache-dir . && \ + pip install --no-cache-dir -r test-requirements.txt + +COPY . /app + +RUN pip install --no-cache-dir . && \ git status && \ ls -al diff --git a/pyproject.toml b/pyproject.toml index 1495a53..57523f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ repository = "https://github.com/wtsi-npg/partisan.git" [build-system] requires = ["setuptools>=41", "wheel", "setuptools-git-versioning>=2.0,<3"] +build-backend = "setuptools.build_meta" [tool.setuptools] # Note: we are relying on setuptools' automatic package discovery, so no further