|
2 | 2 | # docker push uhhlt/dats_backend:<version> |
3 | 3 |
|
4 | 4 | FROM ubuntu:jammy-20221020 AS ubuntu |
| 5 | +# install uv |
| 6 | +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ |
5 | 7 | CMD ["/bin/bash"] |
6 | 8 |
|
7 | 9 | # makes CUDA devices visible to the container by default |
8 | 10 | ENV NVIDIA_VISIBLE_DEVICES=all |
9 | 11 | ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility |
10 | 12 |
|
11 | | -# install basic tools to download files/models |
12 | | -RUN apt-get update -q &&\ |
13 | | - apt-get install -q -y --no-install-recommends bzip2 curl wget ca-certificates &&\ |
14 | | - apt-get clean &&\ |
15 | | - rm -rf /var/lib/apt/lists/* &&\ |
| 13 | +# install basic Ubuntu packages including python3.11 |
| 14 | +ARG DEBIAN_FRONTEND=noninteractive |
| 15 | +ENV TZ=Europe/Berlin |
| 16 | +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone |
| 17 | +RUN apt-get update && apt-get install -y software-properties-common && add-apt-repository ppa:deadsnakes/ppa |
| 18 | +RUN apt-get update -q && \ |
| 19 | + apt-get install -q -y --no-install-recommends bzip2 curl wget ca-certificates libmagic1 libpq-dev build-essential python3.11 python3-pip ffmpeg && \ |
| 20 | + apt-get clean && \ |
| 21 | + rm -rf /var/lib/apt/lists/* && \ |
16 | 22 | rm -r /var/cache |
17 | 23 |
|
18 | | -# install micromamba for anaconda python package management |
19 | | -ARG MICROMAMBA_VERSION=1.5.1 |
20 | | -RUN curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/${MICROMAMBA_VERSION} -o mamba.tar.bz2 |
21 | | -RUN tar -xvj -f mamba.tar.bz2 bin/micromamba |
22 | | -RUN rm mamba.tar.bz2 |
23 | | - |
24 | | -# create the 'dats' python environment with all dependencies |
25 | | -ENV MAMBA_ROOT_PREFIX=/opt |
26 | | -COPY environment.yml . |
27 | | -COPY requirements.txt /requirements.txt |
28 | | -RUN micromamba create -f environment.yml -q -y &&\ |
29 | | - micromamba clean -a -f -q -y &&\ |
30 | | - find /opt/ -follow -type f -name '*.a' -delete &&\ |
31 | | - find /opt/ -follow -type f -name '*.js.map' -delete &&\ |
32 | | - rm -r /root/.cache |
33 | | - |
34 | | - |
35 | | -# These settings & scripts are needed to automatically start any CMD in the container with the python environment |
36 | | -ENV MAMBA_EXE="/bin/micromamba" |
37 | | -ENV ENV_NAME=dats |
38 | | -ARG MAMBA_DOCKERFILE_ACTIVATE=1 |
39 | | -COPY _entrypoint.sh /usr/local/bin/_entrypoint.sh |
40 | | -COPY _activate_current_env.sh /usr/local/bin/_activate_current_env.sh |
41 | | -COPY _dockerfile_shell.sh /usr/local/bin/_dockerfile_shell.sh |
42 | | -ENTRYPOINT ["/usr/local/bin/_entrypoint.sh"] |
43 | | -SHELL ["/usr/local/bin/_dockerfile_shell.sh"] |
44 | | - |
| 24 | +# create the python environment |
| 25 | +ENV UV_LINK_MODE=copy |
| 26 | +ENV UV_COMPILE_BYTECODE=1 |
| 27 | +ENV UV_LOCKED=1 |
45 | 28 |
|
| 29 | +WORKDIR /dats_code |
| 30 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 31 | + --mount=type=bind,source=uv.lock,target=uv.lock \ |
| 32 | + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ |
| 33 | + uv sync --directory . --no-dev --no-editable --no-install-project --no-install-workspace --no-managed-python |
| 34 | +ENV PATH="/dats_code/.venv/bin:${PATH}" |
46 | 35 |
|
47 | 36 | # set up python env variables |
48 | | -ARG DATS_ENV |
49 | | -ENV DATS_ENV=${DATS_ENV} \ |
50 | | - PYTHONFAULTHANDLER=1 \ |
51 | | - PYTHONUNBUFFERED=1 \ |
52 | | - PYTHONHASHSEED=random \ |
53 | | - PYTHONDONTWRITEBYTECODE=1 \ |
54 | | - CUPY_CACHE_IN_MEMORY=1 |
| 37 | +ENV PYTHONFAULTHANDLER=1 |
| 38 | +ENV PYTHONUNBUFFERED=1 |
| 39 | +ENV PYTHONHASHSEED=random |
| 40 | +ENV PYTHONDONTWRITEBYTECODE=1 |
| 41 | +ENV CUPY_CACHE_IN_MEMORY=1 |
55 | 42 |
|
56 | 43 | # allow running celery workers as superuser |
57 | 44 | ENV C_FORCE_ROOT=1 |
58 | 45 |
|
59 | | -# For development, Jupyter remote kernel |
60 | | -# Using inside the container: |
61 | | -# jupyter lab --ip=0.0.0.0 --allow-root --NotebookApp.custom_display_url=http://127.0.0.1:8888 |
62 | | -ARG INSTALL_JUPYTER=false |
63 | | -RUN bash -c "if [ $INSTALL_JUPYTER == 'true' ] ; then micromamba install jupyterlab -c conda-forge -q -y -n dats && micromamba clean -a -f -q -y ; fi" |
64 | | - |
65 | 46 | # copy the actual dats source code into the image |
66 | | -WORKDIR /dats_code |
67 | 47 | COPY . /dats_code |
68 | 48 | WORKDIR /dats_code/src |
0 commit comments