Skip to content

Commit 9087826

Browse files
authored
fix: rbuilder dockerfile move around (#296)
This caused err: flashbots/rbuilder#739
1 parent 88329bc commit 9087826

3 files changed

Lines changed: 102 additions & 4 deletions

File tree

.github/workflows/build-push-reth-rbuilder.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
source_ref: ${{ inputs.ref }}
6666
target_tag: ${{ needs.prepare.outputs.target_tag }}-${{ matrix.slug }}
6767
target_repository: ethpandaops/reth-rbuilder
68+
target_dockerfile: ./reth-rbuilder/Dockerfile.rbuilder
6869
platform: ${{ matrix.platform }}
6970
build_args: ${{ inputs.build_args }}
7071

@@ -75,7 +76,7 @@ jobs:
7576
HARBOR_USERNAME: "${{ vars.HARBOR_USERNAME }}"
7677
HARBOR_PASSWORD: "${{ secrets.HARBOR_PASSWORD }}"
7778
harbor_registry: ${{ vars.HARBOR_REGISTRY }}
78-
79+
7980
# This step captures the git commit hash from the deploy action for job output
8081
- name: Set job output
8182
id: set_output

generate_config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242

4343
# Build argument defaults for special cases
4444
BUILD_ARGS = {
45-
'mev-rs/main-minimal': 'FEATURES=minimal-preset',
46-
'reth-rbuilder/develop': 'RBUILDER_BIN=reth-rbuilder'
45+
'mev-rs/main-minimal': 'FEATURES=minimal-preset'
4746
}
4847

4948
# Clients that need to have minimal builds created automatically
@@ -204,7 +203,9 @@ def extract_client_name(config):
204203
def get_dockerfile_path(client_name, target_tag=None):
205204
"""Determine the dockerfile path based on client name and tag conventions"""
206205
# Special cases for different clients
207-
if client_name == 'nimbus-eth2':
206+
if client_name == 'reth-rbuilder':
207+
return f"./{client_name}/Dockerfile.rbuilder"
208+
elif client_name == 'nimbus-eth2':
208209
if target_tag and 'minimal' in target_tag:
209210
return f"./{client_name}/Dockerfile.beacon-minimal"
210211
return f"./{client_name}/Dockerfile.beacon"

reth-rbuilder/Dockerfile.rbuilder

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#
2+
# Base container (with sccache and cargo-chef)
3+
#
4+
# - https://github.com/mozilla/sccache
5+
# - https://github.com/LukeMathWalker/cargo-chef
6+
#
7+
# Based on https://depot.dev/blog/rust-dockerfile-best-practices
8+
#
9+
ARG FEATURES
10+
ARG RBUILDER_BIN="rbuilder"
11+
12+
FROM rust:1.88 AS base
13+
ARG TARGETPLATFORM
14+
15+
RUN apt-get update \
16+
&& apt-get install -y clang libclang-dev cmake protobuf-compiler
17+
18+
RUN rustup component add clippy rustfmt
19+
20+
21+
# We manually download sccache, because compilation is resource-intensive
22+
RUN set -eux; \
23+
case "$TARGETPLATFORM" in \
24+
"linux/amd64") ARCH_TAG="x86_64-unknown-linux-musl" ;; \
25+
"linux/arm64") ARCH_TAG="aarch64-unknown-linux-musl" ;; \
26+
*) \
27+
echo "Unsupported platform: $TARGETPLATFORM"; \
28+
exit 1 \
29+
;; \
30+
esac; \
31+
wget -O /tmp/sccache.tar.gz \
32+
"https://github.com/mozilla/sccache/releases/download/v0.8.2/sccache-v0.8.2-${ARCH_TAG}.tar.gz"; \
33+
tar -xf /tmp/sccache.tar.gz -C /tmp; \
34+
mv /tmp/sccache-v0.8.2-${ARCH_TAG}/sccache /usr/local/bin/sccache; \
35+
chmod +x /usr/local/bin/sccache; \
36+
rm -rf /tmp/sccache.tar.gz /tmp/sccache-v0.8.2-${ARCH_TAG}
37+
38+
RUN cargo install cargo-chef --version ^0.1
39+
40+
41+
ENV CARGO_HOME=/usr/local/cargo
42+
ENV RUSTC_WRAPPER=sccache
43+
ENV SCCACHE_DIR=/sccache
44+
45+
#
46+
# Planner container (running "cargo chef prepare")
47+
#
48+
FROM base AS planner
49+
WORKDIR /app
50+
COPY . .
51+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
52+
--mount=type=cache,target=/usr/local/cargo/git \
53+
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
54+
cargo chef prepare --recipe-path recipe.json
55+
56+
#
57+
# Builder container (running "cargo chef cook" and "cargo build --release")
58+
#
59+
FROM base AS builder
60+
WORKDIR /app
61+
COPY --from=planner /app/recipe.json recipe.json
62+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
63+
--mount=type=cache,target=/usr/local/cargo/git \
64+
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
65+
cargo chef cook --release --recipe-path recipe.json
66+
COPY . .
67+
68+
69+
FROM builder AS rbuilder
70+
ARG RBUILDER_BIN
71+
ARG FEATURES
72+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
73+
--mount=type=cache,target=/usr/local/cargo/git \
74+
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
75+
cargo build --release --features="$FEATURES" --package=${RBUILDER_BIN}
76+
77+
FROM builder AS test-relay
78+
ARG FEATURES
79+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
80+
--mount=type=cache,target=/usr/local/cargo/git \
81+
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
82+
cargo build --release --features="$FEATURES" --package=test-relay
83+
84+
85+
# Runtime container for test-relay
86+
FROM gcr.io/distroless/cc-debian12 AS test-relay-runtime
87+
WORKDIR /app
88+
COPY --from=test-relay /app/target/release/test-relay /app/test-relay
89+
ENTRYPOINT ["/app/test-relay"]
90+
91+
# Runtime container for rbuilder
92+
FROM gcr.io/distroless/cc-debian12 AS rbuilder-runtime
93+
ARG RBUILDER_BIN
94+
WORKDIR /app
95+
COPY --from=rbuilder /app/target/release/${RBUILDER_BIN} /app/rbuilder
96+
ENTRYPOINT ["/app/rbuilder"]

0 commit comments

Comments
 (0)