Building a Livebook container with our application's code in it #3027
mbklein
started this conversation in
Show and tell
Replies: 1 comment
-
Great, thank you for sharing! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My team is responsible for a large, staff-facing Elixir/Phoenix application called Meadow. In order to make support, troubleshooting, prototyping, and data wrangling easier, we decided it would be beneficial to be able to call Meadow functions from a Livebook notebook. After some limited success with a two-container setup, using Livebook's “attached node” runtime option as well as the standalone runtime with remote execution smart cells, we felt we could do better if Meadow were running right inside the same runtime as the notebook.
However, given the size of our application's codebase,
Mix.install
ing it and waiting for it to compile inside the notebook wasn't practical. The solution presented below has been a complete game changer for us – rock solid, giving us the ability to work with Meadow's codebase and live data with all the same autocomplete, inline documentation, smart cells, and other features that make Livebook such a great tool. It allows us to investigate issues and bugs while documenting them and their solutions all in one place, and also to create repeatable workflows for processes that aren't (yet) among Meadow's user-facing features.I'm sure there are things we could be doing better, but so far this has been an incredible improvement in the way we work.
The four main pieces of the solution are:
Dockerfile
A custom
Dockerfile
that uses the latest Livebook image as a base and builds Meadow inside it, which ensures that Meadow is built using the same version of Elixir/OTP that the notebook will use for its runtime./meadow/bootstrap.exs
An Elixir runtime script that loads Meadow into the current runtime, configures it, and starts its main application.
Starter Notebook (
_meadow.livemd
)This livemd file, containing just the code needed to bootstrap Meadow, is copied to the
LIVEBOOK_HOME
directory, making it easy to fork and create a Meadow support notebook.Identity Provider Module
A custom Livebook Identity Provider module that calls back to the running Meadow application to make sure that the Livebook user is a valid Meadow superuser, allowing seamless integration between Meadow and Livebook auth. I haven't included the code here because it's highly specific to Meadow and therefore not as generally useful as the other pieces.
Here's a screen recording showing it in action, with a couple very simple cells at the bottom just to show off autocompletion and documentation:
Beta Was this translation helpful? Give feedback.
All reactions