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

perf: improve Dockerfile caching #1053

Merged
merged 1 commit into from
Apr 30, 2024
Merged

Conversation

MegaRedHand
Copy link
Collaborator

This PR improves docker build caching by pre-compiling Rust NIFs and mix dependencies, before copying the whole repo.

@MegaRedHand MegaRedHand requested a review from a team as a code owner April 26, 2024 20:16
@MegaRedHand MegaRedHand self-assigned this Apr 26, 2024

# Precompile elixir dependencies
COPY mix.exs mix.lock .fork_version ./
COPY ./config/config.exs /consensus/config/config.exs
Copy link
Collaborator

Choose a reason for hiding this comment

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

didn't know this file is read when compiling dependencies, but it makes sense

# Precompile rust crates. Rustler stores targets under _build
COPY ./native /consensus/native
RUN cd /consensus/native/bls_nif && cargo build --release \
--target-dir="/consensus/_build/prod/lib/lambda_ethereum_consensus/native/bls_nif"
Copy link
Collaborator

@mpaulucci mpaulucci Apr 29, 2024

Choose a reason for hiding this comment

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

I think technically we should do mix release at the end and then this path would change. Wonder if we have another way the doesn't involver hardcoding this path.

I've been doing a small poc of doing mix release and then executing the binary directly instead of iex but the problem is that it doesn't recognize the cli for a reason.

This is what chatGPT said on the matter xD.

Direct CLI Arguments with start
The ./bin/app start command for a release typically does not support passing custom CLI arguments directly to the application's code because it starts the application in the background without an attached shell. This mode is meant for production where direct terminal interaction is not common. Instead, configurations are often managed through environment variables or external configuration files, as previously mentioned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also tried that and apparently, only env vars reach the depths of the runtime.exs script.

Copy link
Collaborator

Choose a reason for hiding this comment

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

weird..

@MegaRedHand MegaRedHand merged commit a3d749a into main Apr 30, 2024
13 checks passed
@MegaRedHand MegaRedHand deleted the improve-dockerfile-caching branch April 30, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants