diff --git a/README.md b/README.md index 126b844..0fc1f95 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ * CPU の場合 ``` -cp jupyter/Dockerfile.gpu jupyter/Dockerfile +cp jupyter/Dockerfile.cpu jupyter/Dockerfile docker compose build ``` diff --git a/README.md b/README.md index 126b844..0fc1f95 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ * CPU の場合 ``` -cp jupyter/Dockerfile.gpu jupyter/Dockerfile +cp jupyter/Dockerfile.cpu jupyter/Dockerfile docker compose build ``` diff --git a/jupyter/Dockerfile b/jupyter/Dockerfile index cf5b0a7..c98acf4 100644 --- a/jupyter/Dockerfile +++ b/jupyter/Dockerfile @@ -10,10 +10,18 @@ apt-get -y upgrade && \ apt-get install -y \ sudo \ + wget \ + git \ + curl \ + python3 \ + python3-dev \ + python3-pip \ + 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 @@ -22,24 +30,30 @@ USER jupyter WORKDIR /opt/jupyter -COPY ./requirements.txt /opt/jupyter/ +# ollama インストール +# RUN curl -fsSL https://ollama.com/install.sh | sh -RUN python -m venv ~/.venv && \ - . ~/.venv/bin/activate && \ - pip install --upgrade pip && \ - pip install jupyterlab && \ - pip install -r requirements.txt && \ - jupyter lab --generate-config && \ +# uv インストール +RUN curl -LsSf https://astral.sh/uv/install.sh | sh + +# uv 環境変数設定 +ENV PATH /opt/jupyter/.local/bin:$PATH + +# python インストール +RUN uv python install +COPY ./pyproject.toml /opt/jupyter/ + +RUN uv sync +RUN uv run --with jupyter 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"] +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] diff --git a/README.md b/README.md index 126b844..0fc1f95 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ * CPU の場合 ``` -cp jupyter/Dockerfile.gpu jupyter/Dockerfile +cp jupyter/Dockerfile.cpu jupyter/Dockerfile docker compose build ``` diff --git a/jupyter/Dockerfile b/jupyter/Dockerfile index cf5b0a7..c98acf4 100644 --- a/jupyter/Dockerfile +++ b/jupyter/Dockerfile @@ -10,10 +10,18 @@ apt-get -y upgrade && \ apt-get install -y \ sudo \ + wget \ + git \ + curl \ + python3 \ + python3-dev \ + python3-pip \ + 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 @@ -22,24 +30,30 @@ USER jupyter WORKDIR /opt/jupyter -COPY ./requirements.txt /opt/jupyter/ +# ollama インストール +# RUN curl -fsSL https://ollama.com/install.sh | sh -RUN python -m venv ~/.venv && \ - . ~/.venv/bin/activate && \ - pip install --upgrade pip && \ - pip install jupyterlab && \ - pip install -r requirements.txt && \ - jupyter lab --generate-config && \ +# uv インストール +RUN curl -LsSf https://astral.sh/uv/install.sh | sh + +# uv 環境変数設定 +ENV PATH /opt/jupyter/.local/bin:$PATH + +# python インストール +RUN uv python install +COPY ./pyproject.toml /opt/jupyter/ + +RUN uv sync +RUN uv run --with jupyter 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"] +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] diff --git a/jupyter/Dockerfile.cpu b/jupyter/Dockerfile.cpu new file mode 100644 index 0000000..c98acf4 --- /dev/null +++ b/jupyter/Dockerfile.cpu @@ -0,0 +1,59 @@ +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 \ + wget \ + git \ + curl \ + python3 \ + python3-dev \ + python3-pip \ + 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 +COPY ./pyproject.toml /opt/jupyter/ + +RUN uv sync +RUN uv run --with jupyter 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 + +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] + diff --git a/README.md b/README.md index 126b844..0fc1f95 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ * CPU の場合 ``` -cp jupyter/Dockerfile.gpu jupyter/Dockerfile +cp jupyter/Dockerfile.cpu jupyter/Dockerfile docker compose build ``` diff --git a/jupyter/Dockerfile b/jupyter/Dockerfile index cf5b0a7..c98acf4 100644 --- a/jupyter/Dockerfile +++ b/jupyter/Dockerfile @@ -10,10 +10,18 @@ apt-get -y upgrade && \ apt-get install -y \ sudo \ + wget \ + git \ + curl \ + python3 \ + python3-dev \ + python3-pip \ + 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 @@ -22,24 +30,30 @@ USER jupyter WORKDIR /opt/jupyter -COPY ./requirements.txt /opt/jupyter/ +# ollama インストール +# RUN curl -fsSL https://ollama.com/install.sh | sh -RUN python -m venv ~/.venv && \ - . ~/.venv/bin/activate && \ - pip install --upgrade pip && \ - pip install jupyterlab && \ - pip install -r requirements.txt && \ - jupyter lab --generate-config && \ +# uv インストール +RUN curl -LsSf https://astral.sh/uv/install.sh | sh + +# uv 環境変数設定 +ENV PATH /opt/jupyter/.local/bin:$PATH + +# python インストール +RUN uv python install +COPY ./pyproject.toml /opt/jupyter/ + +RUN uv sync +RUN uv run --with jupyter 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"] +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] diff --git a/jupyter/Dockerfile.cpu b/jupyter/Dockerfile.cpu new file mode 100644 index 0000000..c98acf4 --- /dev/null +++ b/jupyter/Dockerfile.cpu @@ -0,0 +1,59 @@ +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 \ + wget \ + git \ + curl \ + python3 \ + python3-dev \ + python3-pip \ + 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 +COPY ./pyproject.toml /opt/jupyter/ + +RUN uv sync +RUN uv run --with jupyter 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 + +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] + diff --git a/jupyter/Dockerfile.gpu b/jupyter/Dockerfile.gpu index 6e02066..3ec58d8 100644 --- a/jupyter/Dockerfile.gpu +++ b/jupyter/Dockerfile.gpu @@ -25,6 +25,7 @@ && \ rm -rf /var/lib/apt/lists/* + # ユーザー追加 RUN useradd -m jupyter --home-dir /opt/jupyter && \ echo "jupyter ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/jupyter @@ -33,39 +34,30 @@ USER jupyter WORKDIR /opt/jupyter -# pyenv インストール -RUN curl https://pyenv.run | bash +# ollama インストール +RUN curl -fsSL https://ollama.com/install.sh | sh -# pyenv 環境変数設定 -ENV PYENV_ROOT /opt/jupyter/.pyenv -ENV PATH $PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH +# uv インストール +RUN curl -LsSf https://astral.sh/uv/install.sh | sh -# pyenv 初期化、python ビルド -RUN \ - eval "$(pyenv init --path)" && \ - pyenv update && \ - pyenv install 3.13 && \ - pyenv global 3.13 +# uv 環境変数設定 +ENV PATH /opt/jupyter/.local/bin:$PATH -COPY ./requirements.txt /opt/jupyter/ +# python インストール +RUN uv python install +COPY ./pyproject.toml /opt/jupyter/ -RUN python -m venv ~/.venv && \ - . ~/.venv/bin/activate && \ - pip install --upgrade pip && \ - pip install jupyterlab && \ - pip install -r requirements.txt && \ - pip cache purge && \ - jupyter lab --generate-config && \ +RUN uv sync +RUN uv run --with jupyter 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"] +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] diff --git a/README.md b/README.md index 126b844..0fc1f95 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ * CPU の場合 ``` -cp jupyter/Dockerfile.gpu jupyter/Dockerfile +cp jupyter/Dockerfile.cpu jupyter/Dockerfile docker compose build ``` diff --git a/jupyter/Dockerfile b/jupyter/Dockerfile index cf5b0a7..c98acf4 100644 --- a/jupyter/Dockerfile +++ b/jupyter/Dockerfile @@ -10,10 +10,18 @@ apt-get -y upgrade && \ apt-get install -y \ sudo \ + wget \ + git \ + curl \ + python3 \ + python3-dev \ + python3-pip \ + 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 @@ -22,24 +30,30 @@ USER jupyter WORKDIR /opt/jupyter -COPY ./requirements.txt /opt/jupyter/ +# ollama インストール +# RUN curl -fsSL https://ollama.com/install.sh | sh -RUN python -m venv ~/.venv && \ - . ~/.venv/bin/activate && \ - pip install --upgrade pip && \ - pip install jupyterlab && \ - pip install -r requirements.txt && \ - jupyter lab --generate-config && \ +# uv インストール +RUN curl -LsSf https://astral.sh/uv/install.sh | sh + +# uv 環境変数設定 +ENV PATH /opt/jupyter/.local/bin:$PATH + +# python インストール +RUN uv python install +COPY ./pyproject.toml /opt/jupyter/ + +RUN uv sync +RUN uv run --with jupyter 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"] +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] diff --git a/jupyter/Dockerfile.cpu b/jupyter/Dockerfile.cpu new file mode 100644 index 0000000..c98acf4 --- /dev/null +++ b/jupyter/Dockerfile.cpu @@ -0,0 +1,59 @@ +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 \ + wget \ + git \ + curl \ + python3 \ + python3-dev \ + python3-pip \ + 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 +COPY ./pyproject.toml /opt/jupyter/ + +RUN uv sync +RUN uv run --with jupyter 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 + +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] + diff --git a/jupyter/Dockerfile.gpu b/jupyter/Dockerfile.gpu index 6e02066..3ec58d8 100644 --- a/jupyter/Dockerfile.gpu +++ b/jupyter/Dockerfile.gpu @@ -25,6 +25,7 @@ && \ rm -rf /var/lib/apt/lists/* + # ユーザー追加 RUN useradd -m jupyter --home-dir /opt/jupyter && \ echo "jupyter ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/jupyter @@ -33,39 +34,30 @@ USER jupyter WORKDIR /opt/jupyter -# pyenv インストール -RUN curl https://pyenv.run | bash +# ollama インストール +RUN curl -fsSL https://ollama.com/install.sh | sh -# pyenv 環境変数設定 -ENV PYENV_ROOT /opt/jupyter/.pyenv -ENV PATH $PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH +# uv インストール +RUN curl -LsSf https://astral.sh/uv/install.sh | sh -# pyenv 初期化、python ビルド -RUN \ - eval "$(pyenv init --path)" && \ - pyenv update && \ - pyenv install 3.13 && \ - pyenv global 3.13 +# uv 環境変数設定 +ENV PATH /opt/jupyter/.local/bin:$PATH -COPY ./requirements.txt /opt/jupyter/ +# python インストール +RUN uv python install +COPY ./pyproject.toml /opt/jupyter/ -RUN python -m venv ~/.venv && \ - . ~/.venv/bin/activate && \ - pip install --upgrade pip && \ - pip install jupyterlab && \ - pip install -r requirements.txt && \ - pip cache purge && \ - jupyter lab --generate-config && \ +RUN uv sync +RUN uv run --with jupyter 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"] +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] diff --git a/jupyter/pyproject.toml b/jupyter/pyproject.toml new file mode 100644 index 0000000..2be6ffd --- /dev/null +++ b/jupyter/pyproject.toml @@ -0,0 +1,17 @@ +[project] +name = "tmp" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.13" +dependencies = [ + "matplotlib>=3.10.6", + "numpy>=2.3.2", + "ollama>=0.5.3", + "openpyxl>=3.1.5", + "pandas>=2.3.2", + "psycopg-binary>=3.2.9", + "python-dotenv>=1.1.1", + "requests>=2.32.5", + "sqlalchemy>=2.0.43", +] diff --git a/README.md b/README.md index 126b844..0fc1f95 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ * CPU の場合 ``` -cp jupyter/Dockerfile.gpu jupyter/Dockerfile +cp jupyter/Dockerfile.cpu jupyter/Dockerfile docker compose build ``` diff --git a/jupyter/Dockerfile b/jupyter/Dockerfile index cf5b0a7..c98acf4 100644 --- a/jupyter/Dockerfile +++ b/jupyter/Dockerfile @@ -10,10 +10,18 @@ apt-get -y upgrade && \ apt-get install -y \ sudo \ + wget \ + git \ + curl \ + python3 \ + python3-dev \ + python3-pip \ + 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 @@ -22,24 +30,30 @@ USER jupyter WORKDIR /opt/jupyter -COPY ./requirements.txt /opt/jupyter/ +# ollama インストール +# RUN curl -fsSL https://ollama.com/install.sh | sh -RUN python -m venv ~/.venv && \ - . ~/.venv/bin/activate && \ - pip install --upgrade pip && \ - pip install jupyterlab && \ - pip install -r requirements.txt && \ - jupyter lab --generate-config && \ +# uv インストール +RUN curl -LsSf https://astral.sh/uv/install.sh | sh + +# uv 環境変数設定 +ENV PATH /opt/jupyter/.local/bin:$PATH + +# python インストール +RUN uv python install +COPY ./pyproject.toml /opt/jupyter/ + +RUN uv sync +RUN uv run --with jupyter 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"] +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] diff --git a/jupyter/Dockerfile.cpu b/jupyter/Dockerfile.cpu new file mode 100644 index 0000000..c98acf4 --- /dev/null +++ b/jupyter/Dockerfile.cpu @@ -0,0 +1,59 @@ +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 \ + wget \ + git \ + curl \ + python3 \ + python3-dev \ + python3-pip \ + 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 +COPY ./pyproject.toml /opt/jupyter/ + +RUN uv sync +RUN uv run --with jupyter 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 + +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] + diff --git a/jupyter/Dockerfile.gpu b/jupyter/Dockerfile.gpu index 6e02066..3ec58d8 100644 --- a/jupyter/Dockerfile.gpu +++ b/jupyter/Dockerfile.gpu @@ -25,6 +25,7 @@ && \ rm -rf /var/lib/apt/lists/* + # ユーザー追加 RUN useradd -m jupyter --home-dir /opt/jupyter && \ echo "jupyter ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/jupyter @@ -33,39 +34,30 @@ USER jupyter WORKDIR /opt/jupyter -# pyenv インストール -RUN curl https://pyenv.run | bash +# ollama インストール +RUN curl -fsSL https://ollama.com/install.sh | sh -# pyenv 環境変数設定 -ENV PYENV_ROOT /opt/jupyter/.pyenv -ENV PATH $PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH +# uv インストール +RUN curl -LsSf https://astral.sh/uv/install.sh | sh -# pyenv 初期化、python ビルド -RUN \ - eval "$(pyenv init --path)" && \ - pyenv update && \ - pyenv install 3.13 && \ - pyenv global 3.13 +# uv 環境変数設定 +ENV PATH /opt/jupyter/.local/bin:$PATH -COPY ./requirements.txt /opt/jupyter/ +# python インストール +RUN uv python install +COPY ./pyproject.toml /opt/jupyter/ -RUN python -m venv ~/.venv && \ - . ~/.venv/bin/activate && \ - pip install --upgrade pip && \ - pip install jupyterlab && \ - pip install -r requirements.txt && \ - pip cache purge && \ - jupyter lab --generate-config && \ +RUN uv sync +RUN uv run --with jupyter 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"] +CMD ["uv", "run", "--with", "jupyter", "jupyter", "lab"] diff --git a/jupyter/pyproject.toml b/jupyter/pyproject.toml new file mode 100644 index 0000000..2be6ffd --- /dev/null +++ b/jupyter/pyproject.toml @@ -0,0 +1,17 @@ +[project] +name = "tmp" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.13" +dependencies = [ + "matplotlib>=3.10.6", + "numpy>=2.3.2", + "ollama>=0.5.3", + "openpyxl>=3.1.5", + "pandas>=2.3.2", + "psycopg-binary>=3.2.9", + "python-dotenv>=1.1.1", + "requests>=2.32.5", + "sqlalchemy>=2.0.43", +] diff --git a/jupyter/requirements.txt b/jupyter/requirements.txt deleted file mode 100644 index 14e5e9e..0000000 --- a/jupyter/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -pandas -numpy -requests -matplotlib -openpyxl -ollama -psycopg-binary -python-dotenv -SQLAlchemy -torch -