Newer
Older
jupyterlab-docker / jupyter / Dockerfile
FROM python:3.10.17-bookworm

ENV DEBIAN_FRONTEND=noninteractive
# ENV http_proxy=http://127.0.0.1:3128/
# ENV https_proxy=http://127.0.0.1:3128/

# 必要パッケージインストール
RUN \
	apt-get update		&&	\
	apt-get -y upgrade	&&	\
	apt-get install -y		\
		sudo				\
		postgresql-client	\
		&&					\
	rm -rf /var/lib/apt/lists/*

# ユーザー追加
RUN useradd -m jupyter --home-dir /opt/jupyter && \
	echo "jupyter ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/jupyter

# jupyter ユーザーで実行
USER jupyter
WORKDIR /opt/jupyter

COPY ./requirements.txt /opt/jupyter/

RUN python -m venv ~/.venv			&&	\
	. ~/.venv/bin/activate			&&	\
	pip install --upgrade pip		&&	\
	pip install jupyterlab			&&	\
	pip install -r requirements.txt	&&	\
	jupyter lab --generate-config	&&	\
	sed -i \
		-e "s/^# c.ServerApp.ip.*$/c.ServerApp.ip = '0.0.0.0'/"								\
		-e "s/^# c.ServerApp.port.*$/c.ServerApp.port = 8000/"								\
		-e "s/^# c.ServerApp.password_required.*$/c.ServerApp.password_required = False/"	\
		-e "s/^# c.ServerApp.token.*$/c.ServerApp.token = 'jupyter'/"						\
		~/.jupyter/jupyter_lab_config.py

# Jupyter Lab 実行時の作業ディレクトリ
WORKDIR /opt/jupyter/jupyterlab
ENV PATH /opt/jupyter/.venv/bin:$PATH

CMD ["jupyter", "lab"]