Skip to content

Commit

Permalink
test onbuild for environment.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
eeholmes authored Oct 23, 2024
1 parent 48b8fc4 commit cdbbde3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions appendix
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,38 @@ RUN rm -rf ${REPO_DIR}/book ${REPO_DIR}/docs
# Convert NB_USER to ENV (from ARG) so that it passes to the child dockerfile
ENV NB_USER=${NB_USER}

## ONBUILD section. These are run in child Dockerfiles. First thing that is run

ONBUILD USER ${NB_USER}

# ${REPO_DIR} is owned by ${NB_USER}
ONBUILD COPY --chown=${NB_USER}:${NB_USER} . ${REPO_DIR}/childimage

# Copy Desktop files into ${REPO_DIR}/Desktop if they exist. start will copy to Application dir and Desktop
ONBUILD RUN if [ -d ${REPO_DIR}/childimage/Desktop ]; then \
mkdir -p ${REPO_DIR}/Desktop && \
cp -r ${REPO_DIR}/childimage/Desktop/* ${REPO_DIR}/Desktop/; \
fi

# Add the environment
ONBUILD RUN echo "Checking for 'conda-lock.yml' or 'environment.yml'..." && \
cd "${REPO_DIR}/childimage/" && \
[ -d binder ] && cd binder && \
[ -d .binder ] && cd .binder && \
if test -f "conda-lock.yml"; then
echo "Using conda-lock.yml" && \
conda-lock install --name ${CONDA_ENV};
elif test -f "environment.yml"; then
echo "Using environment.yml" && \
mamba env create --name ${CONDA_ENV} -f environment.yml;
fi && \
mamba clean -yaf && \
find ${CONDA_DIR} -follow -type f -name '*.a' -delete && \
find ${CONDA_DIR} -follow -type f -name '*.js.map' -delete && \
if ls ${NB_PYTHON_PREFIX}/lib/python*/site-packages/bokeh/server/static > /dev/null 2>&1; then \
find ${NB_PYTHON_PREFIX}/lib/python*/site-packages/bokeh/server/static -follow -type f -name '*.js' ! -name '*.min.js' -delete; \
fi

# Revert to default user and home as pwd
USER ${NB_USER}
WORKDIR ${HOME}

0 comments on commit cdbbde3

Please sign in to comment.