Skip to content

Commit

Permalink
Backport PR #589: Docker purge unneeded files
Browse files Browse the repository at this point in the history
* Clears the `~/.cache` directory at every build step as `pip` and `npm` are filling it with junk. ( ~100MB )
* Clears the `~/.npm` directory (just used for cache). ( ~36.7MB )
* Clears the `~/.config` directory after building the notebook (only has `bower` stuff and `bower` is removed).
* Clears the `~/.local` directory after building the notebook (only has `bower` stuff and `bower` is removed).
* Clears the `~/tmp` directory after building the notebook (is already empty).
  • Loading branch information
minrk committed Jan 21, 2016
1 parent ac6baa7 commit 1faa5ee
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@ RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
python3 get-pip.py && \
rm get-pip.py && \
pip2 --no-cache-dir install requests[security] && \
pip3 --no-cache-dir install requests[security]
pip3 --no-cache-dir install requests[security] && \
rm get-pip.py && \
rm -rf /root/.cache

# Install some dependencies.
RUN pip2 --no-cache-dir install ipykernel && \
pip3 --no-cache-dir install ipykernel && \
\
python2 -m ipykernel.kernelspec && \
python3 -m ipykernel.kernelspec
python3 -m ipykernel.kernelspec && \
rm -rf /root/.cache

# Move notebook contents into place.
ADD . /usr/src/jupyter-notebook
Expand All @@ -78,7 +81,13 @@ RUN BUILD_DEPS="nodejs-legacy npm" && \
\
pip3 install --no-cache-dir --pre -e /usr/src/jupyter-notebook && \
\
npm cache clean && \
apt-get clean && \
rm -rf /root/.npm && \
rm -rf /root/.cache && \
rm -rf /root/.config && \
rm -rf /root/.local && \
rm -rf /root/tmp && \
rm -rf /var/lib/apt/lists/* && \
apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $BUILD_DEPS
Expand All @@ -90,7 +99,8 @@ RUN pip2 install --no-cache-dir mock nose requests testpath && \
iptest2 && iptest3 && \
\
pip2 uninstall -y funcsigs mock nose pbr requests six testpath && \
pip3 uninstall -y nose requests testpath
pip3 uninstall -y nose requests testpath && \
rm -rf /root/.cache

# Add a notebook profile.
RUN mkdir -p -m 700 /root/.jupyter/ && \
Expand Down

0 comments on commit 1faa5ee

Please sign in to comment.