Skip to content

Commit

Permalink
Fix Docker warning about deprecated ENV usage (#2893)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamez authored Dec 12, 2024
1 parent 8694330 commit cd46b5c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions docs/deployment/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ You can deploy Livebook inside your infrastructure using Docker. The Dockerfile
FROM ghcr.io/livebook-dev/livebook

# Configure your port accordingly
ENV LIVEBOOK_PORT 7860
ENV LIVEBOOK_PORT=7860
EXPOSE 7860

# If you have a persistent volume, configure it here
ENV LIVEBOOK_DATA_PATH "/data"
ENV LIVEBOOK_DATA_PATH="/data"
USER root
RUN mkdir -p /data
RUN chmod 777 /data
Expand Down Expand Up @@ -147,4 +147,4 @@ If you are using [Livebook Teams](https://livebook.dev/teams/), you can also dep

The deployment steps will show you to deploy your notebooks within Docker, Fly.io, and Kubernetes. This is effectively done by setting the `LIVEBOOK_TEAMS_AUTH`, which configures Livebook to run as a read-only instance connected to Livebook Teams.

Livebook Teams also support airgapped deployments, pre-configured environment variables, shared team secrets, file storages, and more.
Livebook Teams also support airgapped deployments, pre-configured environment variables, shared team secrets, file storages, and more.
2 changes: 1 addition & 1 deletion docs/deployment/fips.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To do this in Docker, you will need to build it differently. Below is an example
```docker
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9-1137
# Set environment variables for path and language
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Install system dependencies and clean cache in one layer
RUN microdnf install -y unzip autoconf git ncurses-devel openssl-devel gcc gcc-c++ make automake perl clang wget tar cmake glibc-locale-source glibc-langpack-en && \
Expand Down
28 changes: 14 additions & 14 deletions lib/livebook/hubs/dockerfile.ex
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,18 @@ defmodule Livebook.Hubs.Dockerfile do
"auto" ->
"""
# Clustering configuration (note that we need the same Livebook secrets across all nodes)
ENV LIVEBOOK_CLUSTER "auto"
ENV LIVEBOOK_SECRET_KEY_BASE "#{secret_key_base}"
ENV LIVEBOOK_COOKIE "#{cookie}"
ENV LIVEBOOK_CLUSTER="auto"
ENV LIVEBOOK_SECRET_KEY_BASE="#{secret_key_base}"
ENV LIVEBOOK_COOKIE="#{cookie}"
"""

"dns" ->
"""
# Clustering configuration (note that we need the same Livebook secrets across all nodes)
ENV LIVEBOOK_NODE "livebook_server@MACHINE_IP"
ENV LIVEBOOK_CLUSTER "dns:QUERY"
ENV LIVEBOOK_SECRET_KEY_BASE "#{secret_key_base}"
ENV LIVEBOOK_COOKIE "#{cookie}"
ENV LIVEBOOK_NODE="livebook_server@MACHINE_IP"
ENV LIVEBOOK_CLUSTER="dns:QUERY"
ENV LIVEBOOK_SECRET_KEY_BASE="#{secret_key_base}"
ENV LIVEBOOK_COOKIE="#{cookie}"
"""

_ ->
Expand All @@ -135,8 +135,8 @@ defmodule Livebook.Hubs.Dockerfile do

apps_config = """
# Apps configuration
ENV LIVEBOOK_APPS_PATH "/apps"
ENV LIVEBOOK_APPS_PATH_WARMUP "manual"
ENV LIVEBOOK_APPS_PATH="/apps"
ENV LIVEBOOK_APPS_PATH_WARMUP="manual"
"""

notebook =
Expand Down Expand Up @@ -210,21 +210,21 @@ defmodule Livebook.Hubs.Dockerfile do
ARG TEAMS_KEY="#{hub.teams_key}"
# Teams Hub configuration for airgapped deployment
ENV LIVEBOOK_TEAMS_KEY ${TEAMS_KEY}
ENV LIVEBOOK_TEAMS_AUTH "offline:#{hub.hub_name}:#{hub.org_public_key}"
ENV LIVEBOOK_TEAMS_KEY=${TEAMS_KEY}
ENV LIVEBOOK_TEAMS_AUTH="offline:#{hub.hub_name}:#{hub.org_public_key}"
"""

secrets =
if used_secrets != [] do
"""
ENV LIVEBOOK_TEAMS_SECRETS "#{encrypt_secrets_to_dockerfile(used_secrets, hub)}"
ENV LIVEBOOK_TEAMS_SECRETS="#{encrypt_secrets_to_dockerfile(used_secrets, hub)}"
"""
end

file_systems =
if hub_file_systems != [] do
"""
ENV LIVEBOOK_TEAMS_FS "#{encrypt_file_systems_to_dockerfile(hub_file_systems, hub)}"
ENV LIVEBOOK_TEAMS_FS="#{encrypt_file_systems_to_dockerfile(hub_file_systems, hub)}"
"""
end

Expand All @@ -248,7 +248,7 @@ defmodule Livebook.Hubs.Dockerfile do

defp format_envs(list) do
Enum.map_join(list, fn {key, value} ->
~s/ENV #{key} "#{String.replace(value, ~S["], ~S[\"])}"\n/
~s/ENV #{key}="#{String.replace(value, ~S["], ~S[\"])}"\n/
end)
end

Expand Down
30 changes: 15 additions & 15 deletions test/livebook/hubs/dockerfile_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ defmodule Livebook.Hubs.DockerfileTest do
FROM ghcr.io/livebook-dev/livebook:#{@version}
# Apps configuration
ENV LIVEBOOK_APPS_PATH "/apps"
ENV LIVEBOOK_APPS_PATH_WARMUP "manual"
ENV LIVEBOOK_APPS_PATH="/apps"
ENV LIVEBOOK_APPS_PATH_WARMUP="manual"
# Notebook
COPY notebook.livemd /apps/
Expand All @@ -48,7 +48,7 @@ defmodule Livebook.Hubs.DockerfileTest do
assert dockerfile =~
"""
# Personal Hub secrets
ENV LB_TEST "test"
ENV LB_TEST="test"
"""

refute dockerfile =~ "ENV LB_SESSION"
Expand Down Expand Up @@ -81,8 +81,8 @@ defmodule Livebook.Hubs.DockerfileTest do
assert dockerfile =~
"""
# Personal Hub secrets
ENV LB_TEST "test"
ENV LB_TEST2 "test"
ENV LB_TEST="test"
ENV LB_TEST2="test"
"""

refute dockerfile =~ "ENV LB_SESSION"
Expand All @@ -101,12 +101,12 @@ defmodule Livebook.Hubs.DockerfileTest do
ARG TEAMS_KEY="lb_tk_fn0pL3YLWzPoPFWuHeV3kd0o7_SFuIOoU4C_k6OWDYg"
# Teams Hub configuration for airgapped deployment
ENV LIVEBOOK_TEAMS_KEY ${TEAMS_KEY}
ENV LIVEBOOK_TEAMS_AUTH "offline:org-name-387:lb_opk_fpxnp3r5djwxnmirx3tu276hialoivf3"
ENV LIVEBOOK_TEAMS_KEY=${TEAMS_KEY}
ENV LIVEBOOK_TEAMS_AUTH="offline:org-name-387:lb_opk_fpxnp3r5djwxnmirx3tu276hialoivf3"
# Apps configuration
ENV LIVEBOOK_APPS_PATH "/apps"
ENV LIVEBOOK_APPS_PATH_WARMUP "manual"
ENV LIVEBOOK_APPS_PATH="/apps"
ENV LIVEBOOK_APPS_PATH_WARMUP="manual"
# Notebook
COPY notebook.livemd /apps/
Expand Down Expand Up @@ -191,7 +191,7 @@ defmodule Livebook.Hubs.DockerfileTest do

dockerfile = Dockerfile.airgapped_dockerfile(config, hub, [], [], file, [], %{})

assert dockerfile =~ ~s/ENV LIVEBOOK_CLUSTER "auto"/
assert dockerfile =~ ~s/ENV LIVEBOOK_CLUSTER="auto"/
end

test "deploying with dns cluster setup" do
Expand All @@ -201,8 +201,8 @@ defmodule Livebook.Hubs.DockerfileTest do

dockerfile = Dockerfile.airgapped_dockerfile(config, hub, [], [], file, [], %{})

assert dockerfile =~ ~s/ENV LIVEBOOK_NODE "livebook_server@MACHINE_IP"/
assert dockerfile =~ ~s/ENV LIVEBOOK_CLUSTER "dns:QUERY"/
assert dockerfile =~ ~s/ENV LIVEBOOK_NODE="livebook_server@MACHINE_IP"/
assert dockerfile =~ ~s/ENV LIVEBOOK_CLUSTER="dns:QUERY"/
end

test "deploying with deployment group environment variables" do
Expand All @@ -222,9 +222,9 @@ defmodule Livebook.Hubs.DockerfileTest do

assert dockerfile =~ """
# Deployment group environment variables
ENV LIVEBOOK_IDENTITY_PROVIDER "cloudflare:foobar"
ENV LIVEBOOK_TEAMS_URL "http://localhost:8000"
ENV MY_JSON "{\\"foo\\": \\"bar\\"}"\
ENV LIVEBOOK_IDENTITY_PROVIDER="cloudflare:foobar"
ENV LIVEBOOK_TEAMS_URL="http://localhost:8000"
ENV MY_JSON="{\\"foo\\": \\"bar\\"}"\
"""
end
end
Expand Down

0 comments on commit cd46b5c

Please sign in to comment.