Skip to content

Commit eabb37e

Browse files
authored
Merge pull request #21 from fangohr/improvements-for-binder
Improvements for binder: minimal requirements to avoid using Dockerfile for binder, and to speed up build time for Binder. [Could be improved in that we now don't test the notebooks in the Binder environment.]
2 parents d27b3a5 + 6264aba commit eabb37e

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,19 @@ docker-build-nocache:
4141

4242
# Here we only bind the required directories and files into the docker container
4343
# at runtime to avoid potential conflicts with local files
44+
4445
define DOCKER_RUN
45-
docker run -u $(id -u ${USER}):$(id -g ${USER}) \
46+
docker run --workdir=/io \
4647
-v $(CURDIR)/book:/io/book \
4748
-v $(CURDIR)/Makefile:/io/Makefile \
4849
-v $(CURDIR)/poetry.lock:/io/poetry.lock \
4950
-v $(CURDIR)/pyproject.toml:/io/pyproject.toml \
5051
python4compscience
5152
endef
5253

54+
docker-bash:
55+
docker run --workdir=/io -t -i -v $(CURDIR):/io python4compscience bash
56+
5357
docker-html:
5458
$(DOCKER_RUN) make html
5559

binder/info.org

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
* Overall strategy: separate Docker containers for development and mybinder
2+
3+
This repository uses a Dockerfile in the root directory for development
4+
purposes. This includes translation of the source files (in book/*ipynb) to html
5+
and pdf (using jupyterbook), which in turns needs a full latex installation.
6+
7+
That makes the container quite big.
8+
9+
For myBinder, we do not need latex, so in this directory, we attempt to have a
10+
leaner definition of dependencies.
11+
12+
Binder should look in this directory (as it is called 'binder') and ignore the
13+
global Dockerfile.
14+
15+
* Re-use dependencies from development environment in myBinder
16+
17+
I don't know if myBinder could read dependencies from a pyproject.toml file (and
18+
couldn't find any documentation on this yet), nor if we can extract a
19+
requirements.txt file from the pyproject.toml file automatically.
20+
21+
As a first step towards making the binder image leaner, I will stick to a definition via a Dockerfile, and leave out latex to make it smaller.
22+
23+
This didn't go so well.
24+
25+
Next attempt: specifying the packages we need in requirements.txt directly. It's
26+
not ideal, as we don't run tests on the particular versions, and we duplicate
27+
some effort from ../pyproject.toml here in reqiuirements.txt. On the positive
28+
side, Binder start-up time could be much smaller (and Binder work at all).
29+
30+

binder/requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
numpy
2+
scipy
3+
sympy
4+
matplotlib
5+
pandas
6+
ipython
7+
pytest

poetry.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[virtualenvs]
2+
create = false

0 commit comments

Comments
 (0)