1- FROM mambaorg/micromamba:1.5.1 as conda
1+ FROM python:3.11-slim as test-image
2+ ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
3+ WORKDIR /app
24
3- # Speed up the build, and avoid unnecessary writes to disk
4- ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 CONDA_DIR=/opt/conda
5- ENV PIPENV_VENV_IN_PROJECT=true PIP_NO_CACHE_DIR=false PIP_DISABLE_PIP_VERSION_CHECK=1
6- ENV PATH=${CONDA_DIR}/bin:${PATH}
7- ENV MAMBA_ROOT_PREFIX="/opt/conda"
5+ # Minimal OS deps for tests
6+ RUN apt-get update && apt-get install -y --no-install-recommends \
7+ git curl \
8+ && rm -rf /var/lib/apt/lists/*
89
9- COPY requirements.txt /tmp/requirements.txt
10- COPY requirements-dev.txt /tmp/requirements-dev.txt
11- COPY environment.yaml /tmp/environment.yaml
10+ # Install uv
11+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
12+ ENV PATH= "/root/.local/bin:$PATH"
1213
13- RUN micromamba create -y --file /tmp/environment.yaml \
14- && micromamba clean --all --yes \
15- && find /opt/conda/ -follow -type f -name '*.pyc' -delete
14+ # Create venv and activate permanently
15+ RUN uv venv --clear --python 3.13
16+ ENV VIRTUAL_ENV="/app/.venv"
17+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
1618
17-
18- FROM python as test-image
19- ENV PATH=/opt/conda/envs/qdaxpy310/bin/:$PATH APP_FOLDER=/app
20- ENV PYTHONPATH=$APP_FOLDER:$PYTHONPATH
21-
22- COPY --from=conda /opt/conda/envs/. /opt/conda/envs/
23- COPY requirements-dev.txt ./
24-
25- RUN pip install -r requirements-dev.txt
19+ # Install the project with dev extras
20+ COPY pyproject.toml README.md ./
21+ COPY qdax ./qdax
22+ RUN uv pip install jax[cuda] .[dev]
2623
2724
2825FROM nvidia/cuda:11.5.2-cudnn8-devel-ubuntu20.04 as cuda-image
29- ENV PATH=/opt/conda/envs/qdaxpy310/bin/:$PATH APP_FOLDER=/app
30- ENV PYTHONPATH=$APP_FOLDER:$PYTHONPATH
31-
32-
33- ENV DISTRO ubuntu2004
34- ENV CPU_ARCH x86_64
35- RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/$DISTRO/$CPU_ARCH/3bf863cc.pub
36-
37-
38- COPY --from=conda /opt/conda/envs/. /opt/conda/envs/
39- ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.0/targets/x86_64-linux/lib
40-
41- ENV TZ=Europe/Paris
42- RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
43- RUN pip --no-cache-dir install jaxlib==0.4.16+cuda11.cudnn86 \
44- -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html \
45- && rm -rf /tmp/*
46-
47- WORKDIR $APP_FOLDER
48-
49- ARG USER_ID=1000
50- ARG GROUP_ID=1000
51- ENV USER=eng
52- ENV GROUP=eng
53- RUN groupadd --gid ${GROUP_ID} $GROUP && useradd -g $GROUP --uid ${USER_ID} --shell /usr/sbin/nologin -m $USER && chown -R $USER:$GROUP $APP_FOLDER
54- USER $USER
26+ ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
27+ WORKDIR /app
5528
56-
57- FROM cuda-image as dev-image
58- # The dev-image does not contain the any file, qdax is expected to be mounted
59- # afterwards
60-
61- USER root
29+ # System packages needed for examples/headless rendering and tooling
6230RUN apt-get update && \
6331 apt-get install -y --no-install-recommends \
6432 curl \
@@ -70,8 +38,6 @@ RUN apt-get update && \
7038 libosmesa6-dev \
7139 patchelf \
7240 python3-opengl \
73- python3-dev=3.10* \
74- python3-pip \
7541 screen \
7642 sudo \
7743 tmux \
@@ -82,21 +48,33 @@ RUN apt-get update && \
8248 xvfb && \
8349 rm -rf /var/lib/apt/lists/*
8450
51+ # Install uv
52+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
53+ ENV PATH="/root/.local/bin:$PATH"
8554
86- COPY requirements-dev.txt /tmp/requirements-dev.txt
87- RUN pip --no-cache-dir install -r /tmp/requirements-dev.txt && rm -rf /tmp/*
88- USER $USER
55+ # Create venv and activate permanently
56+ RUN uv venv --clear --python 3.13
57+ ENV VIRTUAL_ENV="/app/.venv"
58+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
8959
90- FROM cuda-image as run-image
91- # The run-image (default) is the same as the dev-image with the some files directly
92- # copied inside
60+ # Install the project with dev and examples extras
61+ COPY pyproject.toml README.md ./
62+ COPY qdax ./qdax
63+ RUN uv pip install jax[cuda] .[dev,examples]
9364
94- COPY qdax qdax
95- COPY setup.py ./
96- COPY README.md ./
9765
98- RUN pip install .
66+ FROM cuda-image as dev-image
67+ # The dev-image already contains dependencies; repo can be mounted at /app for live dev
9968
100- WORKDIR /
69+ ARG USER_ID=1000
70+ ARG GROUP_ID=1000
71+ ENV USER=eng
72+ ENV GROUP=eng
73+ RUN groupadd --gid ${GROUP_ID} $GROUP && useradd -g $GROUP --uid ${USER_ID} --shell /usr/sbin/nologin -m $USER && chown -R $USER:$GROUP /app
74+ USER $USER
10175
76+
77+ FROM cuda-image as run-image
78+ # Default run image
79+ WORKDIR /
10280CMD ["python" ]
0 commit comments