Skip to content

Commit 6cf91e4

Browse files
Revamp our documentation and refactor a bit (#1433)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5d3a946 commit 6cf91e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1175
-926
lines changed

.readthedocs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version: 2
66

77
sphinx:
88
configuration: docs/source/conf.py
9+
builder: dirhtml
910

1011
build:
1112
os: ubuntu-22.04

docs/requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
myst-parser>=0.18
2-
pydata-sphinx-theme>=0.11
1+
myst-parser<4
2+
pydata-sphinx-theme
33
sphinx-autobuild
44
sphinx-copybutton
5+
sphinx-design
56
sphinxcontrib-autoprogram>=0.1.7
67
sphinxext-opengraph
78
sphinxext-rediraffe
9.54 KB
Loading

docs/source/_static/images/logo.png

-3.3 KB
Loading

docs/source/_static/images/whentouse.svg

Lines changed: 4 additions & 0 deletions
Loading

docs/source/architecture.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ with explicit **versions** is all that is needed.
2020
In repo2docker, a Buildpack does the following things:
2121

2222
1. **Detect** if it can handle a given repository
23-
2. **Build** a base language environment in the docker image
24-
3. **Copy** the contents of the repository into the docker image
25-
4. **Assemble** a specific environment in the docker image based on repository contents
26-
5. **Push** the built docker image to a specific docker registry (optional)
27-
6. **Run** the build docker image as a docker container (optional)
23+
2. **Build** a base language environment in the Docker image
24+
3. **Copy** the contents of the repository into the Docker image
25+
4. **Assemble** a specific environment in the Docker image based on repository contents
26+
5. **Push** the built Docker image to a specific Docker registry (optional)
27+
6. **Run** the build Docker image as a Docker container (optional)
2828

2929
### Detect
3030

@@ -56,15 +56,15 @@ repositories built with the same buildpack.
5656
For example, in `CondaBuildPack`, the base environment consists of installing [miniconda](https://conda.io/miniconda.html)
5757
and basic notebook packages (from `repo2docker/buildpacks/conda/environment.yml`). This is going
5858
to be the same for most repositories built with `CondaBuildPack`, so we want to use
59-
[docker layer caching](https://thenewstack.io/understanding-the-docker-cache-for-faster-builds/) as
59+
[Docker layer caching](https://thenewstack.io/understanding-the-docker-cache-for-faster-builds/) as
6060
much as possible for performance reasons. Next time a repository is built with `CondaBuildPack`,
61-
we can skip straight to the **copy** step (since the base environment docker image _layers_ have
61+
we can skip straight to the **copy** step (since the base environment Docker image _layers_ have
6262
already been built and cached).
6363

6464
The `get_build_scripts` and `get_build_script_files` methods are primarily used for this.
6565
`get_build_scripts` can return arbitrary bash script lines that can be run as different users,
6666
and `get_build_script_files` is used to copy specific scripts (such as a conda installer) into
67-
the image to be run as pat of `get_build_scripts`. Code in either has following constraints:
67+
the image to be run as part of `get_build_scripts`. Code in either has following constraints:
6868

6969
1. You can _not_ use the contents of repository in them, since this happens before the repository
7070
is copied into the image. For example, `pip install -r requirements.txt` will not work,
@@ -91,22 +91,20 @@ This usually means installing required libraries specified in a format native to
9191

9292
Most of this work is done in `get_assemble_scripts` method. It can return arbitrary bash script
9393
lines that can be run as different users, and has access to the repository contents (unlike
94-
`get_build_scripts`). The docker image layers produced by this usually can not be cached,
94+
`get_build_scripts`). The Docker image layers produced by this usually can not be cached,
9595
so less restrictions apply to this than to `get_build_scripts`.
9696

97-
At the end of the assemble step, the docker image is ready to be used in various ways!
97+
At the end of the assemble step, the Docker image is ready to be used in various ways!
9898

9999
### Push
100100

101-
Optionally, repo2docker can **push** a built image to a [docker registry](https://docs.docker.com/registry/),
101+
Optionally, repo2docker can **push** a built image to a [Docker registry](https://docs.docker.com/registry/),
102102
if you specify the `--push` flag.
103103

104104
### Run
105105

106-
Optionally, repo2docker can **run** the built image and allow the user to access the Jupyter Notebook
107-
running inside by default. This is also done as a convenience only (since you can do the same with `docker run`
108-
after using repo2docker only to build), and implemented in `Repo2Docker.run`. It is activated by default
109-
unless the `--no-run` commandline flag is passed.
106+
Optionally, repo2docker can **run** the built image and allow the user to access the Jupyter Notebook running inside by default.
107+
This is also done as a convenience only (since you can do the same with `docker run` after using repo2docker only to build), and implemented in `Repo2Docker.run`. It is activated by default unless the `--no-run` commandline flag is passed.
110108

111109
## ContentProviders
112110

docs/source/changelog.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
- pre-commit update to fix ci [#1238](https://github.com/jupyterhub/repo2docker/pull/1238) ([@minrk](https://github.com/minrk))
135135
- Upgrade to mamba 1.1 and enable rich SAT error messages [#1232](https://github.com/jupyterhub/repo2docker/pull/1232) ([@SylvainCorlay](https://github.com/SylvainCorlay))
136136
- Upgrade to mamba 1.0 [#1213](https://github.com/jupyterhub/repo2docker/pull/1213) ([@SylvainCorlay](https://github.com/SylvainCorlay))
137-
- docker image: update alpine to 3.16 [#1212](https://github.com/jupyterhub/repo2docker/pull/1212) ([@consideRatio](https://github.com/consideRatio))
137+
- Docker image: update alpine to 3.16 [#1212](https://github.com/jupyterhub/repo2docker/pull/1212) ([@consideRatio](https://github.com/consideRatio))
138138
- reconcile CLI/config priority [#1211](https://github.com/jupyterhub/repo2docker/pull/1211) ([@minrk](https://github.com/minrk))
139139
- pipfile: pass --clear flag, and do it separetely to not be ignored [#1208](https://github.com/jupyterhub/repo2docker/pull/1208) ([@consideRatio](https://github.com/consideRatio))
140140
- run submodule test over https [#1204](https://github.com/jupyterhub/repo2docker/pull/1204) ([@minrk](https://github.com/minrk))
@@ -299,12 +299,12 @@ The repo2docker container image has moved to [quay.io/jupyterhub/repo2docker](ht
299299

300300
- Workaround docker-py dependency's failure to import six {pr}`1066:` by {user}`consideratio`
301301
- fix: add chardet, a not explicitly declared dependency {pr}`1064` by {user}`johnhoman`
302-
- Add build-base to build stage of docker image {pr}`1051` by {user}`yuvipanda`
302+
- Add build-base to build stage of Docker image {pr}`1051` by {user}`yuvipanda`
303303
- Fix regression in hydroshare introduced after moving to requests {pr}`1034` by {user}`MridulS`
304304

305305
### Other merged PRs
306306

307-
- Update README quay.io URL, Add docker latest tag {pr}`1075` by {user}`manics`
307+
- Update README quay.io URL, add Docker latest tag {pr}`1075` by {user}`manics`
308308
- GitHub workflow build and push to Docker hub {pr}`1071` by {user}`manics`
309309
- Rename master branch to main {pr}`1068` by {user}`manics`
310310
- Remove Pipfile & Pipfile.lock {pr}`1054` by {user}`yuvipanda`
@@ -343,7 +343,7 @@ The repo2docker container image has moved to [quay.io/jupyterhub/repo2docker](ht
343343
### Other merged PRs
344344

345345
- Cleanup install_requires including duplicates {pr}`1020` by {user}`manics`
346-
- bump docker action version {pr}`1018` by {user}`minrk`
346+
- bump Docker action version {pr}`1018` by {user}`minrk`
347347
- bump python in circleci test {pr}`1013` by {user}`minrk`
348348
- Investigating the missing logs {pr}`1008` by {user}`betatim`
349349
- Experiment with different install mechanism to get code coverage stats again {pr}`982` by {user}`betatim`
@@ -376,7 +376,7 @@ The repo2docker container image has moved to [quay.io/jupyterhub/repo2docker](ht
376376
- chmod start script from repo2docker-entrypoint {pr}`886` by {user}`danlester`
377377
- pypi jupyter-offlinenotebook==0.1.0 {pr}`880` by {user}`manics`
378378
- Add support for Julia 1.4.1 {pr}`878` by {user}`davidanthoff`
379-
- Change --env option to work like docker's {pr}`874` by {user}`hwine`
379+
- Change --env option to work like Docker's {pr}`874` by {user}`hwine`
380380
- Add support for Julia 1.4.0 {pr}`870` by {user}`davidanthoff`
381381
- Update server proxy and rsession proxy {pr}`869` by {user}`betatim`
382382
- Use miniforge instead of miniconda to get conda {pr}`859` by {user}`yuvipanda`
@@ -549,7 +549,7 @@ Release date: 2019-02-21
549549

550550
### New features
551551

552-
- Add additional metadata to docker images about how they were built {pr}`500` by
552+
- Add additional metadata to Docker images about how they were built {pr}`500` by
553553
{user}`jrbourbeau`.
554554
- Allow users to install global NPM packages: {pr}`573` by {user}`GladysNalvarte`.
555555
- Add documentation on switching the user interface presented by a
@@ -579,7 +579,7 @@ Release date: 2019-02-21
579579
- Fix quoting issue in `GIT_CREDENTIAL_ENV` environment variable by
580580
{user}`minrk` in {pr}`572`.
581581
- Change to using the first 8 characters of each Git commit, not the last 8,
582-
to tag each built docker image of repo2docker itself. {user}`minrk` in {pr}`562`.
582+
to tag each built Docker image of repo2docker itself. {user}`minrk` in {pr}`562`.
583583
- Allow users to select the Julia when using a `requirements.txt` by
584584
{user}`yuvipanda` in {pr}`557`.
585585
- Set `JULIA_DEPOT_PATH` to install packages outside the home directory by

docs/source/cli.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Command-line usage and API
2+
3+
`repo2docker` is called with this command:
4+
5+
```
6+
jupyter-repo2docker <source-repository>
7+
```
8+
9+
where `<source-repository>` is a repository in one of [the supported repository providers](#repository-providers).
10+
11+
For example, the following command will build an image of Peter Norvig's
12+
[Pytudes] repository:
13+
14+
```
15+
jupyter-repo2docker https://github.com/norvig/pytudes
16+
```
17+
18+
Building the image may take a few minutes.
19+
20+
[Pytudes] uses a [`requirements.txt` file](https://github.com/norvig/pytudes/blob/HEAD/requirements.txt) to specify its Python environment. Because of this, `repo2docker` will use `pip` to install dependencies listed in this `requirements.txt` file, and these will be present in the generated Docker image. To learn more about configuration files in `repo2docker` visit [](#config-files).
21+
22+
When the image is built, a message will be output to your terminal:
23+
24+
```
25+
Copy/paste this URL into your browser when you connect for the first time,
26+
to login with a token:
27+
http://0.0.0.0:36511/?token=f94f8fabb92e22f5bfab116c382b4707fc2cade56ad1ace0
28+
```
29+
30+
Pasting the URL into your browser will open Jupyter Notebook with the
31+
dependencies and contents of the source repository in the built image.
32+
33+
## Debug repo2docker with `--debug` and `--no-build`
34+
35+
To debug the container image being built, pass the `--debug` parameter:
36+
37+
> ```bash
38+
> jupyter-repo2docker --debug https://github.com/norvig/pytudes
39+
> ```
40+
41+
This will print the generated `Dockerfile`, build it, and run it.
42+
43+
To see the generated `Dockerfile` without actually building it, pass `--no-build` to the commandline.
44+
This `Dockerfile` output is for **debugging purposes** of `repo2docker` only - it can not be used by Docker directly.
45+
46+
> ```bash
47+
> jupyter-repo2docker --no-build --debug https://github.com/norvig/pytudes
48+
> ```
49+
50+
## Build from a branch, commit or tag
51+
52+
To build a particular branch and commit, use the argument `--ref` and
53+
specify the `branch-name` or `commit-hash`. For example:
54+
55+
```
56+
jupyter-repo2docker --ref 9ced85dd9a84859d0767369e58f33912a214a3cf https://github.com/norvig/pytudes
57+
```
58+
59+
:::{tip}
60+
For reproducible builds, we recommend specifying a commit-hash to
61+
deterministically build a fixed version of a repository. Not specifying a
62+
commit-hash will result in the latest commit of the repository being built.
63+
:::
64+
65+
## Set environment variables during builds
66+
67+
When running repo2docker locally you can use the `-e` or `--env` command-line
68+
flag for each variable that you want to define.
69+
70+
For example:
71+
72+
```bash
73+
jupyter-repo2docker -e VAR1=val1 -e VAR2=val2 ...
74+
```
75+
76+
You can also configure environment variables for all users of a repository using the
77+
[](#config-start) configuration file.
78+
79+
(command-line-api)=
80+
81+
## Command-line API
82+
83+
```{autoprogram} repo2docker.__main__:argparser
84+
:prog: jupyter-repo2docker
85+
```
86+
87+
[pytudes]: https://github.com/norvig/pytudes

docs/source/conf.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"sphinxcontrib.autoprogram",
2323
"sphinxext.opengraph",
2424
"sphinxext.rediraffe",
25+
"sphinx_design",
2526
]
2627
root_doc = "index"
2728
source_suffix = [".md", ".rst"]
@@ -40,6 +41,7 @@
4041
#
4142
myst_enable_extensions = [
4243
"colon_fence",
44+
"substitution",
4345
]
4446

4547

@@ -58,8 +60,11 @@
5860

5961
from repo2docker.buildpacks.conda import CondaBuildPack
6062

61-
default_python = CondaBuildPack.major_pythons["3"]
62-
63+
default_python = f"`Python {CondaBuildPack.major_pythons['3']}`"
64+
myst_substitutions = {
65+
"default_python": default_python,
66+
"default_python_version": default_python,
67+
}
6368
rst_prolog = f"""
6469
.. |default_python| replace:: **Python {default_python}**
6570
.. |default_python_version| replace:: {default_python}
@@ -73,12 +78,20 @@
7378
html_favicon = "_static/images/favicon.ico"
7479
html_static_path = ["_static"]
7580
html_css_files = ["custom.css"]
81+
html_sidebars = {
82+
"changelog": [],
83+
"start": [],
84+
}
7685

7786
# pydata_sphinx_theme reference: https://pydata-sphinx-theme.readthedocs.io/en/latest/
7887
html_theme = "pydata_sphinx_theme"
7988
html_theme_options = {
8089
"use_edit_page_button": True,
8190
"github_url": "https://github.com/jupyterhub/repo2docker",
91+
"logo": {
92+
"image_dark": "_static/images/logo-dark.png",
93+
"image_light": "_static/images/logo.png",
94+
},
8295
}
8396
html_context = {
8497
"github_user": "jupyterhub",

0 commit comments

Comments
 (0)