mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-07 18:14:05 +00:00
45 lines
1.8 KiB
Docker
45 lines
1.8 KiB
Docker
FROM quay.io/jupyter/base-notebook
|
|
|
|
# Name your environment and choose the Python version
|
|
ARG env_name=python310
|
|
ARG py_ver=3.10
|
|
|
|
# You can add additional libraries here
|
|
RUN mamba create --yes -p "${CONDA_DIR}/envs/${env_name}" \
|
|
python=${py_ver} \
|
|
'ipykernel' \
|
|
'jupyterlab' && \
|
|
mamba clean --all -f -y
|
|
|
|
# Alternatively, you can comment out the lines above and uncomment those below
|
|
# if you'd prefer to use a YAML file present in the docker build context
|
|
|
|
# COPY --chown=${NB_UID}:${NB_GID} environment.yml /tmp/
|
|
# RUN mamba env create -p "${CONDA_DIR}/envs/${env_name}" -f /tmp/environment.yml && \
|
|
# mamba clean --all -f -y
|
|
|
|
# Create Python kernel and link it to jupyter
|
|
RUN "${CONDA_DIR}/envs/${env_name}/bin/python" -m ipykernel install --user --name="${env_name}" && \
|
|
fix-permissions "${CONDA_DIR}" && \
|
|
fix-permissions "/home/${NB_USER}"
|
|
|
|
# Any additional `pip` installs can be added by using the following line
|
|
# Using `mamba` is highly recommended though
|
|
RUN "${CONDA_DIR}/envs/${env_name}/bin/pip" install --no-cache-dir \
|
|
'flake8'
|
|
|
|
# Creating a startup hook, which will activate our custom environment by default in Jupyter Notebook
|
|
# More info about startup hooks: https://jupyter-docker-stacks.readthedocs.io/en/latest/using/common.html#startup-hooks
|
|
# You can comment this section to keep the default environment in Jupyter Notebook
|
|
USER root
|
|
RUN activate_custom_env_script=/usr/local/bin/before-notebook.d/activate_custom_env.sh && \
|
|
echo "#!/bin/bash" > ${activate_custom_env_script} && \
|
|
echo "eval \"$(conda shell.bash activate "${env_name}")\"" >> ${activate_custom_env_script} && \
|
|
chmod +x ${activate_custom_env_script}
|
|
|
|
USER ${NB_UID}
|
|
|
|
# Making this environment default in Terminal
|
|
# You can comment this line to keep the default environment in a Terminal
|
|
RUN echo "conda activate ${env_name}" >> "${HOME}/.bashrc"
|