Skip to content

Commit da5c650

Browse files
committed
refactor(docker): simplify docker setup and update requirements
- Remove custom user setup in favor of default jovyan user - Use named volume for persistent data - Add pexpect dependency and clean up requirements installation
1 parent 117840c commit da5c650

3 files changed

Lines changed: 14 additions & 16 deletions

File tree

Dockerfile

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@ USER root
55

66
# Install git
77
RUN apt-get update && \
8-
apt-get install -y git sudo && \
8+
apt-get install -y git && \
99
git config --system credential.helper 'store --file ~/.git-credentials' && \
1010
rm -rf /var/lib/apt/lists/*
1111

12-
# Create user and grant sudo
13-
ARG JUPYTER_USER=jupyter_user
14-
RUN useradd -m -s /bin/bash -N -g users ${JUPYTER_USER} && \
15-
chmod 0440 /etc/sudoers.d/jovyan && \
16-
echo "${JUPYTER_USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${JUPYTER_USER}
12+
RUN echo "jovyan ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jovyan-sudo && \
13+
chmod 0440 /etc/sudoers.d/jovyan-sudo
14+
USER jovyan
1715

1816
# Install extensions
19-
COPY --chown=${JUPYTER_USER}:users requirements.txt /tmp/
20-
RUN pip install --no-cache-dir -r /tmp/requirements.txt
21-
22-
# Switch to user
23-
USER ${JUPYTER_USER}
24-
WORKDIR /home/${JUPYTER_USER}
17+
COPY requirements.txt /tmp/
18+
RUN pip install --no-cache-dir -r /tmp/requirements.txt

docker-compose.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ services:
44
context: .
55
args:
66
JUPYTER_IMAGE_VERSION: latest
7-
JUPYTER_USER: ${JUPYTER_USER:-jupyter_user}
87
ports:
98
- "8888:8888"
109
volumes:
11-
- ./data:/home/${JUPYTER_USER:-jupyter_user}/work
10+
- jupyterlab-user-data:/home/jovyan
1211
environment:
13-
- JUPYTER_ENABLE_LAB=yes
12+
- JUPYTER_ENABLE_LAB=yes
13+
14+
volumes:
15+
jupyterlab-user-data:
16+
name: jupyterlab-user-data

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ jupyterlab-search-replace
44
jupyterlab-day
55
jupyterlab-night
66
jupyterlab-lsp==5.2.0
7-
jedi-language-server
7+
jedi-language-server
8+
pexpect==4.9.0

0 commit comments

Comments
 (0)