Files
docker-stacks/docs/using/recipe_code/custom_environment.dockerfile
Ayaz Salikhov f8cd90ade1 Add an ability to specify registry when using docker images (#2008)
* Add an ability to specify registry when using docker images

* Fix typo

* [TMP] Speedup workflow

* Revert "[TMP] Speedup workflow"

This reverts commit 3af0055ccf.
2023-10-19 21:15:10 +02:00

45 lines
1.8 KiB
Docker

FROM docker.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 Terminal
RUN echo "conda activate ${env_name}" >> "${HOME}/.bashrc"