Skip to content

Commit 7e687b2

Browse files
authored
Merge pull request #397 from alphaville/docs/docusaurus-v3-upgrade
Upgrade to Docusaurus v3
2 parents 03aa4b4 + a173460 commit 7e687b2

50 files changed

Lines changed: 2145 additions & 1213 deletions

Some content is hidden

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

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ open-clib/Cargo.lock
4343
/website/node_modules/
4444
/website/yarn.lock
4545
/website/build/
46+
/website/.docusaurus/
4647
!/website/pages/
4748
!/website/static/
4849
!/website/*.js
@@ -73,4 +74,4 @@ open-clib/Cargo.lock
7374
*private*
7475
.DS_Store
7576
/img/
76-
private/
77+
private/

docs/docker.md

Lines changed: 88 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,115 +2,147 @@
22
id: docker
33
title: Docker
44
sidebar_label: Docker
5-
description: Docker image of a Jupyter Python Notebook to run OpEn
5+
description: Docker image of a JupyterLab environment to run OpEn
66
---
77

88
<img src="/optimization-engine/img/docker.gif" alt="OpEn in Docker container" width="200"/>
99

1010
## What is Docker?
1111

12-
[Docker](https://www.docker.com/) is a tool that facilitates the execution and deployment of applications (often web applications) using containers. Containers package the applications along with the entirety of its context such as libraries and configuration files. You may think of containers as independent, isolated and self-sufficient processes. A container is then guaranteed to run on any other Linux-based machine regardless of the exact operating system, local configurations.
12+
[Docker](https://www.docker.com/) is a tool for packaging applications and their dependencies into containers. A container can run on different machines without requiring you to recreate the same environment manually.
1313

14-
Docker has nowadays become extremely popular. Developers package their software in bundles known as *Docker images* which can be stored in Docker Hub: an online repository. Then the users can obtain such images and run them locally.
15-
16-
Docker is open-source and free and can be easily installed on any Linux, Mac OSX or Windows machine.
17-
18-
19-
## What is a Jupyter Notebook?
20-
According to [jupyter.org](https://jupyter.org/), "JupyterLab is a web-based interactive development environment for Jupyter notebooks, code, and data."
14+
## What is JupyterLab?
2115

16+
According to [jupyter.org](https://jupyter.org/), JupyterLab is a web-based development environment for notebooks, code, and data.
2217

2318
## Requirements
2419

25-
You need to have Docker installed ([instructions](https://docs.docker.com/get-docker/)).
20+
You need to have Docker installed. See the [official installation instructions](https://docs.docker.com/get-docker/).
2621

27-
## Pull and Use Docker Image
22+
## Pull and Run the Docker Image
2823

29-
Hmm.. that [OpEn](https://alphaville.github.io/optimization-engine/) framework looks really cool. I wonder whether it is possible to try it out very quickly without installing much...
24+
You can download the current Docker image using:
3025

31-
TaDaaa...
26+
```console
27+
docker pull alphaville/open:0.6.0
28+
```
3229

33-
You can now download this docker image using
30+
and then run it with:
3431

3532
```console
36-
docker pull alphaville/open
33+
docker run --name open-jupyter -p 127.0.0.1:8888:8888 -it alphaville/open:0.6.0
3734
```
3835

39-
and then run it with
36+
This starts JupyterLab and makes it available at:
4037

41-
```console
42-
docker run -p 8888:8888 -it --name=open-notebook alphaville/open
38+
- [http://127.0.0.1:8888/lab](http://127.0.0.1:8888/lab)
39+
40+
The image currently includes:
41+
42+
- Python 3.12
43+
- `opengen==0.10.0`
44+
- JupyterLab
45+
- Rust installed through `rustup`
46+
- Example notebooks under `/open/notebooks`
47+
48+
By default, JupyterLab starts with token authentication enabled. To view the token:
49+
50+
```bash
51+
docker logs open-jupyter
4352
```
44-
It will start a Jupyter Notebook at [localhost:8888](http://localhost:8888) without a password.
4553

46-
It is always a good idea to give your docker container a name using `--name`. For example
54+
It is always a good idea to give your container a name using `--name`.
4755

4856
<div class="alert alert-info">
49-
<b>Info:</b> Use <code>docker run alphaville/open</code> only the first time you run the container. Use <code>docker start {container_name}</code> all subsequent times. Always give a name to your containers.</div>
57+
<b>Info:</b> Use <code>docker run</code> only the first time you create the container. Use <code>docker start -ai open-jupyter</code> to start it again later.</div>
5058

5159
<div class="alert alert-success">
52-
<b>Tip:</b> To stop a running container do <code>docker stop {container_name}</code>.</div>
60+
<b>Tip:</b> To stop a running container, do <code>docker stop open-jupyter</code>.</div>
5361

62+
## Configure the Docker Image
5463

55-
## Configure Docker Image
64+
### Configure password-based access
5665

57-
### Configure password
66+
To run JupyterLab with a password instead of the default token, provide a hashed password through `JUPYTER_NOTEBOOK_PASSWORD`:
5867

59-
To set up a password for your Python Notebook:
68+
```bash
69+
docker run \
70+
--name open-jupyter \
71+
-e JUPYTER_NOTEBOOK_PASSWORD='your hashed password' \
72+
-p 127.0.0.1:8888:8888 \
73+
-it alphaville/open:0.6.0
74+
```
6075

61-
- <a href="https://jupyter-notebook.readthedocs.io/en/stable/public_server.html#hashed-pw" target="_blank">Hash your password</a>
62-
- Run your docker image with:
76+
For password hashing instructions, see the [Jupyter Server documentation](https://jupyter-server.readthedocs.io/en/latest/operators/public-server.html).
6377

64-
```
65-
docker run \
66-
-e JUPYTER_NOTEBOOK_PASSWORD={your hashed password} \
67-
-p 8888:8888 \
68-
--name=open-notebook \
69-
alphaville/open
70-
```
78+
<details>
79+
<summary>How to set up a password</summary>
7180

72-
For example, let's say you want to set the password **open**. Then do
81+
You can read more about how to set up a password for your
82+
Python notebook [here](https://jupyter-server.readthedocs.io/en/latest/operators/public-server.html).
83+
TL;DR: run the following command:
7384

74-
```console
75-
docker run \
76-
-e JUPYTER_NOTEBOOK_PASSWORD=sha1:898ca689bf37:2ee883bfd6ffe82a749a86e37964700bd06a2ff9 \
77-
-p 8888:8888 \
78-
--name=open-notebook \
79-
alphaville/open
80-
```
85+
```bash
86+
docker run --rm -it --entrypoint /venv/bin/python \
87+
alphaville/open:0.6.0 \
88+
-c "from jupyter_server.auth import passwd; print(passwd())"
89+
```
90+
91+
You will be asked to provide your password twice. Then a string
92+
will be printed; this is your hashed password.
93+
</details>
8194

8295
### Configure port
8396

84-
You can access the Jupyter Notebook at a different port by configuring the port forwarding of Docker. For example, to run on port 80 run:
97+
You can access JupyterLab on a different host port by changing Docker's port forwarding. For example, to use port `80` on your machine:
8598

86-
```console
87-
docker run -p 80:8888 alphaville/open
99+
```bash
100+
docker run -p 80:8888 alphaville/open:0.6.0
88101
```
89102

90-
Then, Jupyter Notebook will be accessible at http://localhost.
91-
The argument `-p 80:8888` means that the internal port `8888` is mapped to the host's port `80`.
103+
Then JupyterLab will be available at `http://localhost/lab`.
92104

105+
### Work with notebooks
93106

94-
### Load additional python packages
107+
The bundled example notebook is available inside the container at:
95108

96-
You can load any packages you like in your Python Notebook using `pip3` and prepend a `!` to your command. For example, if you want to load `matplotlib`, do
109+
```text
110+
/open/notebooks/example.ipynb
111+
```
112+
113+
To persist your own notebooks across container restarts, mount a Docker volume onto `/open`:
114+
115+
```bash
116+
docker volume create OpEnVolume
117+
docker run --name open-jupyter \
118+
--mount source=OpEnVolume,destination=/open \
119+
-p 127.0.0.1:8888:8888 \
120+
-it alphaville/open:0.6.0
121+
```
122+
123+
### Load additional Python packages
124+
125+
You can install additional packages from inside JupyterLab. For example:
97126

98127
```python
99-
!pip3 install matplotlib
128+
!pip install matplotlib
100129
```
101130

102-
If you install a Python package in a certain docker container, it will be there the next time you access it.
131+
Packages installed into a persistent container or volume-backed environment will still be there the next time you access it.
103132

104-
### Open terminal into docker container
133+
### Open a terminal in the container
105134

106-
Suppose you have a running docker container with name `open-notebook` (you may specify a name for your docker container when you start it using `--name`). To open a terminal into it you can run
135+
Suppose you have a running Docker container with name `open-jupyter`. To open a shell in it:
107136

108-
```console
109-
docker exec -it open-notebook /bin/bash
137+
```bash
138+
docker exec -it open-jupyter /bin/bash
110139
```
111140

141+
The Python virtual environment is available at `/venv`.
142+
112143
### Download your optimizer
113-
To download your optimizer from Jupyter you first need to create an archive ot it. You can do that using `tar` as follows
144+
145+
To download a generated optimizer from JupyterLab, first create an archive:
114146

115147
```python
116148
!tar -cf rosenbrock.tar.gz optimizers/rosenbrock

docs/example-nmpc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
id: example-nmpc
33
title: Control of population dynamics
44
sidebar_label: Population dynamics
5-
description: Nonlinear model predictive control with OpEn: population dynamics
5+
description: "Nonlinear model predictive control with OpEn: population dynamics"
66
---
77
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});</script>
88
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

docs/example_bnp_py.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ builder.build()
214214
```
215215

216216
This will generate a solver in Rust as well as a [TCP server](./python-tcp-ip) that will
217-
listen for requests at `localhost:8333` (this [can be configured](python-advanced#tcp-ip-interface)).
217+
listen for requests at `localhost:8333` (this [can be configured](python-advanced#tcpip-interface)).
218218

219219

220220

0 commit comments

Comments
 (0)