|
1 | 1 | # Use the jupyter/minimal-notebook as the base image |
2 | 2 | FROM quay.io/jupyter/minimal-notebook:latest |
3 | 3 |
|
4 | | -# Set a shortcut to the tutorial name |
| 4 | +# Set environment variables for the tutorial and repository |
5 | 5 | ENV BASENAME="python-tutorial" |
6 | | -ENV REPO="https://github.com/edoardob90/${BASENAME}" |
7 | | - |
8 | | -# Set the working directory to the home directory of the notebook user |
9 | | -WORKDIR ${HOME} |
10 | | - |
11 | | -# Clone the tutorial repository |
12 | | -RUN git clone \ |
13 | | - --branch main \ |
14 | | - --depth 1 \ |
15 | | - ${REPO} |
16 | | - |
17 | | -# Set the working directory to the repository directory |
18 | | -WORKDIR ${BASENAME} |
| 6 | +ENV REPO=${HOME}/${BASENAME} |
| 7 | +ENV IPYTHONDIR="${HOME}/.ipython" |
19 | 8 |
|
20 | | -# Switch to root user to install additional dependencies (if needed) |
| 9 | +# Switch to root user to install additional dependencies |
21 | 10 | USER root |
22 | | - |
23 | | -# Install additional dependencies |
24 | 11 | RUN apt-get update && \ |
25 | 12 | apt-get install -y --no-install-recommends \ |
26 | 13 | build-essential \ |
27 | 14 | gcc \ |
28 | 15 | g++ \ |
29 | | - libffi-dev \ |
30 | | - && \ |
| 16 | + libffi-dev && \ |
31 | 17 | apt-get clean && \ |
32 | 18 | rm -rf /var/lib/apt/lists/* |
33 | 19 |
|
34 | 20 | # Switch back to the default notebook user |
35 | 21 | USER ${NB_UID} |
36 | 22 |
|
37 | | -# Create the Conda environment defined in environment.yml |
38 | | -# COPY --chown=${NB_USER}:${NB_GID} docker/environment.yml docker/environment.yml |
39 | | -RUN mamba env update -n base -f docker/environment.yml && \ |
| 23 | +# Set up the Conda environment |
| 24 | +COPY docker/environment.yml /tmp/environment.yml |
| 25 | +RUN mamba env update -n base -f /tmp/environment.yml && \ |
40 | 26 | mamba clean --all -f -y && \ |
41 | 27 | fix-permissions "${CONDA_DIR}" && \ |
42 | 28 | fix-permissions "/home/${NB_USER}" |
43 | 29 |
|
44 | | -# Copy the IPython configuration file (binder/postBuild script) |
45 | | -RUN mkdir -p ${HOME}/.ipython/profile_default && \ |
46 | | - cp -a binder/ipython_config.py ${HOME}/.ipython/profile_default/ |
| 30 | +# Prepare IPython configuration (move earlier in the build) |
| 31 | +RUN mkdir -p ${HOME}/.ipython/profile_default |
| 32 | +COPY --chown=${NB_UID}:${NB_GID} binder/ipython_config.py ${HOME}/.ipython/profile_default/ |
47 | 33 |
|
48 | | -# Set the environment variable IPYTHONDIR |
49 | | -ENV IPYTHONDIR="${HOME}/.ipython" |
| 34 | +# Copy the repository late in the build process |
| 35 | +RUN mkdir -p ${REPO} |
| 36 | +COPY --chown=${NB_UID}:${NB_GID} . ${REPO}/ |
| 37 | + |
| 38 | +# Set the working directory to the repository |
| 39 | +WORKDIR ${REPO} |
50 | 40 |
|
51 | 41 | # Use the default ENTRYPOINT from the base image to start Jupyter Lab |
52 | 42 | ENTRYPOINT ["tini", "-g", "--", "start.sh"] |
0 commit comments