Automate code & data workflows with interactive Elixir notebooks
Find a file
2022-04-28 11:04:02 +00:00
.github Update ISSUE_TEMPLATE.md (#1120) 2022-04-15 19:52:20 +02:00
app_builder Add taskbar icon to desktop app (#1119) 2022-04-21 09:51:48 +02:00
assets Reinitialize cell editor on reconnection (#1146) 2022-04-28 13:02:20 +02:00
config Add app service settings (#1116) 2022-04-15 13:46:26 +02:00
iframe Serve iframes from another local port when running on http (#989) 2022-02-08 14:45:58 +01:00
lib Add shared mode to Livebook sessions (#1128) 2022-04-28 13:01:53 +02:00
rel Add taskbar icon to desktop app (#1119) 2022-04-21 09:51:48 +02:00
static Update assets 2022-04-28 11:04:02 +00:00
test Update instructions in the Elixir export (#1144) 2022-04-25 13:37:15 +02:00
.dockerignore Build assets to tmp/static_dev in development 2021-05-19 23:50:18 +02:00
.formatter.exs Initial commit 2021-01-07 20:56:24 +01:00
.gitattributes Add .gitattributes to keep newlines on checksumed files 2022-02-21 09:02:16 +01:00
.gitignore Build assets to tmp/static_dev in development 2021-05-19 23:50:18 +02:00
CHANGELOG.md Update changelog (#1135) 2022-04-20 21:19:41 +02:00
Dockerfile Serve iframes from another local port when running on http (#989) 2022-02-08 14:45:58 +01:00
LICENSE Move to Apache 2 License 2021-04-13 21:33:30 +02:00
mix.exs Add taskbar icon to desktop app (#1119) 2022-04-21 09:51:48 +02:00
mix.lock Update dependencies (#1099) 2022-04-11 21:01:45 +02:00
README.md Revert "GitHub Codespaces: Add devcontainer.json files to Livebook (#1138)" 2022-04-26 21:05:00 +02:00

Livebook

Hex.pm

Livebook is a web application for writing interactive and collaborative code notebooks for Elixir, built with Phoenix LiveView. It features:

  • Code notebooks with Markdown support and Code cells where Elixir code is evaluated on demand.

  • Shareable: notebooks are stored in the .livemd format, which is a subset of Markdown with support for diagrams via Mermaid and for mathematical formulas via KaTex. .livemd files can be easily shared and play well with version control.

  • Interactive widgets via Kino: manipulate Vega-Lite charts, tables, and more.

  • Rich code editor through Monaco: with support for autocompletion, inline documentation, code formatting, etc.

  • 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.

  • Persistence: persist your notebooks to disk or any S3-compatible cloud storage.

  • Collaboration: multiple users can work on the same notebook at once. It works out-of-the-box either in single-node or multi-node deployments - without a need for additional tooling.

  • Decentralized: Livebook is open-source and you can run it anywhere. The "Run in Livebook" badges makes it easy to import any Livebook into your preferred Livebook instance.

  • 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.

We are actively working on Livebook and you can consult the issues tracker to see some of the features we are exploring. We also want to thank Jupyter and Deepnote for inspiring some of our features.

Getting started

Livebook comes with a series of introductory notebooks to get you up and running. Just head down to the "Usage" section below to install it. Here is a peek at the "Welcome to Livebook" introductory notebook:

Screenshot

For screencasts and updates, check out news.livebook.dev.

Usage

We provide several methods for running Livebook, pick the one that best fits your use case.

Running on the cloud

Running locally

You can run Livebook on your own machine. You will need Elixir v1.13 or later. Livebook also requires the following Erlang applications: inets, os_mon, runtime_tools, ssl and xmerl. Those applications come with most Erlang distributions but certain package managers may split them apart. For example, on Ubuntu, these Erlang applications can be installed as follows:

sudo apt install erlang-inets erlang-os-mon erlang-runtime-tools erlang-ssl erlang-xmerl erlang-dev erlang-parsetools

Escript

Running Livebook using Escript makes for a very convenient option for local usage and provides easy configuration via CLI options.

mix do local.rebar --force, local.hex --force
mix escript.install hex livebook

# Start the Livebook server
livebook server

# See all the configuration options
livebook server --help

After you install the escript, make sure you add the directory where Elixir keeps escripts to your $PATH. If you installed Elixir with asdf, you'll need to run asdf reshim elixir once the escript is built.

To try out features from the main branch you can alternatively install the escript directly from GitHub like this:

mix escript.install github livebook-dev/livebook

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 with the default configuration
docker run -p 8080:8080 -p 8081:8081 --pull always livebook/livebook

# 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
docker run -p 8080:8080 -p 8081:8081 --pull always -u $(id -u):$(id -g) -v $(pwd):/data livebook/livebook

# You can configure Livebook using environment variables,
# for all options see the dedicated "Environment variables" section below
docker run -p 8080:8080 -p 8081:8081 --pull always -e LIVEBOOK_PASSWORD="securesecret" livebook/livebook

To try out features from the main branch you can alternatively use the livebook/livebook:edge image. See Livebook on Docker Hub.

Mix

You can run latest Livebook directly with Mix.

git clone https://github.com/livebook-dev/livebook.git
cd livebook
mix deps.get --only prod

# Run the Livebook server
MIX_ENV=prod mix phx.server

Embedded devices

If you want to run Livebook on embedded devices, such as Raspberry Pi, BeagleBone, etc., check out our Livebook firmware built with Nerves.

Security considerations

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

The following environment variables configure Livebook:

  • 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.

  • LIVEBOOK_COOKIE - sets the cookie for running Livebook in a cluster. Defaults to a random string that is generated on boot.

  • LIVEBOOK_DATA_PATH - the directory to store Livebook configuration. Defaults to "livebook" under the default user data directory.

  • LIVEBOOK_DEFAULT_RUNTIME - sets the runtime type that is used by default when none is started explicitly for the given notebook. Must be either "standalone" (Elixir standalone), "mix[:PATH][:FLAGS]" (Mix standalone), "attached:NODE:COOKIE" (Attached node) or "embedded" (Embedded). Defaults to "standalone".

  • 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.

  • 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.

  • LIVEBOOK_IFRAME_PORT - sets the port that Livebook serves iframes at. This is relevant only when running Livebook without TLS. Defaults to 8081.

  • LIVEBOOK_IP - sets the ip address to start the web application on. Must be a valid IPv4 or IPv6 address.

  • LIVEBOOK_PASSWORD - sets a password that must be used to access Livebook. Must be at least 12 characters. Defaults to token authentication.

  • 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, you also need to set LIVEBOOK_SECRET_KEY_BASE. Defaults to 8080. If set to 0, a random port will be picked.

  • 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.

  • LIVEBOOK_SHUTDOWN_ENABLED - controls if a shutdown button should be shown in the homepage. Set it to "true" to enable it.

  • LIVEBOOK_TOKEN_ENABLED - controls whether token authentication is enabled. Enabled by default unless LIVEBOOK_PASSWORD is set. Set it to "false" to disable it.

  • LIVEBOOK_UPDATE_INSTRUCTIONS_URL - sets the URL to direct the user to for updating Livebook when a new version becomes available.

If running Livebook as a Docker image or an Elixir release, the environment variables used by Elixir releases are also available. The notables ones are RELEASE_NODE and RELEASE_DISTRIBUTION.

Rendering notebooks as Markdown on GitHub

By default GitHub renders the .livemd notebooks as regular text files. Depending on your use case and the target audience, you may find it useful to render notebooks content as Markdown files instead. There is an option to override how a particular file gets rendered on GitHub, so all you need to do is add a magic comment in every such notebook:

<!-- vim: set syntax=markdown: -->

# My notebook

...

For more details see the documentation.

Development

Livebook is primarily a Phoenix web application and can be setup as such:

git clone https://github.com/livebook-dev/livebook.git
cd livebook
mix dev.setup

# Run the Livebook server
mix phx.server

# To test escript
MIX_ENV=prod mix escript.build
./livebook server

Sponsors

Livebook development is sponsored by:

Continuous Integration

Our CI server and desktop app for macOS are powered by:

License

Copyright (C) 2021 Dashbit

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

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.