2022-05-13 15:39:27 +08:00
< h1 >
< a href = "https://livebook.dev/" target = "_blank" >
< img src = "https://github.com/livebook-dev/livebook/raw/main/static/images/logo-with-text.png" alt = "Livebook" width = "400" >
< / a >
< / h1 >
2021-01-08 03:55:45 +08:00
2022-09-09 22:48:06 +08:00
[![Website ](https://img.shields.io/badge/-Website-%23ff87a7 )](https://livebook.dev/) [![Version ](https://img.shields.io/hexpm/v/livebook?color=b5a3be )](https://hex.pm/packages/livebook)
2021-08-28 23:44:36 +08:00
2022-09-09 22:48:06 +08:00
Livebook is a web application for writing interactive and collaborative code notebooks. It features:
2021-01-08 03:55:45 +08:00
2022-03-02 19:48:02 +08:00
* Code notebooks with Markdown support and Code cells where Elixir code is evaluated on demand.
2021-01-08 03:55:45 +08:00
2022-05-02 21:54:07 +08:00
* Rich code editor through [Monaco ](https://microsoft.github.io/monaco-editor/ ): with support for autocompletion, inline documentation, code formatting, etc.
2021-01-08 03:55:45 +08:00
2022-05-02 21:54:07 +08:00
* Interactive results via [Kino ](https://github.com/elixir-nx/kino ): display [Vega-Lite charts ](https://vega.github.io/vega-lite/ ), tables, maps, and more.
2021-06-18 05:32:36 +08:00
2022-07-19 15:33:58 +08:00
* Automation: use Smart cells to perform high-level tasks and write notebooks faster than ever. Query databases, plot charts, build maps, and more directly from Livebook's UI.
2021-01-08 03:55:45 +08:00
2021-08-25 17:57:18 +08:00
* Reproducible: Livebook ensures your code runs in a predictable order, all the way down to package management. It also tracks your notebook state, annotating which parts are stale.
2021-07-15 17:23:22 +08:00
2022-07-19 15:33:58 +08:00
* Collaboration: multiple users can work on the same notebook at once, no additional setup required.
2021-08-25 17:57:18 +08:00
2022-07-19 15:33:58 +08:00
* Decentralized: Livebook is open-source and you can run it anywhere. The ["Run in Livebook" badge ](https://livebook.dev/badge ) makes it easy to import any Livebook into your own Livebook.
2021-10-21 14:02:16 +08:00
2022-05-02 21:54:07 +08:00
* Versionable: notebooks are stored in the `.livemd` format, which is a subset of Markdown with support for diagrams via [Mermaid ](https://mermaid-js.github.io/mermaid ) and for mathematical formulas via [KaTex ](https://katex.org/ ). `.livemd` files can be shared and play well with version control.
2021-10-21 14:02:16 +08:00
* Custom runtimes: when executing Elixir code, you can either start a fresh Elixir instance, connect to an existing node, or run it inside an existing Elixir project, with access to all of its modules and dependencies. This means Livebook can be a great tool to introspect and document existing projects too.
2021-06-18 05:32:36 +08:00
## Getting started
2022-09-21 18:06:22 +08:00
Head out to [the Install section ](https://livebook.dev/#install ) of Livebook's website to get started. Once Livebook is up and running on your machine, **visit the "Learn" section** with introductory guides and documentation on several Livebook features. Here is a sneak peak of the "Welcome to Livebook" guide:
2021-04-05 22:46:17 +08:00
2021-08-18 21:55:07 +08:00
![Screenshot ](https://github.com/livebook-dev/livebook/raw/main/.github/imgs/welcome.png )
2021-04-05 22:46:17 +08:00
2022-05-13 15:39:27 +08:00
For screencasts and news, check out [news.livebook.dev ](https://news.livebook.dev/ ).
2021-04-05 22:46:17 +08:00
2022-05-13 15:39:27 +08:00
## Installation
2021-04-05 22:46:17 +08:00
2022-01-29 04:57:59 +08:00
We provide several methods for running Livebook,
2021-04-27 22:34:02 +08:00
pick the one that best fits your use case.
2022-05-13 15:39:27 +08:00
### On the cloud
2021-10-19 19:30:23 +08:00
* [Launch a Livebook instance close to you on Fly.io ](https://fly.io/launch/livebook )
2022-05-13 15:39:27 +08:00
### Desktop app
2021-09-10 16:36:25 +08:00
2022-09-13 20:34:25 +08:00
* [Download the installer for Mac and Windows from our homepage ](https://livebook.dev/#install )
* Latest stable builds: [Mac (Universal) ](https://livebook.dev/releases/latest/LivebookInstall-latest-macos-universal.dmg ),
[Windows ](https://livebook.dev/releases/latest/LivebookInstall-latest-windows-x86_64.exe )
* Nightly builds: [Mac (Universal) ](https://livebook.dev/releases/nightly/LivebookInstall-nightly-macos-universal.dmg ),
[Windows ](https://livebook.dev/releases/nightly/LivebookInstall-nightly-windows-x86_64.exe )
* Builds for particular Livebook version are available on our
[GitHub releases ](https://github.com/livebook-dev/livebook/releases ).
2022-05-13 15:39:27 +08:00
### 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.
```shell
# Running with the default configuration
2023-03-16 00:30:18 +08:00
docker run -p 8080:8080 -p 8081:8081 --pull always ghcr.io/livebook-dev/livebook
2022-05-13 15:39:27 +08:00
# In order to access and save notebooks directly to your machine
# you can mount a local directory into the container.
# Make sure to specify the user with "-u $(id -u):$(id -g)"
# so that the created files have proper permissions
2023-03-16 00:30:18 +08:00
docker run -p 8080:8080 -p 8081:8081 --pull always -u $(id -u):$(id -g) -v $(pwd):/data ghcr.io/livebook-dev/livebook
2022-05-13 15:39:27 +08:00
# You can configure Livebook using environment variables,
# for all options see the dedicated "Environment variables" section below
2023-03-16 00:30:18 +08:00
docker run -p 8080:8080 -p 8081:8081 --pull always -e LIVEBOOK_PASSWORD="securesecret" ghcr.io/livebook-dev/livebook
2022-05-13 15:39:27 +08:00
```
2023-03-16 00:30:18 +08:00
For CUDA support, [see images with the "cuda" tag ](https://github.com/livebook-dev/livebook/pkgs/container/livebook ).
2022-12-14 03:41:05 +08:00
2022-05-13 15:39:27 +08:00
To try out features from the main branch you can alternatively
2023-03-16 00:30:18 +08:00
use the `ghcr.io/livebook-dev/livebook:edge` image.
See [Livebook images ](https://github.com/livebook-dev/livebook/pkgs/container/livebook ).
2022-05-13 15:39:27 +08:00
### Embedded devices
If you want to run Livebook on embedded devices, such as Raspberry Pi, BeagleBone, etc.,
check out [our Livebook firmware ](https://github.com/livebook-dev/nerves_livebook ) built
with [Nerves ](https://www.nerves-project.org/ ).
### Direct installation with Elixir
2022-06-13 00:10:37 +08:00
You can run Livebook on your own machine using just Elixir. You will need
2021-12-08 15:08:23 +08:00
[Elixir v1.13 ](https://elixir-lang.org/install.html ) or later.
2021-06-24 13:27:58 +08:00
Livebook also requires the following Erlang applications: `inets` ,
2021-11-12 19:39:58 +08:00
`os_mon` , `runtime_tools` , `ssl` and `xmerl` . Those applications come
with most Erlang distributions but certain package managers may split
2022-01-29 04:57:59 +08:00
them apart. For example, on Ubuntu, these Erlang applications can
2021-06-24 13:27:58 +08:00
be installed as follows:
```shell
2021-11-12 19:39:58 +08:00
sudo apt install erlang-inets erlang-os-mon erlang-runtime-tools erlang-ssl erlang-xmerl erlang-dev erlang-parsetools
2021-06-24 13:27:58 +08:00
```
2021-04-05 22:46:17 +08:00
2021-09-10 16:36:25 +08:00
#### Escript
2021-04-27 22:34:02 +08:00
Running Livebook using Escript makes for a very convenient option
for local usage and provides easy configuration via CLI options.
```shell
2022-02-26 16:40:15 +08:00
mix do local.rebar --force, local.hex --force
2021-10-17 01:54:10 +08:00
mix escript.install hex livebook
2021-04-27 22:34:02 +08:00
# Start the Livebook server
2021-05-20 05:30:53 +08:00
livebook server
2021-04-27 22:34:02 +08:00
# See all the configuration options
2021-05-20 05:30:53 +08:00
livebook server --help
2021-04-27 22:34:02 +08:00
```
2021-05-20 05:30:53 +08:00
After you install the escript, make sure you add the directory where
Elixir keeps escripts to your [$PATH ](https://en.wikipedia.org/wiki/PATH_(variable )).
2021-05-20 18:27:30 +08:00
If you installed Elixir with `asdf` , you'll need to run `asdf reshim elixir`
once the escript is built.
2021-05-20 05:30:53 +08:00
2021-06-25 00:02:24 +08:00
To try out features from the main branch you can alternatively
install the escript directly from GitHub like this:
```shell
2021-08-18 21:55:07 +08:00
mix escript.install github livebook-dev/livebook
2021-06-25 00:02:24 +08:00
```
2021-09-10 16:36:25 +08:00
#### Mix
2021-05-20 05:30:53 +08:00
You can run latest Livebook directly with Mix.
```shell
2021-08-18 21:55:07 +08:00
git clone https://github.com/livebook-dev/livebook.git
2021-05-20 05:30:53 +08:00
cd livebook
mix deps.get --only prod
# Run the Livebook server
MIX_ENV=prod mix phx.server
```
2021-09-21 19:47:45 +08:00
## Security considerations
2021-04-14 03:37:04 +08:00
2021-09-21 19:47:45 +08:00
Livebook is built to document and execute code. Anyone with access to a Livebook instance
will be able to access any file and execute any code in the machine Livebook is running.
For this reason, Livebook only binds to the 127.0.0.1, allowing access to happen only within
the current machine. When running Livebook in the production environment - the recommended
environment - we also generate a token on initialization and we only allow access to the
Livebook if said token is supplied as part of the URL.
## Environment variables
2021-04-15 21:50:29 +08:00
<!-- Environment variables -->
The following environment variables configure Livebook:
2022-04-15 19:46:26 +08:00
* LIVEBOOK_APP_SERVICE_NAME - sets the application name used by the cloud
provider to aid debugging.
* LIVEBOOK_APP_SERVICE_URL - sets the application url to manage this
Livebook instance within the cloud provider platform.
2023-03-01 04:37:43 +08:00
* LIVEBOOK_APPS_PATH - the directory with app notebooks. When set, the apps
are deployed on Livebook startup with the persisted settings.
Password-protected notebooks will receive a random password,
unless LIVEBOOK_APPS_PATH_PASSWORD is set.
* LIVEBOOK_APPS_PATH_PASSWORD - the password to use for all protected apps
deployed from LIVEBOOK_APPS_PATH.
2023-02-02 04:22:49 +08:00
* LIVEBOOK_BASE_URL_PATH - sets the base url path the web application is served on.
Useful when deploying behind a reverse proxy.
2021-04-27 22:34:02 +08:00
* LIVEBOOK_COOKIE - sets the cookie for running Livebook in a cluster.
Defaults to a random string that is generated on boot.
2022-01-31 18:51:57 +08:00
* LIVEBOOK_DATA_PATH - the directory to store Livebook configuration.
Defaults to "livebook" under the default user data directory.
2021-06-25 00:03:00 +08:00
* LIVEBOOK_DEFAULT_RUNTIME - sets the runtime type that is used by default
when none is started explicitly for the given notebook. Must be either
2022-08-29 20:20:24 +08:00
"standalone" (Elixir standalone), "attached:NODE:COOKIE" (Attached node)
or "embedded" (Embedded). Defaults to "standalone".
2021-05-10 20:37:38 +08:00
2023-02-02 04:22:49 +08:00
* LIVEBOOK_DISTRIBUTION - sets the node distribution for running Livebook in a
cluster. Must be "name" (long names) or "sname" (short names). Note that this
sets RELEASE_DISTRIBUTION if present when creating a release. Defaults to "sname".
2022-04-15 19:46:26 +08:00
* LIVEBOOK_FORCE_SSL_HOST - sets a host to redirect to if the request is not over HTTP.
Note it does not apply when accessing Livebook via localhost. Defaults to nil.
2022-01-31 18:51:57 +08:00
* LIVEBOOK_HOME - sets the home path for the Livebook instance. This is the
default path used on file selection screens and others. Defaults to the
user's operating system home.
2022-02-08 21:45:58 +08:00
* LIVEBOOK_IFRAME_PORT - sets the port that Livebook serves iframes at.
This is relevant only when running Livebook without TLS. Defaults to 8081.
2022-05-26 08:39:55 +08:00
* LIVEBOOK_IFRAME_URL - sets the URL that Livebook loads iframes from.
By default iframes are loaded from local LIVEBOOK_IFRAME_PORT when accessing
2023-04-04 06:03:14 +08:00
Livebook over http:// and from https://livebookusercontent.com when accessing over https://.
2022-05-26 08:39:55 +08:00
2021-06-25 00:03:00 +08:00
* LIVEBOOK_IP - sets the ip address to start the web application on.
Must be a valid IPv4 or IPv6 address.
2021-04-27 22:34:02 +08:00
2023-02-02 04:22:49 +08:00
* LIVEBOOK_NODE - sets the node name for running Livebook in a cluster. Note that
this sets RELEASE_NODE if present when creating a release.
2022-11-30 06:34:38 +08:00
2021-06-25 00:03:00 +08:00
* LIVEBOOK_PASSWORD - sets a password that must be used to access Livebook.
Must be at least 12 characters. Defaults to token authentication.
2021-04-15 21:50:29 +08:00
2022-01-20 17:43:02 +08:00
* LIVEBOOK_PORT - sets the port Livebook runs on. If you want to run multiple
instances on the same domain with the same credentials but on different ports,
2022-01-21 16:18:02 +08:00
you also need to set LIVEBOOK_SECRET_KEY_BASE. Defaults to 8080. If set to 0,
a random port will be picked.
2021-04-15 21:50:29 +08:00
2021-06-25 00:03:00 +08:00
* LIVEBOOK_SECRET_KEY_BASE - sets a secret key that is used to sign and encrypt
the session and other payloads used by Livebook. Must be at least 64 characters
long and it can be generated by commands such as: 'openssl rand -base64 48'.
Defaults to a random secret on every boot.
2021-04-20 01:50:09 +08:00
2022-04-14 21:52:28 +08:00
* LIVEBOOK_SHUTDOWN_ENABLED - controls if a shutdown button should be shown
in the homepage. Set it to "true" to enable it.
2021-11-10 20:54:50 +08:00
* LIVEBOOK_TOKEN_ENABLED - controls whether token authentication is enabled.
2023-03-01 04:37:43 +08:00
Enabled by default unless LIVEBOOK_PASSWORD is set. Set it to "false" to
2022-01-20 17:43:02 +08:00
disable it.
2021-11-10 20:54:50 +08:00
2022-04-18 06:55:08 +08:00
* LIVEBOOK_UPDATE_INSTRUCTIONS_URL - sets the URL to direct the user to for
updating Livebook when a new version becomes available.
2022-11-10 23:03:50 +08:00
* LIVEBOOK_WITHIN_IFRAME - controls if the application is running inside an
iframe. Set it to "true" to enable it. If you do enable it, then the application
must run with HTTPS.
2023-02-16 05:18:13 +08:00
* LIVEBOOK_ALLOW_URI_SCHEMES - sets additional allowed hyperlink schemes to the
Markdown content. Livebook sanitizes links in Markdown, allowing only a few
standard schemes by default (such as http and https). Set it to a comma-separated
list of schemes.
2023-02-16 05:16:38 +08:00
2021-05-21 08:01:54 +08:00
<!-- Environment variables -->
2023-02-02 17:52:16 +08:00
When running Livebook Desktop, Livebook will invoke on boot a file named
`~/.livebookdesktop.sh` on macOS or `%USERPROFILE%\.livebookdesktop.bat`
on Windows. This file can set environment variables used by Livebook,
2023-02-11 03:48:09 +08:00
such as:
* [the `PATH` environment variable ](https://en.wikipedia.org/wiki/PATH_(variable ))
* set `LIVEBOOK_DISTRIBUTION=name` to enable notebooks to communicate
with nodes in other machines
* or to configure the Erlang VM, for instance, by setting
`ERL_AFLAGS="-proto_dist inet6_tcp"` if you need Livebook to run over IPv6
2023-02-02 17:52:16 +08:00
Be careful when modifying said files, Livebook may be unable to start if
configured incorrectly.
2022-09-09 22:48:06 +08:00
If running Livebook via the command line, run `livebook server --help` to see
all CLI-specific options.
2021-05-20 05:30:53 +08:00
## Development
Livebook is primarily a Phoenix web application and can be setup as such:
```shell
2021-07-24 04:48:24 +08:00
git clone https://github.com/livebook-dev/livebook.git
2021-05-20 05:30:53 +08:00
cd livebook
2021-12-23 01:52:17 +08:00
mix dev.setup
2021-05-20 05:30:53 +08:00
# Run the Livebook server
mix phx.server
2022-09-09 22:48:06 +08:00
# Run tests
mix test
2021-05-20 05:30:53 +08:00
# To test escript
MIX_ENV=prod mix escript.build
./livebook server
```
2023-01-17 04:09:47 +08:00
### Livebook Desktop
For macOS, run:
```shell
# Test macOS app locally
(cd rel/app/macos & & ./run.sh)
# Build macOS installer
.github/scripts/app/build_macos.sh
```
For Windows, run:
```shell
# Test Windows app locally
(cd rel/app/windows & & ./run.sh)
# Build Windows installer
.github/scripts/app/build_windows.sh
```
2021-09-10 16:36:25 +08:00
## Sponsors
Livebook development is sponsored by:
2023-04-12 01:20:35 +08:00
< a href = "https://fly.io" target = _blank > < img src = "https://fly.io/public/images/brand/logo.svg" width = "320" / > < / a >
2021-09-10 16:36:25 +08:00
2023-04-12 01:20:35 +08:00
## Supporters
Machine Learning and Neural Network models hosted by:
< a href = "https://huggingface.co/" target = _blank > < img src = "https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo-with-title.png" width = "320" / > < / a >
2022-01-29 04:57:59 +08:00
2022-01-31 18:51:57 +08:00
Our CI server and desktop app for macOS are powered by:
2022-01-29 04:57:59 +08:00
2023-04-12 01:20:35 +08:00
< a href = "https://www.macstadium.com" target = "_blank" > < img src = "https://user-images.githubusercontent.com/9582/151619816-b7794798-8261-46c8-bb88-d12108e3ff12.png" width = "320" / > < / a >
2022-01-29 04:57:59 +08:00
2021-04-05 22:46:17 +08:00
## License
Copyright (C) 2021 Dashbit
2021-12-13 14:33:34 +08:00
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0 ](http://www.apache.org/licenses/LICENSE-2.0 )
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.