@@ -33,14 +33,38 @@ RUN rm -rf ${REPO_DIR}/book ${REPO_DIR}/docs
33
33
# Convert NB_USER to ENV (from ARG) so that it passes to the child dockerfile
34
34
ENV NB_USER=${NB_USER}
35
35
36
+ ## ONBUILD section. These are run in child Dockerfiles. First thing that is run
37
+
38
+ ONBUILD USER ${NB_USER}
39
+
36
40
# ${REPO_DIR} is owned by ${NB_USER}
37
41
ONBUILD COPY --chown=${NB_USER}:${NB_USER} . ${REPO_DIR}/childimage
42
+
38
43
# Copy Desktop files into ${REPO_DIR}/Desktop if they exist. start will copy to Application dir and Desktop
39
44
ONBUILD RUN if [ -d ${REPO_DIR}/childimage/Desktop ]; then \
40
45
mkdir -p ${REPO_DIR}/Desktop && \
41
46
cp -r ${REPO_DIR}/childimage/Desktop/* ${REPO_DIR}/Desktop/; \
42
47
fi
43
48
49
+ # Add the environment
50
+ ONBUILD RUN echo "Checking for 'conda-lock.yml' or 'environment.yml'..." && \
51
+ cd "${REPO_DIR}/childimage/" && \
52
+ [ -d binder ] && cd binder && \
53
+ [ -d .binder ] && cd .binder && \
54
+ if test -f "conda-lock.yml"; then
55
+ echo "Using conda-lock.yml" && \
56
+ conda-lock install --name ${CONDA_ENV};
57
+ elif test -f "environment.yml"; then
58
+ echo "Using environment.yml" && \
59
+ mamba env create --name ${CONDA_ENV} -f environment.yml;
60
+ fi && \
61
+ mamba clean -yaf && \
62
+ find ${CONDA_DIR} -follow -type f -name '*.a' -delete && \
63
+ find ${CONDA_DIR} -follow -type f -name '*.js.map' -delete && \
64
+ if ls ${NB_PYTHON_PREFIX}/lib/python*/site-packages/bokeh/server/static > /dev/null 2>&1; then \
65
+ find ${NB_PYTHON_PREFIX}/lib/python*/site-packages/bokeh/server/static -follow -type f -name '*.js' ! -name '*.min.js' -delete; \
66
+ fi
67
+
44
68
# Revert to default user and home as pwd
45
69
USER ${NB_USER}
46
70
WORKDIR ${HOME}
0 commit comments