1
1
ARG python_version="3.11"
2
- FROM quay.io/jupyter/base -notebook:python-${python_version}
2
+ FROM quay.io/jupyter/minimal -notebook:python-${python_version}
3
3
4
4
ARG python_version
5
- ARG arcgis_version="2.3.1 "
5
+ ARG arcgis_version="2.4.0 "
6
6
ARG sampleslink="https://github.com/Esri/arcgis-python-api/releases/download/v${arcgis_version}/samples.zip"
7
7
ARG githubfolder="arcgis-python-api"
8
- ENV DOCKER_STACKS_JUPYTER_CMD= "notebook"
8
+ ARG env_name=arcgis
9
9
10
10
LABEL org.opencontainers.image.authors="jroebuck@esri.com"
11
- LABEL org.opencontainers.image.description="Jupyter Notebook with the latest version of the ArcGIS API for Python and its Linux dependencies preinstalled "
11
+ LABEL org.opencontainers.image.description="Jupyter environment preconfigured for ArcGIS API for Python"
12
12
LABEL org.opencontainers.image.licenses=Apache
13
13
LABEL org.opencontainers.image.source=https://github.com/Esri/arcgis-python-api
14
14
15
- USER root
16
-
17
- RUN apt-get update --yes && \
18
- apt-get install --yes --no-install-recommends unzip && \
19
- apt-get clean && rm -rf /var/lib/apt/lists/*
20
-
21
15
USER ${NB_UID}
22
16
23
17
# Install Python API from Conda
24
- RUN conda install - c esri arcgis=${arcgis_version} -y \
18
+ RUN conda create -n ${env_name} - c esri -c defaults arcgis=${arcgis_version} python=${python_version} -y --quiet --override-channels \
25
19
&& conda clean --all -f -y \
26
20
&& find /opt/conda -name __pycache__ -type d -exec rm -rf {} +
27
21
22
+ # Install arcgis-mapping if arcgis_version >= 2.4.0
23
+ RUN (dpkg --compare-versions $arcgis_version ge 2.4.0 \
24
+ && conda install -n ${env_name} -c esri -c defaults arcgis-mapping -y --quiet --override-channels \
25
+ && conda clean --all -f -y \
26
+ && find /opt/conda -name __pycache__ -type d -exec rm -rf {} +;) \
27
+ || echo "[INFO] Skipped installing arcgis-mapping for version $arcgis_version (>= 2.4.0 required for arcgis-mapping)"
28
+
28
29
# Fetch and extract samples from GitHub
29
30
RUN mkdir /home/${NB_USER}/$githubfolder && \
30
31
wget -O samples.zip $sampleslink \
@@ -36,7 +37,34 @@ RUN mkdir /home/${NB_USER}/$githubfolder && \
36
37
work/ \
37
38
talks/ \
38
39
environment.yml\
40
+ # remove .DS_Store and __MACOSX from home directory:
41
+ && find /home/${NB_USER} -name ".DS_Store" -delete \
42
+ && rm -rf /home/${NB_USER}/__MACOSX \
39
43
&& fix-permissions /home/${NB_USER}
40
44
41
- RUN rm /opt/conda/lib/python${python_version}/site-packages/notebook/static/base/images/logo.png
42
- COPY --chown=${NB_USER}:users jupyter_esri_logo.png /opt/conda/lib/python${python_version}/site-packages/notebook/static/base/images/logo.png
45
+ # See https://jupyter-docker-stacks.readthedocs.io/en/latest/using/recipes.html#add-a-custom-conda-environment-and-jupyter-kernel
46
+ # Create Python kernel and link it to jupyter
47
+ RUN "${CONDA_DIR}/envs/${env_name}/bin/python" -m ipykernel install --user --name="${env_name}" && \
48
+ fix-permissions "${CONDA_DIR}" && \
49
+ fix-permissions "/home/${NB_USER}"
50
+
51
+
52
+ # More information here: https://github.com/jupyter/docker-stacks/pull/2047
53
+ USER root
54
+
55
+ # Set DOCKER_STACKS_JUPYTER_CMD to "notebook" for versions less than 2.4.0
56
+ RUN \
57
+ (dpkg --compare-versions $arcgis_version lt 2.4.0 \
58
+ && echo 'DOCKER_STACKS_JUPYTER_CMD="notebook"' >> /etc/environment \
59
+ && echo "[INFO] Set DOCKER_STACKS_JUPYTER_CMD to notebook for arcgis < 2.4.0" ) \
60
+ || echo "[INFO] Using default DOCKER_STACKS_JUPYTER_CMD (lab) for arcgis >= 2.4.0"
61
+
62
+ RUN \
63
+ # This changes a startup hook, which will activate the custom environment for the process
64
+ echo conda activate "${env_name}" >> /usr/local/bin/before-notebook.d/10activate-conda-env.sh && \
65
+ # This makes the custom environment default in Jupyter Terminals for all users which might be created later
66
+ echo conda activate "${env_name}" >> /etc/skel/.bashrc && \
67
+ # This makes the custom environment default in Jupyter Terminals for already existing NB_USER
68
+ echo conda activate "${env_name}" >> "/home/${NB_USER}/.bashrc"
69
+
70
+ USER ${NB_UID}
0 commit comments