Skip to content

Commit 5bb6a1a

Browse files
author
Franz Ebner
committed
Merge branch 'febner/unify-dockerfile' into 'main'
unify Dockerfile, .dockerignore all, ci default tags See merge request common/python-package-template!5
2 parents 0c5984a + 6092415 commit 5bb6a1a

5 files changed

Lines changed: 51 additions & 153 deletions

File tree

‎{{ cookiecutter.__package_name_kebab_case }}/.devcontainer/devcontainer.json‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
// Sets the run context to one level up instead of the .devcontainer folder.
77
"context": "..",
88
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9-
"dockerfile": "../Dockerfile-cuda"
9+
"dockerfile": "../Dockerfile",
10+
"args": {
11+
"IMAGE_NAME": "nvidia/cuda:12.3.1-runtime-ubuntu22.04"
12+
},
13+
"target": "dev"
1014
},
1115
"features": {
1216
"ghcr.io/devcontainers/features/git-lfs:1": {
@@ -16,7 +20,7 @@
1620
},
1721
"runArgs": [
1822
"--gpus=all"
19-
],
23+
]
2024

2125
// Features to add to the dev container. More info: https://containers.dev/features.
2226
// "features": {},
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
.venv
1+
# Ignore everything
2+
*
3+
4+
# but
5+
!/pyproject.toml
6+
!/poetry.lock
7+
!/{{ cookiecutter.__package_name_snake_case }}/**/*.py
8+
9+
# but but
10+
# Ignore the unignored
11+
# /{{ cookiecutter.__package_name_snake_case }}/super/specific.py

{{ cookiecutter.__package_name_kebab_case }}/Dockerfile-cuda renamed to {{ cookiecutter.__package_name_kebab_case }}/Dockerfile

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
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

55
ARG PYTHON_VERSION={{cookiecutter.python_version}}
66
ARG POETRY_VERSION=1.8.0
7-
ENV DEBIAN_FRONTEND noninteractive
7+
ENV DEBIAN_FRONTEND=noninteractive
88

99
LABEL 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
3834
RUN 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 -
5048
ENV 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)
6058
COPY pyproject.toml poetry.lock ./
@@ -66,6 +64,22 @@ RUN pyenv rehash
6664
# Copy the rest of the repository
6765
ADD . .
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/*

‎{{ cookiecutter.__package_name_kebab_case }}/Dockerfile-base‎

Lines changed: 0 additions & 63 deletions
This file was deleted.

‎{{ cookiecutter.__package_name_kebab_case }}/Dockerfile-test‎

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)