From b06907a806e4b799e37a3ab989f712597e756418 Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Wed, 26 Jun 2024 14:08:19 +0200 Subject: [PATCH] fix: docker build for worker and leader --- leader.Dockerfile | 48 ++++++++++++++++++++++++++++++++++++++ worker.Dockerfile | 37 +++++++++++++++++++++++++++++ zero_bin/leader.Dockerfile | 43 ---------------------------------- zero_bin/worker.Dockerfile | 35 --------------------------- 4 files changed, 85 insertions(+), 78 deletions(-) create mode 100644 leader.Dockerfile create mode 100644 worker.Dockerfile delete mode 100644 zero_bin/leader.Dockerfile delete mode 100644 zero_bin/worker.Dockerfile diff --git a/leader.Dockerfile b/leader.Dockerfile new file mode 100644 index 000000000..8d66b43fb --- /dev/null +++ b/leader.Dockerfile @@ -0,0 +1,48 @@ +FROM rustlang/rust:nightly-bullseye-slim as builder + +RUN apt-get update && apt-get install -y libjemalloc2 libjemalloc-dev make libssl-dev pkg-config + +RUN mkdir -p zero_bin +COPY Cargo.toml . +# Cleanup all workspace members and add again selected crates +RUN sed -i '/members =/{:a;N;/]/!ba};//d' Cargo.toml +RUN sed -i 's#\[workspace\]#\[workspace\]\nmembers = \["zero_bin\/leader", "zero_bin\/prover", "zero_bin\/rpc", "zero_bin\/common", \ + "zero_bin\/ops"\, "evm_arithmetization", "trace_decoder", "mpt_trie"\]#' Cargo.toml +COPY Cargo.lock . +COPY ./rust-toolchain.toml ./ +RUN cat ./Cargo.toml + +COPY proof_gen proof_gen +COPY mpt_trie mpt_trie +COPY trace_decoder trace_decoder +COPY evm_arithmetization evm_arithmetization +COPY zero_bin/common zero_bin/common +COPY zero_bin/ops zero_bin/ops +COPY zero_bin/rpc zero_bin/rpc +COPY zero_bin/prover zero_bin/prover +COPY zero_bin/leader zero_bin/leader + + +RUN \ + touch zero_bin/common/src/lib.rs && \ + touch zero_bin/ops/src/lib.rs && \ + touch zero_bin/leader/src/main.rs && \ + touch zero_bin/rpc/src/lib.rs && \ + touch zero_bin/prover/src/lib.rs && \ + touch evm_arithmetization/src/lib.rs && \ + touch trace_decoder/src/lib.rs && \ + touch mpt_trie/src/lib.rs + +# Disable the lld linker for now, as it's causing issues with the linkme package. +# https://github.com/rust-lang/rust/pull/124129 +# https://github.com/dtolnay/linkme/pull/88 +ENV RUSTFLAGS='-C target-cpu=native -Zlinker-features=-lld' + +RUN cargo build --release --bin leader + +RUN ls -la ./target/release + +FROM debian:bullseye-slim +RUN apt-get update && apt-get install -y ca-certificates libjemalloc2 +COPY --from=builder ./target/release/leader /usr/local/bin/leader +ENTRYPOINT ["/usr/local/bin/leader"] \ No newline at end of file diff --git a/worker.Dockerfile b/worker.Dockerfile new file mode 100644 index 000000000..c91ff2fb3 --- /dev/null +++ b/worker.Dockerfile @@ -0,0 +1,37 @@ +FROM rustlang/rust:nightly-bullseye-slim as builder + +RUN apt-get update && apt-get install -y libjemalloc2 libjemalloc-dev make libssl-dev pkg-config + +RUN mkdir -p zero_bin +COPY Cargo.toml . +# Cleanup all workspace members and add again selected crates +RUN sed -i '/members =/{:a;N;/]/!ba};//d' Cargo.toml +RUN sed -i 's#\[workspace\]#\[workspace\]\nmembers = \["zero_bin\/worker", "zero_bin\/common", "zero_bin\/ops"\, "evm_arithmetization", "mpt_trie"\]#' Cargo.toml +COPY Cargo.lock . +COPY ./rust-toolchain.toml ./ + +COPY proof_gen proof_gen +COPY mpt_trie mpt_trie +COPY evm_arithmetization evm_arithmetization +COPY zero_bin/common zero_bin/common +COPY zero_bin/ops zero_bin/ops +COPY zero_bin/worker zero_bin/worker + +RUN \ + touch zero_bin/common/src/lib.rs && \ + touch zero_bin/ops/src/lib.rs && \ + touch zero_bin/worker/src/main.rs && \ + touch evm_arithmetization/src/lib.rs && \ + touch mpt_trie/src/lib.rs + +# Disable the lld linker for now, as it's causing issues with the linkme package. +# https://github.com/rust-lang/rust/pull/124129 +# https://github.com/dtolnay/linkme/pull/88 +ENV RUSTFLAGS='-C target-cpu=native -Zlinker-features=-lld' + +RUN cargo build --release --bin worker + +FROM debian:bullseye-slim +RUN apt-get update && apt-get install -y ca-certificates libjemalloc2 +COPY --from=builder ./target/release/worker /usr/local/bin/worker +ENTRYPOINT ["/usr/local/bin/worker"] diff --git a/zero_bin/leader.Dockerfile b/zero_bin/leader.Dockerfile deleted file mode 100644 index 7e0eb6e8c..000000000 --- a/zero_bin/leader.Dockerfile +++ /dev/null @@ -1,43 +0,0 @@ -FROM rustlang/rust:nightly-bullseye-slim as builder - -RUN apt-get update && apt-get install -y libjemalloc2 libjemalloc-dev make libssl-dev pkg-config - -RUN \ - mkdir -p ops/src && touch ops/src/lib.rs && \ - mkdir -p common/src && touch common/src/lib.rs && \ - mkdir -p rpc/src && touch rpc/src/lib.rs && \ - mkdir -p prover/src && touch prover/src/lib.rs && \ - mkdir -p leader/src && echo "fn main() {println!(\"YO!\");}" > leader/src/main.rs - -COPY Cargo.toml . -RUN sed -i "2s/.*/members = [\"ops\", \"leader\", \"common\", \"rpc\", \"prover\"]/" Cargo.toml -COPY Cargo.lock . - -COPY ops/Cargo.toml ./ops/Cargo.toml -COPY common/Cargo.toml ./common/Cargo.toml -COPY rpc/Cargo.toml ./rpc/Cargo.toml -COPY prover/Cargo.toml ./prover/Cargo.toml -COPY leader/Cargo.toml ./leader/Cargo.toml - -COPY ./rust-toolchain.toml ./ - -RUN cargo build --release --bin leader - -COPY ops ./ops -COPY common ./common -COPY rpc ./rpc -COPY prover ./prover -COPY leader ./leader -RUN \ - touch ops/src/lib.rs && \ - touch common/src/lib.rs && \ - touch rpc/src/lib.rs && \ - touch prover/src/lib.rs && \ - touch leader/src/main.rs - -RUN cargo build --release --bin leader - -FROM debian:bullseye-slim -RUN apt-get update && apt-get install -y ca-certificates libjemalloc2 -COPY --from=builder ./target/release/leader /usr/local/bin/leader -CMD ["leader"] diff --git a/zero_bin/worker.Dockerfile b/zero_bin/worker.Dockerfile deleted file mode 100644 index 39036aa2c..000000000 --- a/zero_bin/worker.Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -FROM rustlang/rust:nightly-bullseye-slim as builder - -RUN apt-get update && apt-get install -y libjemalloc2 libjemalloc-dev make libssl-dev - -RUN \ - mkdir -p common/src && touch common/src/lib.rs && \ - mkdir -p ops/src && touch ops/src/lib.rs && \ - mkdir -p worker/src && echo "fn main() {println!(\"YO!\");}" > worker/src/main.rs - -COPY Cargo.toml . -RUN sed -i "2s/.*/members = [\"common\", \"ops\", \"worker\"]/" Cargo.toml -COPY Cargo.lock . - -COPY common/Cargo.toml ./common/Cargo.toml -COPY ops/Cargo.toml ./ops/Cargo.toml -COPY worker/Cargo.toml ./worker/Cargo.toml - -COPY ./rust-toolchain.toml ./ - -RUN cargo build --release --bin worker - -COPY common ./common -COPY ops ./ops -COPY worker ./worker -RUN \ - touch common/src/lib.rs && \ - touch ops/src/lib.rs && \ - touch worker/src/main.rs - -RUN cargo build --release --bin worker - -FROM debian:bullseye-slim -RUN apt-get update && apt-get install -y ca-certificates libjemalloc2 -COPY --from=builder ./target/release/worker /usr/local/bin/worker -CMD ["worker"]