diff --git a/README.md b/README.md index 1f1c563ee..e4e57cda1 100644 --- a/README.md +++ b/README.md @@ -346,6 +346,11 @@ When clustering is enabled, you must additionally set the following env vars: `LIVEBOOK_DISTRIBUTION` is automatically set to `name` if clustering is enabled. +Some variables, like `LIVEBOOK_NODE`, are oftentimes computed at runtime. +When using the Livebook Docker image, you can create a file at `/app/env.sh` +that exports the necessary environment variables. This file is invoked right +before booting Livebook. + ## Development Livebook is primarily a Phoenix web application and can be setup as such: diff --git a/lib/livebook/hubs/dockerfile.ex b/lib/livebook/hubs/dockerfile.ex index 13f29b69f..178995976 100644 --- a/lib/livebook/hubs/dockerfile.ex +++ b/lib/livebook/hubs/dockerfile.ex @@ -130,16 +130,12 @@ defmodule Livebook.Hubs.Dockerfile do """ <> ~S""" - # Custom startup script to cluster multiple Livebook nodes on Fly.io + # Runtime configuration to cluster multiple Livebook nodes on Fly.io RUN printf '\ - #!/bin/bash\n\ export ERL_AFLAGS="-proto_dist inet6_tcp"\n\ export LIVEBOOK_NODE="${FLY_APP_NAME}-${FLY_IMAGE_REF##*-}@${FLY_PRIVATE_IP}"\n\ export LIVEBOOK_CLUSTER="dns:${FLY_APP_NAME}.internal"\n\ - /app/bin/livebook start\n\ - ' > /app/bin/start.sh && chmod +x /app/bin/start.sh - - CMD [ "sh", "-c", "/app/bin/start.sh" ] + ' > /app/env.sh """ end diff --git a/rel/server/env.bat.eex b/rel/server/env.bat.eex index 7552c471a..5866e8dc7 100644 --- a/rel/server/env.bat.eex +++ b/rel/server/env.bat.eex @@ -1,3 +1,7 @@ +if exist "!RELEASE_ROOT!\env.bat" ( + call "!RELEASE_ROOT!\env.bat" +) + set RELEASE_MODE=interactive if defined LIVEBOOK_NODE set RELEASE_NODE="!LIVEBOOK_NODE!" if not defined RELEASE_NODE set RELEASE_NODE=livebook_server diff --git a/rel/server/env.sh.eex b/rel/server/env.sh.eex index d7b2cbc5d..f9b3830a5 100644 --- a/rel/server/env.sh.eex +++ b/rel/server/env.sh.eex @@ -1,3 +1,7 @@ +if [ -f "${RELEASE_ROOT}/env.sh" ]; then + . "${RELEASE_ROOT}/env.sh" +fi + export RELEASE_MODE=interactive export RELEASE_NODE=${LIVEBOOK_NODE:-${RELEASE_NODE:-livebook_server}} if [ -z "${LIVEBOOK_CLUSTER}" ]; then DISTRIBUTION_DEFAULT="sname"; else DISTRIBUTION_DEFAULT="name"; fi