Skip to content

Commit 3328340

Browse files
authored
Update NeMo Jupyter to use a more recent version (#228)
* replacing java install features * updating to use nvcr.io/nvidia/nemo:25.07.nemotron-nano-v2 * setting java version to 17 * adding digests for mise and java to feature-version/state.json for app caching * Adding digests for mise and mise-java * use a dockerfile now to set jupyter user and enter at the WORKDIR, removed --allow-root from docker-compose.yaml * using build context instead of GAR image * indentation error * troubleshooting java installation * Replacing root with jupyter and /workspace with /home/jupyter * reverting to the old java install digest * remove package list files from apt-get update * use sudo-passwordless.sh to grant sudo access, updated .devcontainer postCreateCommand to call it * Removing unused version of mise-java * adding comment in Dockerfile re: /var/lib/apt/lists/* removal
1 parent b54296c commit 3328340

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

feature-versions/state.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
"ghcr.io/devcontainers/features/common-utils": {
1919
"tag": "2",
2020
"installed": "@sha256:00fd45550f578d9d515044d9e2226e908dbc3d7aa6fcb9dee4d8bdb60be114cf"
21+
},
22+
"ghcr.io/roul/devcontainer-features/mise":{
23+
"tag":"1",
24+
"installed": "@sha256:bcbd34b34176b6255d5aa5b881f1addc99bb3eed6049c841cb201f63fca132e4"
2125
}
2226
}

src/nemo_jupyter/.devcontainer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
// Get the host's docker group ID and propagate it into the .env file, which
88
// allows it to be used within docker-compose.yaml.
99
// "initializeCommand": "DOCKER_GID=`getent group docker | cut -d: -f3` && echo \"DOCKER_GID=${DOCKER_GID}\" > .env",
10-
"postCreateCommand": "apt update && apt install -y sudo && ./startupscript/post-startup.sh root /workspace ${templateOption:cloud} ${templateOption:login} && echo -e \"alias weightsbiases='/usr/local/bin/wb'\\nalias wb='/usr/bin/wb'\" >> /root/.bashrc", // re-mount bucket files on container start up
10+
"postCreateCommand": "apt update && apt install -y sudo && ./startupscript/post-startup.sh jupyter /home/jupyter ${templateOption:cloud} ${templateOption:login} && echo -e \"alias weightsbiases='/usr/local/bin/wb'\\nalias wb='/usr/bin/wb'\" >> /home/jupyter/.bashrc && ./sudo-passwordless.sh jupyter", // re-mount bucket files on container start up
1111
"postStartCommand": [
1212
"./startupscript/remount-on-restart.sh",
13-
"root",
14-
"/workspace",
13+
"jupyter",
14+
"/home/jupyter",
1515
"${templateOption:cloud}",
1616
"${templateOption:login}"
1717
],
1818
"features": {
19+
"ghcr.io/roul/devcontainer-features/mise@sha256:bcbd34b34176b6255d5aa5b881f1addc99bb3eed6049c841cb201f63fca132e4": {},
1920
"ghcr.io/devcontainers/features/java@sha256:df67d6ff6e9cdd858207ae9e92a99ddb88384b789f79eecd6f873216e951d286": {
2021
"version": "17"
2122
},

src/nemo_jupyter/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM nvcr.io/nvidia/nemo:25.07.nemotron-nano-v2
2+
3+
ARG NB_USER=jupyter
4+
ARG NB_UID=1010
5+
ARG NB_GID=1000
6+
ARG WORKDIR=/home/${NB_USER}
7+
8+
USER root
9+
10+
# Only create the user, not the group—GID 1000 already exists as 'ubuntu'
11+
RUN useradd --uid ${NB_UID} --gid ${NB_GID} --create-home --home-dir ${WORKDIR} --shell /bin/bash ${NB_USER}
12+
13+
# Fix ownership for common dirs
14+
RUN mkdir -p /workspace \
15+
&& chown -R ${NB_UID}:${NB_GID} ${WORKDIR} /workspace /tmp \
16+
&& chown -R ${NB_UID}:${NB_GID} /opt/conda || true
17+
18+
# This folder caused java installation issues, removing it resolves this
19+
RUN rm -rf /var/lib/apt/lists/*
20+
21+
# Environment and working directory
22+
ENV HOME=${WORKDIR}
23+
WORKDIR ${WORKDIR}
24+
25+
# Switch to non-root user
26+
USER ${NB_USER}

src/nemo_jupyter/docker-compose.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ version: "2.4"
22
services:
33
app:
44
container_name: "application-server"
5-
image: "nvcr.io/nvidia/nemo:24.09"
6-
user: root
5+
build:
6+
context: .
7+
user: jupyter
78
restart: always
89
volumes:
910
- .:/workspace:cached
@@ -17,7 +18,7 @@ services:
1718
- /dev/fuse
1819
security_opt:
1920
- apparmor:unconfined
20-
command: jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root --LabApp.token=''
21+
command: jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --LabApp.token=''
2122
networks:
2223
app-network:
2324
external: true
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# This script is used to set up passwordless sudo for the core user on the VM.
4+
# It requires to be run with root priviledges and USER_NAME to be set in the environment.
5+
# It is typically called from post-startup.sh.
6+
7+
USER_NAME="${1}"
8+
9+
if [[ -z "${USER_NAME}" ]]; then
10+
echo "Usage: $0 <username>"
11+
exit 1
12+
fi
13+
14+
sudoers_file="/etc/sudoers"
15+
sudoers_d_file="/etc/sudoers.d/${USER_NAME}"
16+
17+
# Make sure user exists
18+
if ! id "${USER_NAME}" &>/dev/null; then
19+
echo "User ${USER_NAME} does not exist."
20+
exit 1
21+
fi
22+
23+
# Check if there's an old rule in the main sudoers file that requires a password
24+
if grep -q "^${USER_NAME} ALL=(ALL:ALL) ALL" "${sudoers_file}"; then
25+
echo "Found password-requiring rule for ${USER_NAME} in /etc/sudoers. Commenting it out."
26+
27+
# Comment out the old rule in /etc/sudoers
28+
sed -i "s/^${USER_NAME} ALL=(ALL:ALL) ALL/# ${USER_NAME} ALL=(ALL:ALL) ALL/" "${sudoers_file}"
29+
fi
30+
31+
echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" > "${sudoers_d_file}"
32+
chmod 440 "${sudoers_d_file}"
33+
34+
echo "User ${USER_NAME} has been given passwordless sudo access."

0 commit comments

Comments
 (0)