Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile variant for clustered deployment on Fly.io #2286

Merged
merged 8 commits into from
Oct 22, 2023

Conversation

jonatanklosko
Copy link
Member

Preview

image

There is still an issue related to booting apps that I need to address.

@github-actions
Copy link

github-actions bot commented Oct 18, 2023

Uffizzi Preview deployment-38881 was deleted.

lib/livebook/config.ex Outdated Show resolved Hide resolved
~S"""
# Custom startup script to cluster multiple Livebook nodes
RUN printf '#!/bin/bash\n\
export ERL_AFLAGS="-proto_dist inet6_tcp"\n\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we move the static variables out of the script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason? If we could move them all that would make sense, but since LIVEBOOK_NODE is runtime, I would keep together for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to keep only runtime ones in the runtime script. Also, any thoughts in an approach like this?

ENV ERL_AFLAGS "-proto_dist inet6_tcp"
ENV LIVEBOOK_DISTRIBUTION name
CMD [ 'sh', '-c' , 'LIVEBOOK_NODE="${FLY_APP_NAME}-${FLY_IMAGE_REF##*-}@${FLY_PRIVATE_IP}" LIVEBOOK_CLUSTER="dns:${FLY_APP_NAME}.internal" /app/bin/livebook start']

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to keep only runtime ones in the runtime script.

Yeah, the practical difference is whether the env vars are set globally, which I don't think they necessarily should be? Also, normally all of these would go to env.sh.eex, that's why I prefer to keep them together.

I considered CMD, which we could even break it into multiple lines, but what I like about creating a startup file is that usually you'd have that file alongside and COPY it, so it's the closest to that (and if the user wants to do that, it's easy). Also for CMD you actually must use double quotes, because because technically it is parsed as a JSON array 🙈

# Custom startup script to cluster multiple Livebook nodes on Fly.io
RUN printf '\
#!/bin/bash\n\
export ERL_AFLAGS="-proto_dist inet6_tcp"\n\
export LIVEBOOK_DISTRIBUTION="name"\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 [ "/app/bin/start.sh" ]

vs

# Custom startup script to cluster multiple Livebook nodes on Fly.io
CMD [ "sh", "-c" , "\
  ERL_AFLAGS=\"-proto_dist inet6_tcp\" \
  LIVEBOOK_DISTRIBUTION=\"name\" \
  LIVEBOOK_NODE=\"${FLY_APP_NAME}-${FLY_IMAGE_REF##*-}@${FLY_PRIVATE_IP}\" \
  LIVEBOOK_CLUSTER=\"dns:${FLY_APP_NAME}.internal\" \
  /app/bin/livebook start" ]

@jonatanklosko jonatanklosko merged commit 06b5532 into main Oct 22, 2023
7 checks passed
@jonatanklosko jonatanklosko deleted the jk-cluster branch October 22, 2023 15:23
jonatanklosko added a commit that referenced this pull request Oct 22, 2023
Co-authored-by: José Valim <jose.valim@dashbit.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants