From 1e4200e3389f901a1a08a9754cc696f9c9679f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Wed, 19 May 2021 23:30:53 +0200 Subject: [PATCH] Initial release (#279) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Ensure config is loaded before compiling Escript dependencies * Update README * Add CHANGELOG * Update mix.exs * Increase timeout for mix standalone test * Add package info to mix.exs * Update README.md Co-authored-by: José Valim Co-authored-by: José Valim --- CHANGELOG.md | 5 ++ README.md | 59 ++++++++++++------- mix.exs | 30 ++++++++-- test/livebook/runtime/mix_standalone_test.exs | 4 +- 4 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..d7a2f0f11 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## v0.1.0 (2021-05-19) + + * Initial release diff --git a/README.md b/README.md index 10a8888cb..49e0fc5fb 100644 --- a/README.md +++ b/README.md @@ -27,19 +27,6 @@ The current version provides only the initial step of our Livebook vision. Our p We provide several distinct methods of running Livebook, pick the one that best fits your use case. -### Mix - -You can run latest Livebook directly with Mix. - -```shell -git clone https://github.com/elixir-nx/livebook.git -cd livebook -mix deps.get --only prod - -# Run the Livebook server -MIX_ENV=prod mix phx.server -``` - You will need [Elixir v1.12](https://elixir-lang.org/install.html) or later. ### Escript @@ -48,20 +35,20 @@ Running Livebook using Escript makes for a very convenient option for local usage and provides easy configuration via CLI options. ```shell -# Currently you need to build the Escript manually, -# we will publish it to Hex once we release the first version -git clone https://github.com/elixir-nx/livebook.git -cd livebook -mix deps.get --only prod -MIX_ENV=prod mix escript.build +mix escript.install hex livebook # Start the Livebook server -./livebook server +livebook server # See all the configuration options -./livebook server --help +livebook server --help ``` +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)). +If you installed Elixir with `asdf`, you'll need to run `asdf reshim elixir`. +once the Escript is built. + ### Docker Running Livebook using Docker is a great option for cloud deployments @@ -82,6 +69,19 @@ docker run -p 8080:8080 -u $(id -u):$(id -g) -v :/data livebook/liveb docker run -p 8080:8080 -e LIVEBOOK_PASSWORD="securesecret" livebook/livebook ``` +### Mix + +You can run latest Livebook directly with Mix. + +```shell +git clone https://github.com/elixir-nx/livebook.git +cd livebook +mix deps.get --only prod + +# Run the Livebook server +MIX_ENV=prod mix phx.server +``` + ### 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. @@ -111,6 +111,23 @@ The following environment variables configure Livebook: * 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. +## Development + +Livebook is primarily a Phoenix web application and can be setup as such: + +```shell +git clone https://github.com/elixir-nx/livebook.git +cd livebook +mix deps.get + +# Run the Livebook server +mix phx.server + +# To test escript +MIX_ENV=prod mix escript.build +./livebook server +``` + ## License diff --git a/mix.exs b/mix.exs index c4b5a2ea1..5f48792d5 100644 --- a/mix.exs +++ b/mix.exs @@ -1,18 +1,24 @@ defmodule Livebook.MixProject do use Mix.Project + @version "0.1.0" + @description "Interactive and collaborative code notebooks - made with Phoenix LiveView" + def project do [ app: :livebook, - version: "0.1.0", + version: @version, elixir: "~> 1.12", + name: "Livebook", + description: @description, elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), escript: escript(), - releases: releases() + releases: releases(), + package: package() ] end @@ -48,18 +54,23 @@ defmodule Livebook.MixProject do [ "dev.setup": ["deps.get", "cmd npm install --prefix assets"], "dev.build": ["cmd npm run deploy --prefix ./assets"], - "format.all": ["format", "cmd npm run format --prefix ./assets"] + "format.all": ["format", "cmd npm run format --prefix ./assets"], + # TODO: loadconfig no longer required on Elixir v1.13 + # Currently this ensures we load configuration before + # compiling dependencies as part of `mix escript.install`. + # See https://github.com/elixir-lang/elixir/commit/a6eefb244b3a5892895a97b2dad4cce2b3c3c5ed + "escript.build": ["loadconfig", "escript.build"] ] end - defp escript() do + defp escript do [ main_module: LivebookCLI, app: nil ] end - defp releases() do + defp releases do [ livebook: [ include_executables_for: [:unix], @@ -67,4 +78,13 @@ defmodule Livebook.MixProject do ] ] end + + def package do + [ + licenses: ["Apache-2.0"], + links: %{ + "GitHub" => "https://github.com/elixir-nx/livebook" + } + ] + end end diff --git a/test/livebook/runtime/mix_standalone_test.exs b/test/livebook/runtime/mix_standalone_test.exs index 103fd6783..b8d31d0c1 100644 --- a/test/livebook/runtime/mix_standalone_test.exs +++ b/test/livebook/runtime/mix_standalone_test.exs @@ -11,8 +11,8 @@ defmodule Livebook.Runtime.MixStandaloneTest do ref = emitter.ref # Wait for the Mix setup to finish and for node initialization - assert_receive {:emitter, ^ref, {:output, "Running mix deps.get...\n"}}, 5_000 - assert_receive {:emitter, ^ref, {:ok, runtime}}, 5_000 + assert_receive {:emitter, ^ref, {:output, "Running mix deps.get...\n"}}, 8_000 + assert_receive {:emitter, ^ref, {:ok, runtime}}, 8_000 Runtime.connect(runtime) %{node: node} = runtime