Add Dockerfile

This commit is contained in:
Sydhds
2025-06-13 16:54:22 +02:00
committed by GitHub
parent 409cdcb651
commit 1059b87572
4 changed files with 87 additions and 0 deletions

44
Dockerfile Normal file
View File

@@ -0,0 +1,44 @@
# Stage 1: Build Prover
FROM rust:1.87-slim-bookworm AS builder
RUN apt update && apt install -y pkg-config libssl-dev protobuf-compiler
# Working directory
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY proto ./proto
COPY prover ./prover
COPY rln_proof ./rln_proof
COPY smart_contract ./smart_contract
RUN cargo build --release
# Stage 2: Run Prover
FROM ubuntu:25.04
RUN groupadd -r user && useradd -r -g user user
WORKDIR /app
# Copy the entrypoint script and make it executable
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Copy from the builder stage
COPY --from=builder /app/target/release/status_rln_prover ./status_rln_prover
COPY mock ./mock
RUN chown -R user:user /app
RUN chown user:user /usr/local/bin/docker-entrypoint.sh
USER user
# Exppose default port
EXPOSE 50051
# Run the prover - shell script will build arguments with parsed env var
ENTRYPOINT ["docker-entrypoint.sh"]
# Define default env variables. These will be used if not overridden during `docker run`.
ENV SERVICE_IP="0.0.0.0" \
SERVICE_PORT="50051"

View File

@@ -1,5 +1,10 @@
# Status L2 Rln Prover
## Docker
* docker build --progress=plain --no-cache -t prover .
* docker run -p 50051:50051 -e MOCK_SC="1" -e MOCK_USER="mock/mock_user_1.json" prover
## Run
RUST_LOG=debug cargo run -- -i 127.0.0.1 -r "wss://eth-mainnet.g.alchemy.com/v2/__MY_TOKEN__"

35
docker-entrypoint.sh Normal file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
# Array to hold the command-line arguments
CMD_ARGS=()
CMD_ARGS+=("--ip" "${SERVICE_IP}")
CMD_ARGS+=("--port" "${SERVICE_PORT}")
if [ -n "$WS_RPC_URL" ]; then
CMD_ARGS+=("--ws-rpc-url" "${WS_RPC_URL}")
fi
if [ -n "$KARMA_SC_ADDRESS" ]; then
CMD_ARGS+=("--ksc" "${KARMA_SC_ADDRESS}")
fi
if [ -n "$RLN_SC_ADDRESS" ]; then
CMD_ARGS+=("--rlnsc" "${RLN_SC_ADDRESS}")
fi
if [ -n "$KARMA_TIERS_SC_ADDRESS" ]; then
CMD_ARGS+=("--tsc" "${KARMA_TIERS_SC_ADDRESS}")
fi
if [ -n "$MOCK_SC" ]; then
CMD_ARGS+=("--mock-sc" "true")
fi
if [ -n "$MOCK_USER" ]; then
CMD_ARGS+=("--mock-user" "${MOCK_USER}")
fi
echo "Starting rln-prover-service with arguments: ${CMD_ARGS[*]}"
export RUST_LOG=debug
exec ./status_rln_prover "${CMD_ARGS[@]}"

View File

@@ -49,6 +49,9 @@ const PROVER_MINIMAL_AMOUNT_FOR_REGISTRATION: U256 =
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// debug!("Args: {:?}", std::env::args());
let filter = EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy();