From 16263e9aca3f47e642f18ed9f8b9e02fc23005ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Gasser?= Date: Wed, 30 Mar 2022 09:22:55 -0400 Subject: [PATCH] chore: make Dockerfiles independent from each other (#28) --- .github/workflows/publish_docker.yml | 1 - Dockerfile.workflows | 67 ++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish_docker.yml b/.github/workflows/publish_docker.yml index 38886c5..5b6f27e 100644 --- a/.github/workflows/publish_docker.yml +++ b/.github/workflows/publish_docker.yml @@ -89,7 +89,6 @@ jobs: run: | docker build \ -t ${{ env.tag }}-workflows \ - --build-arg BASE_IMAGE=${{ env.tag }} \ -f Dockerfile.workflows \ . diff --git a/Dockerfile.workflows b/Dockerfile.workflows index 9e74e35..4fe9034 100644 --- a/Dockerfile.workflows +++ b/Dockerfile.workflows @@ -1,8 +1,67 @@ -# Given by .github/workflows/publish_docker.yml -# For now takes the ./Dockerfile image url (tag) -ARG BASE_IMAGE +# Modified by .github/workflows/publish_docker.yml +ARG CUDA_IMAGE=nvidia/cuda:9.2-base-ubuntu18.04 +FROM $CUDA_IMAGE -FROM $BASE_IMAGE +# Modified by .github/workflows/publish_docker.yml +ARG PYTHON_VERSION=3.7 + +ARG USER_ID=1001 +ARG GROUP_ID=1001 +ARG USER_NAME=sandbox +ARG GROUP_NAME=sandbox +ARG HOME_DIR=/sandbox + +COPY ./setup.py /tmp +COPY ./README.md /tmp +COPY ./substratools /tmp/substratools + +# need the 3 first lines to get python${PYTHON_VERSION} on all ubuntu versions +RUN apt-get update \ + && apt-get install -y software-properties-common \ + && add-apt-repository ppa:deadsnakes/ppa \ +# needed for tzdata, installed by python3.9 + && export DEBIAN_FRONTEND=noninteractive \ + && export TZ=Europe/Moscow \ +# install essential apps + && apt-get install -y \ + build-essential \ + libssl-dev \ + python${PYTHON_VERSION} \ + libpython${PYTHON_VERSION}-dev \ + python${PYTHON_VERSION}-distutils \ + python3-pip \ +# needed for pillow + && apt-get install -y libjpeg-dev zlib1g-dev \ +# clean the apt cache + && rm -rf /var/lib/apt/lists/ \ + # link default python, python3, pip, pip3 to python${PYTHON_VERSION} + && rm -f /usr/bin/python \ + && ln -s /usr/bin/python${PYTHON_VERSION} /usr/bin/python \ + && rm -f /usr/bin/python3 \ + && ln -s /usr/bin/python${PYTHON_VERSION} /usr/bin/python3 \ + && python --version \ + && python3 --version \ +# install pip for python${PYTHON_VERSION} + && python -m pip install --upgrade --no-cache-dir pip \ + && pip --version \ + && pip3 --version \ +# needed for pillow + && pip install --upgrade --no-cache-dir setuptools \ +# install essential datascience libraries +# latest versions compatible with python>=3.7 + && pip install --no-cache-dir pillow==9.0.1 pandas==1.3.5 numpy==1.21.5 scikit-learn==1.0.2 lifelines==0.26.4 scipy==1.7.3 \ +# install substratools + && cd /tmp && pip install --no-cache-dir . \ +# clean the apt cache + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Create default user, group, and home directory +RUN addgroup --gid ${GROUP_ID} ${GROUP_NAME} +RUN adduser --disabled-password --gecos "" --uid ${USER_ID} --gid ${GROUP_ID} --home ${HOME_DIR} ${USER_NAME} + +ENV PYTHONPATH ${HOME_DIR} +WORKDIR ${HOME_DIR} # install datascience workflows libraries # latest versions compatible with python>=3.7