-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Add reproducible build profile and Dockerfile #42
Conversation
I see you don't use release defaults (https://doc.rust-lang.org/cargo/reference/profiles.html):
I'm worried about behavior change. Are you 100% sure about each item? eg: overflow-checks, panic. |
agree with Dan about there being a bunch of items. imo the fewer changes the better! which ones are absolutely necessary? |
good point, I will test again with the release profile without changes and see if the reproducibility still holds. |
Dockerfile
Outdated
ENV BUILD_PROFILE=$BUILD_PROFILE | ||
|
||
# Extra Cargo flags | ||
ARG RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-Wl,--build-id=none -Clink-arg=-static-libgcc -C metadata='' --remap-path-prefix $(pwd)=." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be too much to ask to break out each flag into it's own line, with a comment what it does? like in mev-boost here: https://github.com/flashbots/mev-boost/blob/develop/Makefile#L4-L15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can do that there too
Dockerfile
Outdated
# RUSTFLAGS breakdown: | ||
# -C target-feature=+crt-static -> Statically link the C runtime library for standalone binaries | ||
# -C link-arg=-Wl,--build-id=none -> Remove build ID from binary for reproducibility | ||
# -Clink-arg=-static-libgcc -> Statically link against libgcc | ||
# -C metadata='' -> Remove metadata hash from symbol names for reproducible builds | ||
# --remap-path-prefix $(pwd)=. -> Replace absolute paths with '.' in debug info | ||
ARG RUSTFLAGS="-C target-feature=+crt-static \ | ||
-C link-arg=-Wl,--build-id=none \ | ||
-Clink-arg=-static-libgcc \ | ||
-C metadata='' \ | ||
--remap-path-prefix $(pwd)=." | ||
ENV RUSTFLAGS="$RUSTFLAGS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# RUSTFLAGS breakdown: | |
# -C target-feature=+crt-static -> Statically link the C runtime library for standalone binaries | |
# -C link-arg=-Wl,--build-id=none -> Remove build ID from binary for reproducibility | |
# -Clink-arg=-static-libgcc -> Statically link against libgcc | |
# -C metadata='' -> Remove metadata hash from symbol names for reproducible builds | |
# --remap-path-prefix $(pwd)=. -> Replace absolute paths with '.' in debug info | |
ARG RUSTFLAGS="-C target-feature=+crt-static \ | |
-C link-arg=-Wl,--build-id=none \ | |
-Clink-arg=-static-libgcc \ | |
-C metadata='' \ | |
--remap-path-prefix $(pwd)=." | |
ENV RUSTFLAGS="$RUSTFLAGS" | |
ARG RUSTFLAGS="-C target-feature=+crt-static \ # Statically link the C runtime library for standalone binaries | |
-C link-arg=-Wl,--build-id=none \ # Remove build ID from binary for reproducibility | |
-Clink-arg=-static-libgcc \ # Statically link against libgcc | |
-C metadata='' \ # Remove metadata hash from symbol names for reproducible builds | |
--remap-path-prefix $(pwd)=." # Replace absolute paths with '.' in debug info | |
ENV RUSTFLAGS="$RUSTFLAGS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesnt work in Docker
You cant have inline comments there. Thats why I pulled them outside of it.
However, this is possible
ARG RUSTFLAGS="\
# Statically link the C runtime library for standalone binaries
-C target-feature=+crt-static \
# Remove build ID from binary for reproducibility
-C link-arg=-Wl,--build-id=none \
# Statically link against libgcc
-Clink-arg=-static-libgcc \
# Remove metadata hash from symbol names for reproducible builds
-C metadata='' \
# Replace absolute paths with '.' in debug info
--remap-path-prefix $(pwd)=."
ENV RUSTFLAGS="$RUSTFLAGS"
* feat: add extra job for the reproducible docker build in the CI * remove the extra Cargo.toml profiles * add comments to the rust flags and move them into Makefile * Add comments to the rust flags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
One implementation detail that I don't particularly like is duplication of flags in both Dockerfile and Makefile. One would need to keep them in sync to match the behavior of Docker build vs make build-reproducible
.
Maybe in the future we can move them to an externally managed profile.
This PR adds a reproducible build profile and a Dockerfile that will build the binary reproducibly and puts it in a distroless minimal base image.
This will later be used in the BuilderNet v1.3 where most services will run in containers.
Steps to test: