-
Notifications
You must be signed in to change notification settings - Fork 1
Trim down the docker image size #55
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .git | ||
| .github | ||
| test | ||
| Makefile | ||
| README.md | ||
| LICENSE | ||
| .dockerignore | ||
| **/__pycache__ | ||
| **/*.pyc | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,29 @@ | |
| # Extended from github.com/jupyter/docker-stacks | ||
| # See also http://blog.dscpl.com.au/2016/01/roundup-of-docker-issues-when-hosting.html | ||
|
|
||
| # Build the nss_wrapper separately | ||
| FROM python:3.13-slim-bullseye AS nss-builder | ||
|
|
||
| ENV DEBIAN_FRONTEND noninteractive | ||
| ENV NSS_WRAPPER_VERSION 1.1.2 | ||
|
|
||
| RUN apt-get update && apt-get install -yq --no-install-recommends \ | ||
| build-essential \ | ||
| ca-certificates \ | ||
| cmake \ | ||
| wget \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN wget -q https://ftp.samba.org/pub/cwrap/nss_wrapper-${NSS_WRAPPER_VERSION}.tar.gz && \ | ||
| mkdir nss_wrapper && \ | ||
| tar -xC nss_wrapper --strip-components=1 -f nss_wrapper-${NSS_WRAPPER_VERSION}.tar.gz && \ | ||
| mkdir nss_wrapper/obj && \ | ||
| (cd nss_wrapper/obj && \ | ||
| cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DLIB_SUFFIX=64 .. && \ | ||
| make && \ | ||
| make install) | ||
|
|
||
|
|
||
| FROM python:3.13-slim-bullseye | ||
|
|
||
| LABEL maintainer="Nick Greenfield <nick@onecodex.com>" | ||
|
|
@@ -13,28 +36,20 @@ USER root | |
| # features (e.g., download as all possible file formats) | ||
| ENV DEBIAN_FRONTEND noninteractive | ||
| RUN apt-get update && apt-get install -yq --no-install-recommends \ | ||
| apt-transport-https \ | ||
| build-essential \ | ||
| bzip2 \ | ||
| ca-certificates \ | ||
| cmake \ | ||
| curl \ | ||
| fontconfig \ | ||
| fonts-dejavu \ | ||
| gcc \ | ||
| gfortran \ | ||
| git \ | ||
| gnupg \ | ||
| locales \ | ||
| python-dev \ | ||
| patch \ | ||
| procps \ | ||
| libffi7 \ | ||
| libpango-1.0-0 \ | ||
| libpangoft2-1.0-0 \ | ||
| libcairo2 \ | ||
| sudo \ | ||
| unzip \ | ||
| vim \ | ||
| wget \ | ||
| fonts-texgyre \ | ||
| xz-utils \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
|
|
@@ -47,6 +62,8 @@ ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/ | |
| RUN chmod +x /usr/local/bin/tini \ | ||
| && echo "12d20136605531b09a2c2dac02ccee85e1b874eb322ef6baf7561cd93f93c855 /usr/local/bin/tini" | sha256sum -c - | ||
|
|
||
| COPY --from=nss-builder /usr/local/lib64/libnss_wrapper.so /usr/local/lib64/ | ||
|
|
||
| # Configure environment | ||
| ENV SHELL /bin/bash | ||
| ENV NB_USER jovyan | ||
|
|
@@ -69,8 +86,12 @@ RUN mkdir /home/$NB_USER/work && \ | |
|
|
||
|
|
||
| ADD requirements.txt /root/ | ||
| RUN pip install -U pip && \ | ||
| pip install -q -r /root/requirements.txt | ||
| # Install Python packages, allow full access for the NB_USER | ||
| # chown has to be run in the same command otherwise the files are copied in the next docker layer | ||
| RUN pip install --no-cache-dir -U pip && \ | ||
| pip install --no-cache-dir -q -r /root/requirements.txt && \ | ||
| rm -rf /usr/local/lib/python3.13/site-packages/biom/tests && \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there other tests we could remove, e.g. scikit-bio's?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but they're not that big - I figured simplicity wins over chipping away more tiny pieces 🤷 |
||
| chown -R $NB_USER:root /usr/local/lib/python3.13 | ||
|
|
||
| # Activate ipywidgets extension in the environment that runs the notebook server | ||
| RUN jupyter nbextension enable --py widgetsnbextension | ||
|
|
@@ -79,18 +100,6 @@ RUN jupyter contrib nbextension install --user && \ | |
|
|
||
| WORKDIR /home/$NB_USER/work | ||
|
|
||
| # Install nss_wrapper | ||
| RUN wget https://ftp.samba.org/pub/cwrap/nss_wrapper-1.1.2.tar.gz && \ | ||
| mkdir nss_wrapper && \ | ||
| tar -xC nss_wrapper --strip-components=1 -f nss_wrapper-1.1.2.tar.gz && \ | ||
| rm nss_wrapper-1.1.2.tar.gz && \ | ||
| mkdir nss_wrapper/obj && \ | ||
| (cd nss_wrapper/obj && \ | ||
| cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DLIB_SUFFIX=64 .. && \ | ||
| make && \ | ||
| make install) && \ | ||
| rm -rf nss_wrapper | ||
|
|
||
| # Copy `onecodex` installed fonts to local directory | ||
| RUN cp /usr/local/lib/python3.13/site-packages/onecodex/assets/fonts/*.otf /usr/local/share/fonts && fc-cache | ||
|
|
||
|
|
@@ -120,7 +129,8 @@ RUN chmod +x /usr/local/bin/token_notebook.py | |
| # Add patch to jupyter notebook for export to One Codex document portal | ||
| COPY notebook/notebook.patch /usr/local/lib/python3.13/site-packages/notebook | ||
| RUN cd /usr/local/lib/python3.13/site-packages/notebook \ | ||
| && patch -p0 < notebook.patch | ||
| && patch -p0 < notebook.patch \ | ||
| && chown -R $NB_USER:root /usr/local/lib/python3.13/site-packages/notebook | ||
|
|
||
| # Finally fix permissions on everything | ||
| # See https://github.com/jupyter/docker-stacks/issues/188 | ||
|
|
@@ -129,8 +139,5 @@ RUN chown -R $NB_USER:root /home/$NB_USER && find /home/$NB_USER -type d -exec c | |
|
|
||
| ENV PYTHONPATH "/home/jovyan/.local/lib/python3.13" | ||
|
|
||
| # Provide full access to the Python directory to allow for pip installs | ||
| RUN chown -R $NB_USER:root /usr/local/lib/python3.13 | ||
|
|
||
| # Switch to unprivileged user, jovyan | ||
| USER $NB_USER | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| # jupyter_contrib_nbextensions imports pkg_resources, which setuptools removed | ||
| # in v81; the python:3.13-slim base image no longer ships setuptools at all. | ||
| setuptools<81 | ||
| awscli | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why we had this as a dependency
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I vaguely remember at one point the main container uploading the ipynb file. It's now done in a sidecar that has a different image with awscli. |
||
| biopython | ||
| ipywidgets | ||
| jupyter_contrib_nbextensions | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm with @clausmith @lynchde on the wheel-only change?