1- # This dockerfile serves as a base for all testing images.
2- # It contains the minimal dependencies and is therefore smaller.
3- FROM nvidia/cuda:12.3.1-runtime-ubuntu22.04
1+ # TODO: might be cool to have a fixed image, to assure reproducibility
2+ ARG FROM_IMAGE=debian:stable-slim
3+ FROM FROM_IMAGE AS build
44
55ARG PYTHON_VERSION={{cookiecutter.python_version}}
66ARG POETRY_VERSION=1.8.0
7- ENV DEBIAN_FRONTEND noninteractive
7+ ENV DEBIAN_FRONTEND= noninteractive
88
99LABEL maintainer="{{cookiecutter.author_name}} <{{cookiecutter.author_email}}>"
1010
11- RUN apt-get update --allow-insecure-repositories && apt-get install -yq \
11+ RUN apt-get update && apt-get install -yq \
1212 build-essential \
13- # provides nohup command
14- coreutils \
15- # editor
16- vim \
1713 libssl-dev \
1814 zlib1g-dev \
1915 libbz2-dev \
2016 libreadline-dev \
2117 libsqlite3-dev \
22- curl \
18+ curl \
2319 libncursesw5-dev \
2420 xz-utils \
2521 tk-dev \
@@ -31,14 +27,16 @@ RUN apt-get update --allow-insecure-repositories && apt-get install -yq \
3127 python3-distutils \
3228 && rm -rf /var/lib/apt/lists/*
3329
34- ENV PYENV_ROOT $HOME/.pyenv
35- ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
30+ ENV PYENV_ROOT= $HOME/.pyenv
31+ ENV PATH= $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
3632
3733# Install pyenv
3834RUN set -ex \
3935 && curl https://pyenv.run | bash \
40- && pyenv update \
41- && pyenv install -s ${PYTHON_VERSION} \
36+ && pyenv update
37+
38+ # Install python and set interpreter
39+ RUN pyenv install -s ${PYTHON_VERSION} \
4240 && pyenv global ${PYTHON_VERSION} \
4341 && pyenv rehash
4442
@@ -50,11 +48,11 @@ RUN curl -sSL https://install.python-poetry.org | python -
5048ENV PATH="${PATH}:${POETRY_HOME}/bin"
5149
5250# Setup directory structure
53- RUN mkdir /repo
54- WORKDIR /repo
51+ RUN mkdir /workspace
52+ WORKDIR /workspace
5553
56- # set pythonpath for nvidia image
57- ENV PYTHONPATH "${PYTHONPATH}:/repo "
54+ # set python path to default
55+ ENV PYTHONPATH= "${PYTHONPATH}:/workspace "
5856
5957# Install dependencies (package itself is not installed)
6058COPY pyproject.toml poetry.lock ./
@@ -66,6 +64,22 @@ RUN pyenv rehash
6664# Copy the rest of the repository
6765ADD . .
6866
69- # special entry point which allows you to start the container manually, will keep the container alive
70- # ENTRYPOINT ["tail", "-f", "/dev/null"]
7167
68+ # TODO: build from FROM_IMAGE (or a plain python img), and just copy from build (without pyenv, poetry)
69+ FROM build AS runtime
70+
71+
72+ FROM base AS dev
73+
74+ RUN eval "$(pyenv init -)" \
75+ # activate pyenv on shell start
76+ && pyenv init - > ~/.bashrc
77+
78+ RUN poetry install --all-extras --no-root
79+
80+ RUN apt-get update --allow-insecure-repositories && apt-get install -yq \
81+ # provides nohup command
82+ coreutils \
83+ # editor
84+ vim \
85+ && rm -rf /var/lib/apt/lists/*
0 commit comments