From eac011520d33de8bd95d94d2f6b968ae7aae603e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20Chud=C3=BD?= Date: Mon, 23 Sep 2024 13:22:16 +0200 Subject: [PATCH] Test optimise size of datasicence image --- python/datascience/Dockerfile.datascience | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/python/datascience/Dockerfile.datascience b/python/datascience/Dockerfile.datascience index 7e8c02d..0e6f519 100644 --- a/python/datascience/Dockerfile.datascience +++ b/python/datascience/Dockerfile.datascience @@ -1,4 +1,4 @@ -ARG FROM_PYTHON_VERSION=3.7 +ARG FROM_PYTHON_VERSION=3.8 FROM deepnote/python:${FROM_PYTHON_VERSION} RUN pip install --upgrade pip @@ -11,11 +11,17 @@ ADD requirements-below-3.11.txt /requirements-below-3.11.txt #Determine the Python version and set the version-specifications file ARG FROM_PYTHON_VERSION RUN if [ "$(printf '%s\n' "$FROM_PYTHON_VERSION" "3.11" | sort -V | head -n1)" = "3.11" ]; then \ - pip install -r requirements-3.11+.txt \ + mv "requirements-3.11+.txt" "requirements.txt" \ ; else \ - pip install -r requirements-below-3.11.txt \ + mv "requirements-below-3.11.txt" "requirements.txt" \ ; fi - -# Clean up the requirements files from the image -RUN rm /requirements-3.11+.txt /requirements-below-3.11.txt +# Install dependencies +# Combine all RUN commands into one to minimize the number of layers +RUN apt-get update \ + && apt-get install -y --no-install-recommends gcc \ + && pip install --no-cache-dir -r requirements.txt \ + && apt-get purge -y gcc \ + && apt-get autoremove -y \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /root/.cache \ No newline at end of file