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

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

# 必要パッケージインストール
RUN \
	apt-get update		&&	\
	apt-get -y upgrade	&&	\
	apt-get install -y		\
		sudo				\
		wget				\
		git					\
		curl				\
		ffmpeg				\
		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

# ollama インストール
RUN curl -fsSL https://ollama.com/install.sh | sh

# uv インストール
RUN curl -LsSf https://astral.sh/uv/install.sh | sh

# uv 環境変数設定
ENV PATH /opt/jupyter/.local/bin:$PATH

# python インストール
RUN uv python install

# Jupyter Lab 実行時の作業ディレクトリ
WORKDIR /opt/jupyter/jupyterlab
COPY --chown=jupyter:jupyter ./pyproject.toml /opt/jupyter/jupyterlab

RUN uv sync
RUN	uv run 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'/"						\
		-e "s/^# c.ServerApp.notebook_dir.*$/c.ServerApp.notebook_dir = '\/opt\/jupyter\/jupyterlab\/notebook'/" \
		~/.jupyter/jupyter_lab_config.py
	
CMD ["uv", "run", "jupyter", "lab"]