Skip to content

Commit cdbbde3

Browse files
authored
test onbuild for environment.yml
1 parent 48b8fc4 commit cdbbde3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

appendix

+24
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,38 @@ RUN rm -rf ${REPO_DIR}/book ${REPO_DIR}/docs
3333
# Convert NB_USER to ENV (from ARG) so that it passes to the child dockerfile
3434
ENV NB_USER=${NB_USER}
3535

36+
## ONBUILD section. These are run in child Dockerfiles. First thing that is run
37+
38+
ONBUILD USER ${NB_USER}
39+
3640
# ${REPO_DIR} is owned by ${NB_USER}
3741
ONBUILD COPY --chown=${NB_USER}:${NB_USER} . ${REPO_DIR}/childimage
42+
3843
# Copy Desktop files into ${REPO_DIR}/Desktop if they exist. start will copy to Application dir and Desktop
3944
ONBUILD RUN if [ -d ${REPO_DIR}/childimage/Desktop ]; then \
4045
mkdir -p ${REPO_DIR}/Desktop && \
4146
cp -r ${REPO_DIR}/childimage/Desktop/* ${REPO_DIR}/Desktop/; \
4247
fi
4348

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+
4468
# Revert to default user and home as pwd
4569
USER ${NB_USER}
4670
WORKDIR ${HOME}

0 commit comments

Comments
 (0)