mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: Add reproducible build profile (#10459)
Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com> Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
This commit is contained in:
@ -288,6 +288,13 @@ codegen-units = 1
|
||||
inherits = "release"
|
||||
lto = "fat"
|
||||
|
||||
[profile.reproducible]
|
||||
inherits = "release"
|
||||
debug = false
|
||||
panic = "abort"
|
||||
codegen-units = 1
|
||||
overflow-checks = true
|
||||
|
||||
[workspace.dependencies]
|
||||
# reth
|
||||
op-reth = { path = "crates/optimism/bin" }
|
||||
|
||||
37
Dockerfile.reproducible
Normal file
37
Dockerfile.reproducible
Normal file
@ -0,0 +1,37 @@
|
||||
# Use the Rust 1.82 image based on Debian Bullseye
|
||||
FROM rust:1.82-bullseye@sha256:c42c8ca762560c182ba30edda0e0d71a8604040af2672370559d7e854653c66d AS builder
|
||||
|
||||
# Install specific version of libclang-dev
|
||||
RUN apt-get update && apt-get install -y libclang-dev=1:11.0-51+nmu5
|
||||
|
||||
# Clone the repository at the specific branch
|
||||
RUN git clone https://github.com/paradigmxyz/reth /app
|
||||
WORKDIR /app
|
||||
|
||||
# Checkout the reproducible-build branch
|
||||
RUN git checkout reproducible-build
|
||||
|
||||
# Get the latest commit timestamp and set SOURCE_DATE_EPOCH
|
||||
RUN SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && \
|
||||
echo "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" >> /etc/environment
|
||||
|
||||
# Set environment variables for reproducibility
|
||||
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 SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH \
|
||||
CARGO_INCREMENTAL=0 \
|
||||
LC_ALL=C \
|
||||
TZ=UTC \
|
||||
RUSTFLAGS="${RUSTFLAGS}"
|
||||
|
||||
# Set the default features if not provided
|
||||
ARG FEATURES="jemalloc asm-keccak"
|
||||
|
||||
# Build the project with the reproducible settings
|
||||
RUN . /etc/environment && \
|
||||
cargo build --bin reth --features "${FEATURES}" --profile "reproducible" --locked --target x86_64-unknown-linux-gnu
|
||||
|
||||
# Create a minimal final image with just the binary
|
||||
FROM scratch AS binaries
|
||||
|
||||
# Copy the compiled binary from the builder stage
|
||||
COPY --from=builder /app/target/x86_64-unknown-linux-gnu/reproducible/reth /reth
|
||||
10
Makefile
10
Makefile
@ -62,6 +62,16 @@ install-op: ## Build and install the op-reth binary under `~/.cargo/bin`.
|
||||
build: ## Build the reth binary into `target` directory.
|
||||
cargo build --bin reth --features "$(FEATURES)" --profile "$(PROFILE)"
|
||||
|
||||
SOURCE_DATE_EPOCH := $(shell git log -1 --pretty=%ct)
|
||||
.PHONY: reproducible
|
||||
reproducible: ## Build the reth binary into `target` directory with reproducible builds. Only works for x86_64-unknown-linux-gnu currently
|
||||
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
|
||||
CARGO_INCREMENTAL=0 \
|
||||
LC_ALL=C \
|
||||
TZ=UTC \
|
||||
RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-Wl,--build-id=none -Clink-arg=-static-libgcc -C metadata='' --remap-path-prefix $$(pwd)=." \
|
||||
cargo build --bin reth --features "$(FEATURES)" --profile "reproducible" --locked --target x86_64-unknown-linux-gnu
|
||||
|
||||
.PHONY: build-debug
|
||||
build-debug: ## Build the reth binary into `target/debug` directory.
|
||||
cargo build --bin reth --features "$(FEATURES)"
|
||||
|
||||
Reference in New Issue
Block a user