More contents to Docker guide

This commit is contained in:
José Valim 2023-10-24 23:44:28 +02:00
parent 626ea9781a
commit 3104871e47
2 changed files with 48 additions and 50 deletions

View file

@ -55,8 +55,8 @@ pick the one that best fits your use case.
### Docker
Running Livebook using Docker is a great option for cloud deployments
and also for local usage in case you don't have Elixir installed.
Running Livebook using Docker is another great option to run Livebook
in case you don't have Elixir installed.
```shell
# Running with the default configuration
@ -76,29 +76,14 @@ docker run -p 8080:8080 -p 8081:8081 --pull always -e LIVEBOOK_PASSWORD="secures
docker run -p 8090:8090 -p 8091:8091 --pull always -e LIVEBOOK_PORT=8090 -e LIVEBOOK_IFRAME_PORT=8091 ghcr.io/livebook-dev/livebook
```
To deploy Livebook on your cloud platform, see our [Docker Deployment](docs/deployment/docker.md) guide.
For CUDA support, [see images with the "cuda" tag](https://github.com/livebook-dev/livebook/pkgs/container/livebook).
To try out features from the main branch you can alternatively
use the `ghcr.io/livebook-dev/livebook:edge` image.
See [Livebook images](https://github.com/livebook-dev/livebook/pkgs/container/livebook).
If using Docker Compose the following template is a good starting point:
```yml
services:
livebook:
image: ghcr.io/livebook-dev/livebook
ports:
- 8090:8090
- 8091:8091
environment:
- LIVEBOOK_PORT=8090
- LIVEBOOK_IFRAME_PORT=8091
```
To run multiple instances of Livebook behind a load balancer,
see the ["Clustering"](#clustering) section.
### Embedded devices
If you want to run Livebook on embedded devices, such as Raspberry Pi, BeagleBone, etc.,
@ -216,7 +201,8 @@ The following environment variables can be used to configure Livebook on boot:
accesses files from external sources.
* LIVEBOOK_CLUSTER - configures clustering strategy when running multiple
instances of Livebook. See the ["Clustering"](#clustering) section below.
instances of Livebook. See the "Clustering" section of our Docker Deployment
guide for more information: https://hexdocs.pm/livebook/docker.html
* LIVEBOOK_COOKIE - sets the cookie for running Livebook in a cluster.
Defaults to a random string that is generated on boot.
@ -328,32 +314,6 @@ such as:
Be careful when modifying boot files, Livebook may be unable to start if
configured incorrectly.
### Clustering
Clustering is enabled via the `LIVEBOOK_CLUSTER` environment variable.
Currently the only supported value is `dns:QUERY`, in which case nodes
ask DNS for A/AAAA records using the given query and try to connect to
peer nodes on the discovered IPs.
When clustering is enabled, you must additionally set the following env vars:
* `LIVEBOOK_NODE=livebook_server@IP`, where `IP` is the machine IP of each
deployed node
* You must set `LIVEBOOK_SECRET_KEY_BASE` and `LIVEBOOK_COOKIE` to
different random values (use `openssl rand -base64 48` to generate
said values)
* If your cloud requires IPv6, also set `ERL_AFLAGS="-proto_dist inet6_tcp"`
`LIVEBOOK_DISTRIBUTION` is automatically set to `name` if clustering is
enabled.
Some variables, like `LIVEBOOK_NODE`, are oftentimes computed at runtime.
When using the Livebook Docker image, you can create a file at `/app/env.sh`
that exports the necessary environment variables. This file is invoked right
before booting Livebook.
## Development
Livebook is primarily a Phoenix web application and can be setup as such:

View file

@ -1,6 +1,8 @@
# Docker
## Dockerfile
There are two main use cases to deploy Livebook in the cloud. The first is to read and write notebooks in the cloud, instead of your machine. The second is to deploy notebooks as applications. This guide covers both as well other details such as clustering.
## Livebook in the cloud
You can deploy Livebook inside your infrastructure using Docker. The Dockerfile below provides a great starting point:
@ -18,10 +20,46 @@ RUN mkdir -p /data
RUN chmod 777 /data
```
To configure your Livebook instance, you can use [these environment variables](../../README.md#environment-variables).
We also recommend setting the `LIVEBOOK_PASSWORD` environment variable to a secret value. If it is not set, you will find the token to access Livebook in the logs. See all other supported [environment variables](../../README.md#environment-variables) to learn more.
If you want to run several Livebook instances behind a load balancer, you need to enable clustering. See the [Clustering](#clustering) section.
If you plan to limit access to your Livebook via a proxy, we recommend leaving the "/public" route of your instances still public. This route is used for integration with the [Livebook Badge](https://livebook.dev/badge/) and other conveniences.
## Livebook Teams
### Docker compose
[Livebook Teams](https://livebook.dev/teams/) users have access to airgapped notebook deployment via Docker, with pre-configured Zero Trust Authentication, shared team secrets and file storages. To get started, open up Livebook, click "Add Organization" on the sidebar, and visit the "Airgapped Deployment" section of your organization.
If using Docker Compose the following template is a good starting point:
```yml
services:
livebook:
image: ghcr.io/livebook-dev/livebook
ports:
- 8090:8090
- 8091:8091
environment:
- LIVEBOOK_PORT=8090
- LIVEBOOK_IFRAME_PORT=8091
```
## Deploy notebooks as applications
It is possible to deploy any notebook as an application in Livebook. Inside the notebook, open up the Application pane on the sidebar (with a rocket icon), click "Deploy with Docker", and follow the required steps. You will be able to choose a Livebook image, preset clustering options, and more.
If you are using [Livebook Teams](https://livebook.dev/teams/), you will also have access to airgapped notebook deployment with pre-configured Zero Trust Authentication, shared team secrets and file storages. To get started, open up Livebook, click "Add Organization" on the sidebar, and visit the "Airgapped Deployment" section of your organization.
## Clustering
If you plan to run several Livebook instances behind a load balancer, you need to enable clustering via the `LIVEBOOK_CLUSTER` environment variable. Currently the only supported value is `dns:QUERY`, in which case nodes ask DNS for A/AAAA records using the given query and try to connect to peer nodes on the discovered IPs.
When clustering is enabled, you must additionally set the following env vars:
* `LIVEBOOK_NODE=livebook_server@IP`, where `IP` is the machine IP of each deployed node
* You must set `LIVEBOOK_SECRET_KEY_BASE` and `LIVEBOOK_COOKIE` to different random values (use `openssl rand -base64 48` to generate said values)
* If your cloud requires IPv6, also set `ERL_AFLAGS="-proto_dist inet6_tcp"`
`LIVEBOOK_DISTRIBUTION` is automatically set to `name` if clustering is enabled.
Some variables, like `LIVEBOOK_NODE`, are oftentimes computed at runtime. When using the Livebook Docker image, you can create a file at `/app/env.sh` that exports the necessary environment variables. This file is invoked right before booting Livebook.