2023-11-10 20:58:21 +08:00
|
|
|
if System.otp_release() < "25" do
|
|
|
|
Mix.raise("Livebook requires Erlang/OTP 25+")
|
|
|
|
end
|
|
|
|
|
2021-03-04 05:56:28 +08:00
|
|
|
defmodule Livebook.MixProject do
|
2021-01-08 03:55:45 +08:00
|
|
|
use Mix.Project
|
|
|
|
|
2023-10-25 15:44:09 +08:00
|
|
|
@elixir_requirement "~> 1.15.2 or ~> 1.16-dev"
|
2023-10-10 01:12:24 +08:00
|
|
|
@version "0.12.0-dev"
|
2023-03-20 01:51:23 +08:00
|
|
|
@description "Automate code & data workflows with interactive notebooks"
|
2021-05-20 05:30:53 +08:00
|
|
|
|
2021-01-08 03:55:45 +08:00
|
|
|
def project do
|
|
|
|
[
|
2021-03-04 05:56:28 +08:00
|
|
|
app: :livebook,
|
2021-05-20 05:30:53 +08:00
|
|
|
version: @version,
|
2022-01-27 21:52:59 +08:00
|
|
|
elixir: @elixir_requirement,
|
2021-05-20 05:30:53 +08:00
|
|
|
name: "Livebook",
|
|
|
|
description: @description,
|
2021-01-08 03:55:45 +08:00
|
|
|
elixirc_paths: elixirc_paths(Mix.env()),
|
2022-11-10 23:37:57 +08:00
|
|
|
test_elixirc_options: [docs: true],
|
2021-01-08 03:55:45 +08:00
|
|
|
start_permanent: Mix.env() == :prod,
|
|
|
|
aliases: aliases(),
|
2022-01-20 05:20:05 +08:00
|
|
|
deps: with_lock(target_deps(Mix.target()) ++ deps()),
|
2021-04-27 22:34:02 +08:00
|
|
|
escript: escript(),
|
2022-01-27 21:52:59 +08:00
|
|
|
package: package(),
|
2022-01-20 19:00:06 +08:00
|
|
|
default_release: :livebook,
|
2023-09-21 16:35:26 +08:00
|
|
|
releases: releases(),
|
|
|
|
|
|
|
|
# Docs
|
|
|
|
homepage_url: "https://livebook.dev",
|
|
|
|
docs: docs()
|
2021-01-08 03:55:45 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def application do
|
|
|
|
[
|
2021-03-04 05:56:28 +08:00
|
|
|
mod: {Livebook.Application, []},
|
2023-06-10 02:59:04 +08:00
|
|
|
extra_applications: [
|
|
|
|
:logger,
|
|
|
|
:runtime_tools,
|
|
|
|
:os_mon,
|
|
|
|
:inets,
|
|
|
|
:ssl,
|
|
|
|
:xmerl,
|
|
|
|
:crypto,
|
|
|
|
:public_key
|
|
|
|
],
|
2021-10-05 06:49:01 +08:00
|
|
|
env: Application.get_all_env(:livebook)
|
2021-01-08 03:55:45 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2022-11-04 00:49:07 +08:00
|
|
|
defp elixirc_paths(:test), do: elixirc_paths(:dev) ++ ["test/support"]
|
|
|
|
defp elixirc_paths(_), do: ["lib", "proto/lib"]
|
2021-01-08 03:55:45 +08:00
|
|
|
|
2022-01-27 21:52:59 +08:00
|
|
|
defp package do
|
|
|
|
[
|
|
|
|
licenses: ["Apache-2.0"],
|
|
|
|
links: %{
|
|
|
|
"GitHub" => "https://github.com/livebook-dev/livebook"
|
|
|
|
},
|
2022-05-06 16:28:01 +08:00
|
|
|
files:
|
2022-11-04 00:49:07 +08:00
|
|
|
~w(lib static config mix.exs mix.lock README.md LICENSE CHANGELOG.md iframe/priv/static/iframe proto/lib)
|
2022-01-27 21:52:59 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
defp aliases do
|
|
|
|
[
|
2023-05-27 15:04:52 +08:00
|
|
|
setup: ["deps.get", "cmd npm install --prefix assets"],
|
|
|
|
"assets.deploy": ["cmd npm run deploy --prefix assets"],
|
|
|
|
"format.all": ["format", "cmd npm run format --prefix assets"],
|
2022-11-04 00:49:07 +08:00
|
|
|
"protobuf.generate": ["cmd --cd proto mix protobuf.generate"]
|
2022-01-27 21:52:59 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
defp escript do
|
|
|
|
[
|
|
|
|
main_module: LivebookCLI,
|
|
|
|
app: nil
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
2021-08-25 17:52:41 +08:00
|
|
|
# Although we use requirements here, the with_lock() function
|
|
|
|
# below ensures we only use the locked versions. This is important
|
|
|
|
# for two reasons:
|
|
|
|
#
|
|
|
|
# 1. because we bundle assets from phoenix, phoenix_live_view,
|
|
|
|
# and phoenix_html, we want to make sure we have those exact
|
|
|
|
# versions
|
|
|
|
#
|
|
|
|
# 2. we don't want users to potentially get a new dependency
|
|
|
|
# when installing from git or as an escript
|
|
|
|
#
|
|
|
|
# Therefore, to update any dependency, you must call before:
|
|
|
|
#
|
|
|
|
# mix deps.unlock foo bar baz
|
|
|
|
#
|
2021-01-08 03:55:45 +08:00
|
|
|
defp deps do
|
|
|
|
[
|
2023-10-09 22:49:07 +08:00
|
|
|
{:phoenix, "~> 1.7.8"},
|
2023-10-28 02:49:46 +08:00
|
|
|
# {:phoenix_live_view, "~> 0.20.1"},
|
|
|
|
{:phoenix_live_view, github: "phoenixframework/phoenix_live_view", override: true},
|
2023-10-06 18:10:36 +08:00
|
|
|
{:phoenix_html, "~> 3.0"},
|
2023-06-07 18:30:52 +08:00
|
|
|
{:phoenix_live_dashboard, "~> 0.8.0"},
|
2021-01-08 03:55:45 +08:00
|
|
|
{:telemetry_metrics, "~> 0.4"},
|
2021-12-12 16:40:38 +08:00
|
|
|
{:telemetry_poller, "~> 1.0"},
|
2021-01-08 03:55:45 +08:00
|
|
|
{:jason, "~> 1.0"},
|
2023-10-31 23:36:45 +08:00
|
|
|
{:bandit, "~> 1.0"},
|
2023-10-06 18:10:36 +08:00
|
|
|
{:plug_crypto, "~> 2.0"},
|
2021-08-12 20:40:07 +08:00
|
|
|
{:earmark_parser, "~> 1.4"},
|
2023-04-13 18:46:56 +08:00
|
|
|
{:ecto, "~> 3.10"},
|
|
|
|
{:phoenix_ecto, "~> 4.4"},
|
2023-11-16 20:57:28 +08:00
|
|
|
{:aws_credentials, "~> 0.1.11", runtime: false},
|
2022-08-02 21:26:45 +08:00
|
|
|
{:aws_signature, "~> 0.3.0"},
|
2022-11-04 00:49:07 +08:00
|
|
|
{:mint_web_socket, "~> 1.0.0"},
|
|
|
|
{:protobuf, "~> 0.8.0"},
|
2023-10-22 23:23:15 +08:00
|
|
|
{:dns_cluster, "~> 0.1.1"},
|
2021-08-25 17:52:41 +08:00
|
|
|
{:phoenix_live_reload, "~> 1.2", only: :dev},
|
|
|
|
{:floki, ">= 0.27.0", only: :test},
|
2023-06-21 06:25:25 +08:00
|
|
|
{:bypass, "~> 2.1", only: :test},
|
|
|
|
# ZTA deps
|
|
|
|
{:jose, "~> 1.11.5"},
|
2023-10-06 21:49:10 +08:00
|
|
|
{:req, "~> 0.4.4"},
|
2023-09-21 16:35:26 +08:00
|
|
|
# Docs
|
|
|
|
{:ex_doc, "~> 0.30", only: :dev, runtime: false}
|
2021-01-08 03:55:45 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2023-01-17 04:09:47 +08:00
|
|
|
defp target_deps(:app), do: [{:elixirkit, path: "elixirkit"}]
|
2022-01-20 05:20:05 +08:00
|
|
|
defp target_deps(_), do: []
|
|
|
|
|
2021-08-25 17:52:41 +08:00
|
|
|
@lock (with {:ok, contents} <- File.read("mix.lock"),
|
2023-11-08 14:42:39 +08:00
|
|
|
{:ok, quoted} <-
|
|
|
|
Code.string_to_quoted(contents,
|
|
|
|
warn_on_unnecessary_quotes: false,
|
|
|
|
emit_warnings: false
|
|
|
|
),
|
2021-08-25 17:52:41 +08:00
|
|
|
{%{} = lock, _binding} <- Code.eval_quoted(quoted, []) do
|
|
|
|
for {dep, hex} when elem(hex, 0) == :hex <- lock,
|
|
|
|
do: {dep, elem(hex, 2)},
|
|
|
|
into: %{}
|
|
|
|
else
|
|
|
|
_ -> %{}
|
|
|
|
end)
|
|
|
|
|
|
|
|
defp with_lock(deps) do
|
|
|
|
for dep <- deps do
|
|
|
|
name = elem(dep, 0)
|
|
|
|
put_elem(dep, 1, @lock[name] || elem(dep, 1))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-27 21:52:59 +08:00
|
|
|
## Releases
|
2021-04-27 22:34:02 +08:00
|
|
|
|
2023-11-17 00:54:34 +08:00
|
|
|
# aws_credentials has runtime: false, so explicitly add is as :load
|
|
|
|
@release_apps [livebook: :permanent, aws_credentials: :load]
|
|
|
|
|
2021-05-20 05:30:53 +08:00
|
|
|
defp releases do
|
2021-04-27 22:34:02 +08:00
|
|
|
[
|
|
|
|
livebook: [
|
2023-11-17 00:54:34 +08:00
|
|
|
applications: @release_apps,
|
2023-02-02 04:22:49 +08:00
|
|
|
include_executables_for: [:unix, :windows],
|
2022-01-27 21:52:59 +08:00
|
|
|
include_erts: false,
|
|
|
|
rel_templates_path: "rel/server",
|
|
|
|
steps: [:assemble, &remove_cookie/1]
|
2022-01-18 00:34:38 +08:00
|
|
|
],
|
2022-06-02 04:29:54 +08:00
|
|
|
app: [
|
2023-11-17 00:54:34 +08:00
|
|
|
applications: @release_apps,
|
2022-03-02 19:06:30 +08:00
|
|
|
include_erts: false,
|
|
|
|
rel_templates_path: "rel/app",
|
|
|
|
steps: [
|
|
|
|
:assemble,
|
|
|
|
&remove_cookie/1,
|
2023-01-17 04:09:47 +08:00
|
|
|
&standalone_erlang_elixir/1
|
2022-03-02 19:06:30 +08:00
|
|
|
]
|
2021-04-27 22:34:02 +08:00
|
|
|
]
|
|
|
|
]
|
|
|
|
end
|
2021-05-20 05:30:53 +08:00
|
|
|
|
2022-01-27 21:52:59 +08:00
|
|
|
defp remove_cookie(release) do
|
|
|
|
File.rm!(Path.join(release.path, "releases/COOKIE"))
|
|
|
|
release
|
|
|
|
end
|
|
|
|
|
2023-02-04 01:30:41 +08:00
|
|
|
@compile {:no_warn_undefined, Standalone}
|
|
|
|
|
2022-01-27 21:52:59 +08:00
|
|
|
defp standalone_erlang_elixir(release) do
|
2023-06-15 18:49:48 +08:00
|
|
|
{_, bindings} = Code.eval_file("versions")
|
|
|
|
elixir_version = bindings[:elixir]
|
|
|
|
rebar3_version = bindings[:rebar3]
|
|
|
|
|
2022-01-27 21:52:59 +08:00
|
|
|
Code.require_file("rel/app/standalone.exs")
|
|
|
|
|
|
|
|
release
|
2022-05-07 05:53:10 +08:00
|
|
|
|> Standalone.copy_otp()
|
2023-06-15 18:49:48 +08:00
|
|
|
|> Standalone.copy_elixir(elixir_version)
|
2022-07-18 17:51:17 +08:00
|
|
|
|> Standalone.copy_hex()
|
2023-06-15 18:49:48 +08:00
|
|
|
|> Standalone.copy_rebar3(rebar3_version)
|
2022-01-27 21:52:59 +08:00
|
|
|
end
|
2023-09-21 16:35:26 +08:00
|
|
|
|
|
|
|
defp docs() do
|
|
|
|
[
|
|
|
|
logo: "static/images/logo.png",
|
2023-09-21 17:21:50 +08:00
|
|
|
main: "readme",
|
2023-09-21 16:35:26 +08:00
|
|
|
api_reference: false,
|
2023-09-21 18:28:45 +08:00
|
|
|
extra_section: "Guides",
|
2023-09-21 16:35:26 +08:00
|
|
|
extras: extras(),
|
2023-09-21 18:28:45 +08:00
|
|
|
filter_modules: fn mod, _ -> mod in [Livebook] end,
|
2023-11-02 02:55:12 +08:00
|
|
|
assets: Path.expand("./docs/images"),
|
2023-09-21 16:35:26 +08:00
|
|
|
groups_for_extras: [
|
2023-11-02 02:55:12 +08:00
|
|
|
"Livebook Teams": Path.wildcard("docs/teams/*"),
|
2023-09-21 17:21:50 +08:00
|
|
|
Deployment: Path.wildcard("docs/deployment/*")
|
2023-09-21 16:35:26 +08:00
|
|
|
]
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
defp extras() do
|
|
|
|
[
|
2023-10-25 05:47:34 +08:00
|
|
|
{"README.md", title: "Welcome to Livebook"},
|
2023-09-21 17:21:50 +08:00
|
|
|
"docs/authentication.md",
|
|
|
|
"docs/deployment/docker.md",
|
|
|
|
"docs/deployment/cloudflare.md",
|
|
|
|
"docs/deployment/google_iap.md",
|
2023-11-02 02:55:12 +08:00
|
|
|
"docs/deployment/tailscale.md",
|
2023-11-10 22:03:59 +08:00
|
|
|
"docs/teams/intro_to_teams.md",
|
|
|
|
"docs/teams/shared_secrets.md",
|
|
|
|
"docs/teams/shared_file_storages.md"
|
2023-09-21 16:35:26 +08:00
|
|
|
]
|
|
|
|
end
|
2021-01-08 03:55:45 +08:00
|
|
|
end
|