Skip to content

Commit

Permalink
Str-909 Dockerize the prover client binary (#631)
Browse files Browse the repository at this point in the history
* restore devent prover docker

* prover doc img docs added

* docker file install sp1 toolchain

* updated entrypoint
  • Loading branch information
MdTeach authored Jan 23, 2025
1 parent 78aa39f commit e1a1e6a
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
71 changes: 71 additions & 0 deletions docker/prover-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
FROM --platform=linux/amd64 rust:latest AS builder

WORKDIR /app
# Set environment variables for optimized release builds
ENV CARGO_INCREMENTAL=0 \
CARGO_TERM_COLOR=always

# Install system dependencies
RUN apt-get update && apt-get -y upgrade && apt-get install -y \
pkg-config \
ca-certificates \
clang \
libssl-dev \
git \
dialog \
xz-utils \
build-essential \
curl \
libclang-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# setup sp1up
RUN curl -fsSL --proto https --tlsv1.2 https://sp1.succinct.xyz | bash && ~/.sp1/bin/sp1up --c-toolchain
ENV PATH="/root/.sp1/bin:$PATH"

# check sp1 is setup properly
RUN cargo prove --version
RUN RUSTUP_TOOLCHAIN=succinct cargo --version

COPY . .

# Accept an argument for Cargo features
ARG PROVER_FEATURES=""

# Build dependencies in release mode
RUN --mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,sharing=private,target=/app/target \
cargo build --release --bin strata-prover-client -F ${PROVER_FEATURES}

RUN --mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,sharing=private,target=/app/target \
cp /app/target/release/strata-prover-client /app/strata-prover-client

FROM --platform=linux/amd64 ubuntu:24.04 AS runtime
WORKDIR /app

# Install runtime dependencies
RUN apt-get update && \
apt-get install -y \
curl \
iproute2 \
net-tools \
libssl-dev \
libffi-dev \
software-properties-common && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Copy the built binaries and the entrypoint script from the builder stage
COPY --from=builder /app/strata-prover-client /usr/local/bin/strata-prover-client
COPY ./docker/prover-client/entrypoint.sh entrypoint.sh

EXPOSE 9851

# Make the entrypoint script executable
RUN chmod +x entrypoint.sh

# Set the entrypoint
ENTRYPOINT ["/app/entrypoint.sh"]
22 changes: 22 additions & 0 deletions docker/prover-client/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### Building the Prover Client Docker Images


#### Native Mode
Generate a Prover Image where proving occurs in native mode. In native mode, instead of actual proof generation, proof statements are executed in native Rust. This results in an empty proof and the expected public parameters.

```bash
docker build --build-arg PROVER_FEATURES=default -t prover-client-native -f ./docker/prover-client/Dockerfile .
```

#### sp1-mock Mode
Generate a Prover Image in sp1-mock proving mode. In mock mode, execution happens inside the RISC-V VM, generating a mock proof and the expected public parameters.
```bash
docker build --build-arg PROVER_FEATURES=sp1-mock -t prover-client-sp1-mock -f ./docker/prover-client/Dockerfile .
```

#### sp1 Mode

Generate a Prover Image in sp1 proving mode. In sp1 mode, actual proofs and public parameters are generated.
```bash
docker build --build-arg PROVER_FEATURES=sp1 -t prover-client-sp1 -f ./docker/prover-client/Dockerfile .
```
19 changes: 19 additions & 0 deletions docker/prover-client/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Exit on error
set -e

echo "starting Prover client"

# Sample Entrypoint
strata-prover-client \
--rpc-port 9851 \
--enable-dev-rpcs true \
--enable-checkpoint-runner false \
--rollup-params $ROLLUP_PARAMS \
--datadir $DATA_DIR \
--sequencer-rpc http://sequencer:8432 \
--bitcoind-url http://bitcoind:8332 \
--bitcoind-user $BITCOIND_USER \
--bitcoind-password $BITCOIND_PASSWORD \
--reth-rpc http://reth:8545 $@

0 comments on commit e1a1e6a

Please sign in to comment.