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

refactor: update docker images to use cargo-chef #1619

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

KolbyML
Copy link
Member

@KolbyML KolbyML commented Jan 6, 2025

What was wrong?

@njgheorghita brought up a concern that #1615 (comment) with my PR to update how we get the client info, to use vergen instead of shadow-rs #1615 that our docker images would no longer get the right git commitment.

He brought up a very good point! The way our dockerfiles were setup vergen wouldn't work properly.

How was it fixed?

Remove the requirement to pass GITHASH to the docker build, by copying the whole working directory, since then the working directory has access to the .git folder, we no longer need to pass it in.

Another thing is now we don't need to update our dockerfile everytime we add a new crate, which will improve maintainability.

Because we are now copying the whole workspace, to not lose caching performance I added cargo-chef (which reth uses) which will changes more info can be found at https://github.com/LukeMathWalker/cargo-chef

I tested these changes locally with #1615 and it works
image

@@ -66,7 +66,7 @@ jobs:
- run:
name: Build Docker image
no_output_timeout: 30m
command: docker build -f ./docker/Dockerfile -t $IMAGE_NAME:latest --build-arg GIT_HASH=$CIRCLE_SHA1 .
command: docker build -f ./docker/Dockerfile -t $IMAGE_NAME:latest
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe I'm missing where this happens, but are you sure we have git initialized at this point? Otherwise there's no .git folder for docker to pick up

Copy link
Member Author

@KolbyML KolbyML Jan 7, 2025

Choose a reason for hiding this comment

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

This PR won't work without #1615 if you are testing

I plan to merge them at the same time so it shouldn't be a issue.

Yes the .git folder is initalized

https://circleci.com/docs/configuration-reference/#checkout

^ CircleCI just does git commands to pull changes and such

image

Copy link
Member Author

Choose a reason for hiding this comment

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

CircleCI does a git clone or git fetch depending on circumstances so the .git would be initialized if that was the case

COPY --from=builder /trin/target/release/portal-bridge /usr/bin/
COPY --from=builder /trin/target/release/sample_range /usr/bin/
COPY --from=builder /trin/target/release/poll_latest /usr/bin/

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit remove this newline


# final base
FROM ubuntu:22.04
# Build application
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit maybe leave a comment here referencing the .dockerignore so that people know where to go and include a folder if a new workspace is created...
eg. Copy over all project folders specified in the .dockerignore or something like that

@KolbyML KolbyML merged commit b1de71d into ethereum:master Jan 7, 2025
9 checks passed
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.

2 participants