Containerfile.capacity 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Two-stage Containerfile for the DarkFi capacity benchmark.
  2. #
  3. # Build context must be the repo root (not this directory), because
  4. # fee-model/Cargo.toml uses path = "../../../" for darkfi deps:
  5. #
  6. # cd /path/to/darkfi
  7. # podman build -t darkfi-capacity \
  8. # -f script/research/fee-model/Containerfile.capacity .
  9. #
  10. # Run:
  11. # podman run --rm --cpuset-cpus=0-3 --memory=8g \
  12. # -v ./out:/out darkfi-capacity
  13. #
  14. # The image bundles the capacity binary and the money contract WASM.
  15. # The benchmark writes results to /out/capacity.json.
  16. # ===========================================================================
  17. # Stage 1: Build
  18. # ===========================================================================
  19. FROM docker.io/debian:bookworm-slim AS rust_builder
  20. ARG RUST_VER=stable
  21. RUN apt-get update && apt-get install -y --no-install-recommends \
  22. build-essential cmake pkg-config clang libclang-dev llvm-dev \
  23. libssl-dev libsqlite3-dev curl ca-certificates git python3 \
  24. && rm -rf /var/lib/apt/lists/*
  25. RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain "${RUST_VER}"
  26. ENV PATH="/root/.cargo/bin:${PATH}"
  27. RUN rustup target add wasm32-unknown-unknown
  28. WORKDIR /opt/darkfi
  29. # Copy the full source tree (preserves the ../../../ path layout
  30. # that fee-model/Cargo.toml uses for darkfi path dependencies).
  31. COPY . /opt/darkfi
  32. # Build zkas first (native target, no special flags needed).
  33. RUN make zkas
  34. # Build contract WASMs with --import-undefined linker flag.
  35. # RUSTFLAGS is set directly so it reliably reaches cargo through the
  36. # contract Makefiles. Only WASM targets are built here, so the
  37. # --import-undefined flag only reaches wasm-ld, never the native linker.
  38. # This fixes "undefined symbol: drk_log_" on Rust 1.82+ where extern "C"
  39. # without #[link(wasm_import_module = ...)] no longer auto-imports.
  40. RUN export RUSTFLAGS="-C link-arg=--import-undefined" && \
  41. make -C src/contract/money && \
  42. make -C src/contract/dao && \
  43. make -C src/contract/deployooor
  44. # Build the capacity binary.
  45. WORKDIR /opt/darkfi/script/research/fee-model
  46. RUN cargo build --release --bin capacity
  47. # ===========================================================================
  48. # Stage 2: Runtime (slim)
  49. # ===========================================================================
  50. FROM docker.io/debian:bookworm-slim
  51. RUN apt-get update && apt-get install -y --no-install-recommends \
  52. libssl3 ca-certificates \
  53. && rm -rf /var/lib/apt/lists/*
  54. WORKDIR /opt/fee-model
  55. # Copy the capacity binary
  56. COPY --from=rust_builder /opt/darkfi/script/research/fee-model/target/release/capacity \
  57. /opt/fee-model/capacity
  58. # Copy the money contract WASM (needed by deploy scenarios)
  59. COPY --from=rust_builder /opt/darkfi/src/contract/money/darkfi_money_contract.wasm \
  60. /opt/darkfi/contracts/darkfi_money_contract.wasm
  61. # Point the benchmark at the bundled WASM
  62. ENV MONEY_WASM_PATH=/opt/darkfi/contracts/darkfi_money_contract.wasm
  63. # Output directory (mount a volume here to retrieve results)
  64. RUN mkdir -p /out
  65. VOLUME /out
  66. ENTRYPOINT ["/opt/fee-model/capacity"]