diff --git a/Dockerfile b/Dockerfile index e41d3671b0a..6e6c86c6eec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,8 +33,17 @@ ENV FEATURES=$FEATURES RUN cargo chef cook --profile $BUILD_PROFILE --features "$FEATURES" --recipe-path recipe.json # Build application +# Platform-specific RUSTFLAGS: amd64 uses x86-64-v3 (Haswell+) with pclmulqdq for rocksdb +# +# TARGETPLATFORM is set by BuildKit: https://docs.docker.com/reference/dockerfile#automatic-platform-args-in-the-global-scope +ARG TARGETPLATFORM COPY --exclude=dist . . -RUN cargo build --profile $BUILD_PROFILE --features "$FEATURES" --locked --bin reth +RUN if [ -n "$RUSTFLAGS" ]; then \ + export RUSTFLAGS="$RUSTFLAGS"; \ + elif [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + export RUSTFLAGS="-C target-cpu=x86-64-v3 -C target-feature=+pclmulqdq"; \ + fi && \ + cargo build --profile $BUILD_PROFILE --features "$FEATURES" --locked --bin reth # ARG is not resolved in COPY so we have to hack around it by copying the # binary to a temporary location