Skip to content

Commit f5b373a

Browse files
committed
arm RStudio and multistage build
1 parent dc51879 commit f5b373a

File tree

2 files changed

+79
-45
lines changed

2 files changed

+79
-45
lines changed

Dockerfile.arm

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
ARG BASE=nvcr.io/nvidia/rapidsai/notebooks:25.10-cuda13-py3.13
2-
FROM $BASE
2+
3+
###############################################################################
4+
# Builder stage: Install conda packages and fix ownership
5+
###############################################################################
6+
FROM $BASE as builder
7+
8+
USER root
9+
10+
# Install additional conda packages into base environment
11+
RUN . /opt/conda/etc/profile.d/conda.sh; conda activate base && \
12+
mamba install -y jupyterhub-singleuser jupyter-vscode-proxy jupyter-resource-usage jupyter-rsession-proxy plotnine ibis-duckdb duckdb-engine minio git-filter-repo glances
13+
14+
# Change ownership of conda to UID 1000 (this won't bloat final image)
15+
RUN chown -R 1000:1000 /opt/conda
16+
17+
###############################################################################
18+
# Final stage
19+
###############################################################################
20+
FROM rapidsai/miniforge-cuda:25.12-cuda13.0.1-base-ubuntu24.04-py3.13
21+
322

423
# Use bash as default shell instead of sh
524
ENV SHELL=/bin/bash
@@ -20,29 +39,11 @@ ENV HOME="/home/${NB_USER}"
2039
USER root
2140
# Remove the useless 'ubuntu' user that currently has UID 1000
2241
RUN userdel -r ubuntu
42+
RUN useradd -rm -d /home/jovyan -s /bin/bash -g conda -u 1000 jovyan
2343

24-
# Change rapids' UID from 1001 to 1000
25-
# This ONLY modifies /etc/passwd, NOT the filesystem
26-
RUN usermod -u 1000 rapids
27-
28-
# Rename rapids to jovyan
29-
RUN usermod -l jovyan rapids
30-
31-
# Move and fix the home directory
32-
RUN usermod -d /home/jovyan -m jovyan
33-
34-
35-
36-
# Copy entrypoint to a safe location before home gets mounted over
37-
RUN cp /home/jovyan/entrypoint.sh /usr/local/bin/entrypoint.sh && \
38-
chmod +x /usr/local/bin/entrypoint.sh && \
39-
chown 1000:1000 /usr/local/bin/entrypoint.sh && \
40-
sed -i '4i . /opt/conda/etc/profile.d/conda.sh; conda activate notebook' /usr/local/bin/entrypoint.sh
41-
42-
# Set the new entrypoint location
43-
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
44-
45-
RUN groupadd --gid ${NB_UID} ${NB_USER}
44+
RUN apt-get update && apt-get -y install curl && rm -rf /var/lib/apt/lists/*
45+
# Copy the modified conda from builder (with packages installed and correct ownership)
46+
COPY --from=builder --chown=1000:1000 /opt/conda /opt/conda
4647

4748
# install vscode
4849
RUN curl -fsSL https://code-server.dev/install.sh | sh && rm -rf .cache
@@ -58,16 +59,18 @@ RUN adduser "$NB_USER" sudo && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoer
5859
COPY install_r.sh install_r.sh
5960
RUN bash install_r.sh
6061

61-
# RStudio not available for arm
62+
# RStudio
63+
COPY install_rstudio.sh install_rstudio.sh
64+
RUN bash install_rstudio.sh
6265
# RUN curl -s https://raw.githubusercontent.com/rocker-org/ml/refs/heads/master/install_rstudio.sh | bash
6366

6467
COPY Rprofile /usr/lib/R/etc/Rprofile.site
6568

6669
## Add rstudio's binaries to path for quarto
6770
ENV PATH=$PATH:/usr/lib/rstudio-server/bin/quarto/bin
6871

69-
# activate notebook by default (created later)
70-
RUN sed 's/conda activate base/conda activate notebook/' /home/$NB_USER/.bashrc > /etc/profile.d/bashrc
72+
# activate base by default in bashrc
73+
# RUN sed 's/conda activate base/conda activate base/' /home/$NB_USER/.bashrc > /etc/profile.d/bashrc
7174

7275
WORKDIR /home/$NB_USER
7376
USER $NB_USER
@@ -83,10 +86,7 @@ RUN Rscript /tmp/install.r
8386
COPY install_spatial.r /tmp/install.r
8487
RUN Rscript /tmp/install.r
8588

86-
RUN conda create -p /opt/conda/envs/notebook jupyterhub-singleuser jupyter-vscode-proxy jupyter-resource-usage
87-
RUN . /opt/conda/etc/profile.d/conda.sh; conda activate notebook && mamba install plotnine ibis-duckdb duckdb-engine minio git-filter-repo glances
88-
89-
89+
USER $NB_USER
9090

9191
CMD ["jupyter", "lab", "--no-browser", "--ip=0.0.0.0"]
9292

install_rstudio.sh

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,57 @@ if [ "$RSTUDIO_VERSION" = "latest" ]; then
2626
RSTUDIO_VERSION="stable"
2727
fi
2828

29-
if [ "$UBUNTU_CODENAME" = "focal" ]; then
30-
UBUNTU_CODENAME="bionic"
31-
fi
32-
33-
# TODO: remove this workaround for Ubuntu 24.04
34-
if [ "$UBUNTU_CODENAME" = "noble" ]; then
35-
UBUNTU_CODENAME="jammy"
36-
fi
37-
38-
if [ "$RSTUDIO_VERSION" = "stable" ] || [ "$RSTUDIO_VERSION" = "preview" ] || [ "$RSTUDIO_VERSION" = "daily" ]; then
39-
if [ "$UBUNTU_CODENAME" = "bionic" ]; then
40-
UBUNTU_CODENAME="focal"
29+
# Handle ARM64 architecture
30+
# ARM64 builds are only available for jammy (22.04), not focal, bionic, or noble
31+
if [ "$ARCH" = "arm64" ]; then
32+
echo "Detected ARM64 architecture, using appropriate RStudio Server build..."
33+
34+
# ARM64 builds only available for Ubuntu 22.04 (jammy)
35+
# Noble (24.04) doesn't have separate ARM64 builds yet, use jammy
36+
if [ "$UBUNTU_CODENAME" != "jammy" ]; then
37+
echo "Using jammy build for ARM64 (current codename: $UBUNTU_CODENAME)..."
38+
UBUNTU_CODENAME="jammy"
4139
fi
42-
wget "https://rstudio.org/download/latest/${RSTUDIO_VERSION}/server/${UBUNTU_CODENAME}/rstudio-server-latest-${ARCH}.deb" -O "$DOWNLOAD_FILE"
43-
else
44-
wget "https://download2.rstudio.org/server/${UBUNTU_CODENAME}/${ARCH}/rstudio-server-${RSTUDIO_VERSION/"+"/"-"}-${ARCH}.deb" -O "$DOWNLOAD_FILE" ||
40+
41+
if [ "$RSTUDIO_VERSION" = "stable" ]; then
42+
# Use latest stable version from S3 bucket (verified working)
43+
# Current stable version as of Nov 2025
44+
RSTUDIO_VERSION="2025.09.2-418"
45+
echo "Downloading RStudio Server ${RSTUDIO_VERSION} for ARM64..."
46+
wget "https://s3.amazonaws.com/rstudio-ide-build/server/${UBUNTU_CODENAME}/${ARCH}/rstudio-server-${RSTUDIO_VERSION}-${ARCH}.deb" -O "$DOWNLOAD_FILE"
47+
elif [ "$RSTUDIO_VERSION" = "preview" ] || [ "$RSTUDIO_VERSION" = "daily" ]; then
48+
# Use daily builds for preview/daily
49+
# Get the latest daily build number - using a recent known working version
50+
RSTUDIO_VERSION="2025.12.0-daily-302"
51+
echo "Downloading RStudio Server daily build ${RSTUDIO_VERSION} for ARM64..."
52+
wget "https://s3.amazonaws.com/rstudio-ide-build/server/${UBUNTU_CODENAME}/${ARCH}/rstudio-server-${RSTUDIO_VERSION}-${ARCH}.deb" -O "$DOWNLOAD_FILE"
53+
else
54+
# User specified a specific version
55+
echo "Downloading RStudio Server ${RSTUDIO_VERSION} for ARM64..."
4556
wget "https://s3.amazonaws.com/rstudio-ide-build/server/${UBUNTU_CODENAME}/${ARCH}/rstudio-server-${RSTUDIO_VERSION/"+"/"-"}-${ARCH}.deb" -O "$DOWNLOAD_FILE"
57+
fi
58+
else
59+
# AMD64/x86_64 architecture - use standard installation
60+
61+
# Apply Ubuntu codename conversions for x86_64
62+
if [ "$UBUNTU_CODENAME" = "focal" ]; then
63+
UBUNTU_CODENAME="bionic"
64+
fi
65+
66+
# TODO: remove this workaround for Ubuntu 24.04
67+
if [ "$UBUNTU_CODENAME" = "noble" ]; then
68+
UBUNTU_CODENAME="jammy"
69+
fi
70+
71+
if [ "$RSTUDIO_VERSION" = "stable" ] || [ "$RSTUDIO_VERSION" = "preview" ] || [ "$RSTUDIO_VERSION" = "daily" ]; then
72+
if [ "$UBUNTU_CODENAME" = "bionic" ]; then
73+
UBUNTU_CODENAME="focal"
74+
fi
75+
wget "https://rstudio.org/download/latest/${RSTUDIO_VERSION}/server/${UBUNTU_CODENAME}/rstudio-server-latest-${ARCH}.deb" -O "$DOWNLOAD_FILE"
76+
else
77+
wget "https://download2.rstudio.org/server/${UBUNTU_CODENAME}/${ARCH}/rstudio-server-${RSTUDIO_VERSION/"+"/"-"}-${ARCH}.deb" -O "$DOWNLOAD_FILE" ||
78+
wget "https://s3.amazonaws.com/rstudio-ide-build/server/${UBUNTU_CODENAME}/${ARCH}/rstudio-server-${RSTUDIO_VERSION/"+"/"-"}-${ARCH}.deb" -O "$DOWNLOAD_FILE"
79+
fi
4680
fi
4781

4882
gdebi --non-interactive "$DOWNLOAD_FILE"

0 commit comments

Comments
 (0)