Skip to content

Commit d24889e

Browse files
authored
Merge pull request #7 from o19s/trim_packages
Trim packages to make expanded directory smaller to fit under Heroku limit..
2 parents 5d56fd1 + 4edeb78 commit d24889e

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,29 @@ ENV TARGET_DIR=${GITHUB_WORKSPACE:-/github/workspace}
1313
# Build the Jupyter lite web app, the pyodide kernel option is passed for offline availability
1414
# (see https://jupyterlite.readthedocs.io/en/latest/howto/configure/advanced/offline.html), the
1515
# Kernel version is taken from https://github.com/jupyterlite/pyodide-kernel/blob/main/packages/pyodide-kernel/package.json
16+
#
17+
# We need to trim the size of our package down, so we are explicitly deleting some default wheels
18+
# from the resulting output. Hacky!
1619
CMD jupyter lite build \
1720
--config /build/jupyter_lite_config.json \
1821
--lite-dir /build \
1922
--no-sourcemaps \
2023
--output-dir notebooks \
2124
--pyodide https://github.com/pyodide/pyodide/releases/download/0.23.2/pyodide-0.23.2.tar.bz2 \
25+
&& rm notebooks/static/pyodide/astropy-5.2* \
26+
&& rm notebooks/static/pyodide/biopython-1.81* \
27+
&& rm notebooks/static/pyodide/bokeh-3.1* \
28+
&& rm notebooks/static/pyodide/Fiona-1.8* \
29+
&& rm notebooks/static/pyodide/gdal-3.5* \
30+
&& rm notebooks/static/pyodide/gensim* \
31+
&& rm notebooks/static/pyodide/mne* \
32+
&& rm notebooks/static/pyodide/mypy-1.1* \
33+
&& rm notebooks/static/pyodide/opencv_python-4.7* \
34+
&& rm notebooks/static/pyodide/*-tests.tar \
35+
&& rm notebooks/static/pyodide/RobotRaconteur-0.15* \
36+
&& rm notebooks/static/pyodide/scipy* \
37+
&& rm notebooks/static/pyodide/sympy* \
38+
&& rm notebooks/static/pyodide/test-1.0.* \
39+
&& rm notebooks/static/pyodide/tomli* \
40+
&& rm notebooks/static/pyodide/yt-4.1* \
2241
&& tar -czf ${TARGET_DIR}/jupyter-lite-build.tgz notebooks

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,16 @@ Browse to http://localhost:8000 and you should see the Jupyterlite interface.
4444
If you are debugging these notebooks, they all use the Haystack Party data.
4545
1. Check out the dev version of Quepid.
4646
1. Run `bin/docker r bundle exec thor sample_data:haystack_party` to load into Quepid the data that the notebooks references.
47+
48+
## Shrinking the Docker Image Size
49+
50+
Heroku allows a Quepid "Slug" to be max 500 MB, and one of the key drivers of slug size is the inclusion of various Python libraries in Pyodide.
51+
52+
To shink it we:
53+
54+
1. Run the build.
55+
2. Untar it into a new folder `tar -xzf jupyter-lite-build.tgz -C notebooks2`
56+
3. Now look for files to remove, and modify the `Dockerfile` to remove the file when the Docker image is built!
57+
4. Re run the build.
58+
5. Unpack the new setup
59+
6. Test it: `ruby -run -ehttpd ./notebooks -p 8000` via http://localhost:8000/lab/index.html

jupyterlite/requirements.txt

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Contents below from https://github.com/jupyterlite/demo/blob/main/requirements.txt
2+
# Stripped out as many resources as possible to slim it down to fit in Heroku limits
3+
# when deployed as part of Quepid.
24

35
# Core modules (mandatory)
46
jupyterlite-core==0.1.0
@@ -8,18 +10,18 @@ jupyterlab~=3.5.1
810
jupyterlite-pyodide-kernel==0.0.8
911

1012
# JavaScript kernel (optional)
11-
jupyterlite-javascript-kernel==0.1.0b21
13+
# jupyterlite-javascript-kernel==0.1.0b21
1214

1315
# Language support (optional)
14-
jupyterlab-language-pack-fr-FR
15-
jupyterlab-language-pack-zh-CN
16+
# jupyterlab-language-pack-fr-FR
17+
# jupyterlab-language-pack-zh-CN
1618

1719
# SQLite kernel (optional)
18-
jupyterlite-xeus-sqlite==0.2.1
20+
#jupyterlite-xeus-sqlite==0.2.1
1921
# P5 kernel (optional)
20-
jupyterlite-p5-kernel==0.1.0
22+
#jupyterlite-p5-kernel==0.1.0
2123
# Lua kernel (optional)
22-
jupyterlite-xeus-lua==0.3.1
24+
# jupyterlite-xeus-lua==0.3.1
2325

2426
# JupyterLab: Fasta file renderer (optional)
2527
jupyterlab-fasta>=3,<4
@@ -41,7 +43,7 @@ ipympl>=0.8.2
4143
# Python: ipycanvas library for Jupyter notebooks (optional)
4244
ipycanvas>=0.9.1
4345
# Python: ipyleaflet library for Jupyter notebooks (optional)
44-
ipyleaflet
46+
# ipyleaflet
4547

4648
# Python: plotting libraries (optional)
4749
plotly>=5,<6
@@ -50,4 +52,4 @@ bqplot
5052

5153
# Contents below added from https://jupyterlite.readthedocs.io/en/latest/howto/configure/advanced/offline.html
5254

53-
jupyterlite-core[mathjax]==0.1.0
55+
#jupyterlite-core[mathjax]==0.1.0

0 commit comments

Comments
 (0)