|
| 1 | +# Build Python using uv in a separate stage |
| 2 | +FROM ghcr.io/astral-sh/uv:bookworm-slim AS python-builder |
| 3 | + |
| 4 | +ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy |
| 5 | +ENV UV_PYTHON_INSTALL_DIR=/opt/python |
| 6 | +ENV UV_PYTHON_PREFERENCE=only-managed |
| 7 | + |
| 8 | +ARG PYTHON_VERSION |
| 9 | +RUN uv python install $PYTHON_VERSION |
| 10 | +RUN mv /opt/python/cpython-$PYTHON_VERSION-linux-*/ /opt/python/$PYTHON_VERSION |
| 11 | + |
| 12 | + |
| 13 | +FROM docker.io/library/ubuntu:22.04 |
| 14 | +LABEL org.opencontainers.image.base.name="docker.io/library/ubuntu:22.04" |
| 15 | + |
| 16 | +### ARG declarations ### |
| 17 | +ARG DEBIAN_FRONTEND=noninteractive |
| 18 | +ARG R_VERSION |
| 19 | +ARG PYTHON_VERSION |
| 20 | +ARG QUARTO_VERSION |
| 21 | + |
| 22 | +### Install Apt Packages ### |
| 23 | +RUN apt-get update -yqq --fix-missing && \ |
| 24 | + apt-get upgrade -yqq && \ |
| 25 | + apt-get dist-upgrade -yqq && \ |
| 26 | + apt-get autoremove -yqq --purge && \ |
| 27 | + apt-get install -yqq --no-install-recommends \ |
| 28 | + curl \ |
| 29 | + ca-certificates \ |
| 30 | + gnupg \ |
| 31 | + tar && \ |
| 32 | + bash -c "$(curl -1fsSL 'https://dl.posit.co/public/pro/setup.deb.sh')" && \ |
| 33 | + apt-get clean -yqq && \ |
| 34 | + rm -rf /var/lib/apt/lists/* |
| 35 | + |
| 36 | +COPY workbench-session/matrix/deps/ubuntu-22.04_packages.txt /tmp/ubuntu-22.04_packages.txt |
| 37 | +RUN apt-get update -yqq && \ |
| 38 | + xargs -a /tmp/ubuntu-22.04_packages.txt apt-get install -yqq --no-install-recommends && \ |
| 39 | + apt-get clean -yqq && \ |
| 40 | + rm -rf /var/lib/apt/lists/* |
| 41 | + |
| 42 | +# Install Python from previous stage |
| 43 | +COPY --from=python-builder /opt/python /opt/python |
| 44 | + |
| 45 | +### Install Jupyter ### |
| 46 | +RUN /opt/python/$PYTHON_VERSION/bin/python -m venv /opt/python/jupyter && \ |
| 47 | + /opt/python/jupyter/bin/pip install --no-cache-dir --upgrade pip setuptools wheel && \ |
| 48 | + /opt/python/jupyter/bin/pip install --no-cache-dir 'jupyterlab<5' notebook 'pwb_jupyterlab<2' && \ |
| 49 | + ln -s /opt/python/jupyter/bin/jupyter /usr/local/bin/jupyter |
| 50 | + |
| 51 | +### Install Jupyter kernel ### |
| 52 | +RUN /opt/python/$PYTHON_VERSION/bin/pip install --no-cache-dir --upgrade --break-system-packages \ |
| 53 | + ipykernel && \ |
| 54 | + /opt/python/$PYTHON_VERSION/bin/python -m ipykernel install --user --name python$PYTHON_VERSION --display-name "Python $PYTHON_VERSION" |
| 55 | + |
| 56 | +# Install R |
| 57 | +RUN RUN_UNATTENDED=1 R_VERSION=$R_VERSION bash -c "$(curl -fsSL https://rstd.io/r-install)" && \ |
| 58 | + find . -type f -name '[rR]-$R_VERSION.*\.(deb|rpm)' -delete |
| 59 | + |
| 60 | +### Install Quarto and TinyTeX ### |
| 61 | +# Caches won't invalidate correctly on new releases for TinyTeX installs. This ADD instruction is a workaround to bust |
| 62 | +# the cache on new releases. |
| 63 | +ADD https://api.github.com/repos/rstudio/tinytex-releases/releases/latest /tmp/tinytex-release.json |
| 64 | +RUN mkdir -p /opt/quarto/$QUARTO_VERSION && \ |
| 65 | + curl -fsSL "https://github.com/quarto-dev/quarto-cli/releases/download/v$QUARTO_VERSION/quarto-$QUARTO_VERSION-linux-amd64.tar.gz" | tar xzf - -C "/opt/quarto/$QUARTO_VERSION" --strip-components=1 && \ |
| 66 | + /opt/quarto/$QUARTO_VERSION/bin/quarto install tinytex --no-prompt --quiet \ |
| 67 | + && rm -f /tmp/tinytex-release.json |
| 68 | + |
| 69 | +### Install Quarto and TinyTeX ### |
| 70 | +ADD https://api.github.com/repos/rstudio/tinytex-releases/releases/latest /tmp/tinytex-release.json |
| 71 | +RUN mkdir -p /opt/quarto/$QUARTO_VERSION && \ |
| 72 | + curl -fsSL "https://github.com/quarto-dev/quarto-cli/releases/download/v$QUARTO_VERSION/quarto-$QUARTO_VERSION-linux-amd64.tar.gz" | tar xzf - -C "/opt/quarto/$QUARTO_VERSION" --strip-components=1 && \ |
| 73 | + /opt/quarto/$QUARTO_VERSION/bin/quarto install tinytex --no-prompt --quiet --update-path && \ |
| 74 | + ln -s /opt/quarto/$QUARTO_VERSION/bin/quarto /usr/local/bin/quarto && \ |
| 75 | + rm -f /tmp/tinytex-release.json |
| 76 | + |
| 77 | +COPY workbench-session/matrix/conf/vscode.extensions.conf /etc/rstudio/vscode.extensions.conf |
| 78 | +COPY workbench-session/matrix/conf/positron.extensions.conf /etc/rstudio/positron.extensions.conf |
| 79 | + |
| 80 | +EXPOSE 8788/tcp |
0 commit comments