Skip to content

Commit

Permalink
Add jupyter venv env vars. Base update
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Jun 16, 2024
1 parent f9f4b2c commit 50c21b3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
13 changes: 6 additions & 7 deletions build/COPY_ROOT_0/opt/ai-dock/bin/build/layer0/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build_common_main() {

build_common_do_install_python_venv() {
$APT_INSTALL \
"python${2}" \
"python${2}-full" \
"python${2}-dev" \
"python${2}-venv"

Expand Down Expand Up @@ -38,18 +38,17 @@ build_common_install_python() {

build_common_install_jupyter() {
$APT_INSTALL \
python3.10 \
python3.10-full \
python3.10-dev \
python3.10-venv
venv="$VENV_DIR/jupyter"
python3.10 -m venv "$venv"
nvm use node
"$venv/bin/pip" install --no-cache-dir \
python3.10 -m venv "$JUPYTER_VENV"
nvm use default
"$JUPYTER_VENV_PIP" install --no-cache-dir \
jupyterlab \
notebook

printf "Removing default ipython kernel...\n"
rm -rf "$VENV_DIR/jupyter/share/jupyter/kernels/python3"
rm -rf "$JUPYTER_VENV/share/jupyter/kernels/python3"
}

build_common_main "$@"
34 changes: 17 additions & 17 deletions build/COPY_ROOT_0/opt/ai-dock/bin/supervisor-jupyter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ function start() {

printf "\nStarting %s...\n" "${SERVICE_NAME:-service}"

nvm use node
"$JUPYTER_VENV/bin/jupyter" \
$JUPYTER_MODE \
--allow-root \
--ip=127.0.0.1 \
--port=$LISTEN_PORT \
--no-browser \
--ServerApp.token='' \
--ServerApp.password='' \
--ServerApp.trust_xheaders=True \
--ServerApp.disable_check_xsrf=False \
--ServerApp.allow_remote_access=True \
--ServerApp.allow_origin='*' \
--ServerApp.allow_credentials=True \
--ServerApp.root_dir=/ \
--ServerApp.preferred_dir="$WORKSPACE" \
--KernelSpecManager.ensure_native_kernel=False
source "$JUPYTER_VENV/bin/activate"
nvm use default
jupyter "$JUPYTER_MODE" \
--allow-root \
--ip=127.0.0.1 \
--port=$LISTEN_PORT \
--no-browser \
--ServerApp.token='' \
--ServerApp.password='' \
--ServerApp.trust_xheaders=True \
--ServerApp.disable_check_xsrf=False \
--ServerApp.allow_remote_access=True \
--ServerApp.allow_origin='*' \
--ServerApp.allow_credentials=True \
--ServerApp.root_dir=/ \
--ServerApp.preferred_dir="$WORKSPACE" \
--KernelSpecManager.ensure_native_kernel=False
}

function set_kernel_paths() {
Expand Down
9 changes: 5 additions & 4 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ LABEL org.opencontainers.image.description "Python development environment in a

LABEL maintainer="Rob Ballantyne <[email protected]>"

# Add new paths at front
#ENV PATH=/opt/another/bin:$PATH
ENV JUPYTER_VENV=$VENV_DIR/jupyter
ENV JUPYTER_VENV_PYTHON=$JUPYTER_VENV/bin/python
ENV JUPYTER_VENV_PIP=$JUPYTER_VENV/bin/pip

# Copy early so we can use scripts in the build - Changes to these files will invalidate the cache and cause a rebuild.
COPY --chown=0:1111 ./COPY_ROOT_0/ /

# Define the startup mamba environment for interactive sessions.
# Define the startup environment for interactive sessions.
# ENV for inheritance
ARG PYTHON_VERSION=all
ENV PYTHON_VERSION=${PYTHON_VERSION}
ARG PYTHON_VENV_NAME=python_312
ARG PYTHON_VENV_NAME=python_310
ENV PYTHON_VENV_NAME=${PYTHON_VENV_NAME}
ENV PYTHON_DEFAULT_VENV=${PYTHON_VENV_NAME}
ENV OPT_SYNC=$OPT_SYNC
Expand Down

0 comments on commit 50c21b3

Please sign in to comment.