Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add an onbuild install script step #600

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion base-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,28 @@ ONBUILD RUN echo "Checking for pip 'requirements.txt'..." \
${NB_PYTHON_PREFIX}/bin/pip install --no-cache -r requirements.txt \
; fi

ONBUILD USER root

ONBUILD RUN echo "Copy 'layer-cleanup'..." \
; [ -d binder ] && cd binder \
; [ -d .binder ] && cd .binder \
; pwd; ls \
; cp resources/layer-cleanup.sh /usr/local/bin/ \
; chmod +x /usr/local/bin/layer-cleanup.sh

ONBUILD RUN echo "Executing install scripts..." \
; [ -d binder ] && cd binder \
; [ -d .binder ] && cd .binder \
; for script in $(find "resources" -type f -name "install.sh"); do \
chmod +x "$script"; \
echo "Executing $script"; \
bash "$script"; \
layer-cleanup.sh; \
chown -R ${NB_USER}:${NB_USER} ${HOME}; \
done

ONBUILD USER ${NB_USER}

# If a postBuild file exists, run it!
# After it's done, we try to remove any possible cruft commands there
# leave behind under $HOME - particularly stuff that jupyterlab extensions
Expand All @@ -210,4 +232,4 @@ ONBUILD RUN echo "Checking for 'start'..." \
chmod +x start \
&& cp start /srv/start \
; fi
# ----------------------
# ----------------------
31 changes: 31 additions & 0 deletions base-notebook/resources/layer-cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Copyright 2024 CS GROUP - https://www.csgroup.eu
# All rights reserved
# This file is provided under MIT license. See LICENSE file.

apt-get autoclean --yes
apt-get autoremove --yes

rm -rf /var/lib/apt/lists/*
rm -rf /etc/apt/sources.list.d/*
rm -rf /usr/local/src/*

rm -rf /var/cache/apt/*
rm -rf /root/.cache/*
# including /root/.cache/pip
rm -rf /usr/local/share/.cache/*
# including /usr/local/share/.cache/yarn

if [ -x "$(command -v npm)" ]; then
npm cache clean --force
rm -rf /root/.npm/*
rm -rf /root/.node-gyp/*
rm -rf /usr/local/share/jupyter/lab/staging/node_modules/*
rm -rf /opt/*/node_modules/*
fi

rm -rf /tmp/* /var/tmp/*

echo "Layer cleaned"

exit 0
31 changes: 31 additions & 0 deletions ml-notebook/resources/layer-cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Copyright 2024 CS GROUP - https://www.csgroup.eu
# All rights reserved
# This file is provided under MIT license. See LICENSE file.

apt-get autoclean --yes
apt-get autoremove --yes

rm -rf /var/lib/apt/lists/*
rm -rf /etc/apt/sources.list.d/*
rm -rf /usr/local/src/*

rm -rf /var/cache/apt/*
rm -rf /root/.cache/*
# including /root/.cache/pip
rm -rf /usr/local/share/.cache/*
# including /usr/local/share/.cache/yarn

if [ -x "$(command -v npm)" ]; then
npm cache clean --force
rm -rf /root/.npm/*
rm -rf /root/.node-gyp/*
rm -rf /usr/local/share/jupyter/lab/staging/node_modules/*
rm -rf /opt/*/node_modules/*
fi

rm -rf /tmp/* /var/tmp/*

echo "Layer cleaned"

exit 0
31 changes: 31 additions & 0 deletions pangeo-notebook/resources/layer-cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Copyright 2024 CS GROUP - https://www.csgroup.eu
# All rights reserved
# This file is provided under MIT license. See LICENSE file.

apt-get autoclean --yes
apt-get autoremove --yes

rm -rf /var/lib/apt/lists/*
rm -rf /etc/apt/sources.list.d/*
rm -rf /usr/local/src/*

rm -rf /var/cache/apt/*
rm -rf /root/.cache/*
# including /root/.cache/pip
rm -rf /usr/local/share/.cache/*
# including /usr/local/share/.cache/yarn

if [ -x "$(command -v npm)" ]; then
npm cache clean --force
rm -rf /root/.npm/*
rm -rf /root/.node-gyp/*
rm -rf /usr/local/share/jupyter/lab/staging/node_modules/*
rm -rf /opt/*/node_modules/*
fi

rm -rf /tmp/* /var/tmp/*

echo "Layer cleaned"

exit 0
31 changes: 31 additions & 0 deletions pytorch-notebook/resources/layer-cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Copyright 2024 CS GROUP - https://www.csgroup.eu
# All rights reserved
# This file is provided under MIT license. See LICENSE file.

apt-get autoclean --yes
apt-get autoremove --yes

rm -rf /var/lib/apt/lists/*
rm -rf /etc/apt/sources.list.d/*
rm -rf /usr/local/src/*

rm -rf /var/cache/apt/*
rm -rf /root/.cache/*
# including /root/.cache/pip
rm -rf /usr/local/share/.cache/*
# including /usr/local/share/.cache/yarn

if [ -x "$(command -v npm)" ]; then
npm cache clean --force
rm -rf /root/.npm/*
rm -rf /root/.node-gyp/*
rm -rf /usr/local/share/jupyter/lab/staging/node_modules/*
rm -rf /opt/*/node_modules/*
fi

rm -rf /tmp/* /var/tmp/*

echo "Layer cleaned"

exit 0