-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.base_image
More file actions
44 lines (34 loc) · 1.03 KB
/
Copy pathDockerfile.base_image
File metadata and controls
44 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
FROM python:3.9-slim
# Install required packages
RUN pip install --no-cache-dir \
ipykernel \
jupyter_client
# Create a non-root user
RUN useradd -m -u 1000 jupyter
# Create virtual environment and necessary directories
ENV VIRTUAL_ENV=/home/jupyter/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Create working directories
RUN mkdir -p /opt/kernel /opt/connection && \
chown -R jupyter:jupyter /opt/kernel /opt/connection /home/jupyter
# Switch to non-root user
USER jupyter
WORKDIR /opt/kernel
# Upgrade pip
RUN pip install --upgrade pip
# Install ipykernel in the virtual environment
RUN pip install --no-cache-dir ipykernel jupyter_client
# Install some base Python dependencies
# TODO: pin versions
RUN pip install --no-cache-dir \
numpy \
pandas \
matplotlib \
seaborn \
scikit-learn \
scipy
# Make further pip installs quiet
ENV PIP_QUIET=1
# The command will be provided when running the container
CMD ["python", "-m", "ipykernel_launcher", "-f", "/opt/connection/kernel.json"]