-
Notifications
You must be signed in to change notification settings - Fork 20
Add reproducible builds #233
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Verify Reproducible Build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think the best idea is to run this on schedule once a week / couple of days for example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figured we were just going to run this manually whenever we have a release that we want to put in a new image. Every 3-4 days def wouldn't hurt though. I'll add that. |
||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
verify: | ||
name: Verify reproducible builds | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- name: Build twice and compare | ||
run: | | ||
export REPRO_FLAGS="--C target-feature=+crt-static -C link-arg=-static-libgcc -C link-arg=-Wl,--build-id=none -C metadata='' --remap-path-prefix=$(pwd)=." | ||
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) | ||
RUSTFLAGS="$REPRO_FLAGS" CARGO_INCREMENTAL=0 LC_ALL=C TZ=UTC \ | ||
cargo build --release --locked -p op-rbuilder | ||
mv target/release/op-rbuilder build1 | ||
cargo clean | ||
RUSTFLAGS="$REPRO_FLAGS" CARGO_INCREMENTAL=0 LC_ALL=C TZ=UTC \ | ||
cargo build --release --locked -p op-rbuilder | ||
mv target/release/op-rbuilder build2 | ||
if cmp -s build1 build2; then | ||
echo "β Builds are reproducible" | ||
else | ||
echo "β Builds differ" | ||
exit 1 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,10 +73,31 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \ | |
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ | ||
cargo build --release --features="$FEATURES" --package=${RBUILDER_BIN} | ||
|
||
# | ||
# Reproducible builder container (deterministic source-date-epoch, no caching, no incremental builds) | ||
# | ||
FROM base AS rbuilder-reproducible | ||
ARG RBUILDER_BIN | ||
ARG FEATURES | ||
WORKDIR /app | ||
COPY . . | ||
RUN SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will force docker to build this 2 times (and one of them would be slow build), let's do it better There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are compiling regular build + reproducible build There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh I see. That RUN command means that the builds are actually happening during docker build, not docker run. I can just add a --target flag to the PR workflow to force it to build only the non-reproducible. Does that solve the problem? |
||
RUSTFLAGS="--C target-feature=+crt-static -C link-arg=-static-libgcc -C link-arg=-Wl,--build-id=none -C metadata='' --remap-path-prefix=/app=." \ | ||
CARGO_INCREMENTAL=0 \ | ||
LC_ALL=C \ | ||
TZ=UTC \ | ||
cargo build --release --locked --features="$FEATURES" --package=${RBUILDER_BIN} | ||
|
||
# Runtime container for rbuilder | ||
FROM gcr.io/distroless/cc-debian12 AS rbuilder-runtime | ||
ARG RBUILDER_BIN | ||
WORKDIR /app | ||
COPY --from=rbuilder /app/target/release/${RBUILDER_BIN} /app/rbuilder | ||
ENTRYPOINT ["/app/rbuilder"] | ||
|
||
# Reproducible runtime container for rbuilder | ||
FROM gcr.io/distroless/cc-debian12 AS rbuilder-reproducible-runtime | ||
ARG RBUILDER_BIN | ||
WORKDIR /app | ||
COPY --from=rbuilder-reproducible /app/target/release/${RBUILDER_BIN} /app/rbuilder | ||
ENTRYPOINT ["/app/rbuilder"] |
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.
not sure it will work