Skip to content

Commit

Permalink
chore: use anagram risczero docker
Browse files Browse the repository at this point in the history
  • Loading branch information
jac18281828 authored Oct 19, 2024
1 parent 1b93f2d commit 27f3c37
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 69 deletions.
12 changes: 6 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
"1YiB.rust-bundle"
]
}
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"version": "latest"
}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
}
75 changes: 13 additions & 62 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,15 @@
# Development Container
# Stage 1: Build yamlfmt
FROM golang:1 AS go-builder
# defined from build kit
# DOCKER_BUILDKIT=1 docker build . -t ...
ARG TARGETARCH
# Bonsol Development Container
FROM ghcr.io/anagrambuild/risczero:latest

# Install yamlfmt
WORKDIR /yamlfmt
RUN go install github.com/google/yamlfmt/cmd/yamlfmt@latest && \
strip $(which yamlfmt) && \
yamlfmt --version

# Stage 2: Rust Development Container
FROM rust:1-slim
ARG TARGETARCH

# Install packages
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
binutils \
ca-certificates \
clang \
cmake \
curl \
git \
gnupg2 \
libssl-dev \
make \
ninja-build \
perl \
pkg-config \
protobuf-c-compiler \
python3 \
python3-pip \
ripgrep \
sudo \
valgrind \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN echo "building platform $(uname -m)"

# create dev user
RUN useradd --create-home --shell /bin/bash bonsol
RUN usermod -a -G sudo bonsol
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

## Rust
ENV USER=bonsol
COPY --chown=${USER}:${USER} --from=go-builder /go/bin/yamlfmt /go/bin/yamlfmt
USER bonsol
ENV PATH=${PATH}:/go/bin
ENV USER=solana
ARG SOLANA=1.18.22
ENV CARGO_HOME=/usr/local/cargo
ENV RUSTUP_HOME=/usr/local/rustup
ENV PATH=${PATH}:/usr/local/cargo/bin:/go/bin:/home/solana/.local/share/solana/install/releases/${SOLANA}/bin
USER solana

# Set user and working directory
ARG PACKAGE=bonsol
USER bonsol
WORKDIR /workspaces/${PACKAGE}

# Install Rust components
Expand All @@ -65,14 +18,12 @@ RUN rustup component add \
clippy \
rust-analyzer

RUN cargo install cargo-binstall
RUN yes | cargo binstall cargo-risczero
RUN cargo risczero build-toolchain

# Clean up
RUN rm -rf /home/bonsol/.cargo/registry /home/bonsol/.cargo/git

ENV PATH=${PATH}:/home/bonsol/.cargo/bin
# Risk0 Groth16 Prover
COPY --from=risczero/risc0-groth16-prover:v2024-05-17.1 /app/stark_verify /stark/stark_verify
COPY --from=risczero/risc0-groth16-prover:v2024-05-17.1 /app/stark_verify.dat /stark/stark_verify.dat
COPY --from=risczero/risc0-groth16-prover:v2024-05-17.1 /app/stark_verify_final.zkey /stark/stark_verify_final.zkey
COPY --from=risczero/risc0-groth16-prover:v2024-05-17.1 /usr/local/sbin/rapidsnark /stark/rapidsnark

LABEL \
org.label-schema.name="bonsol" \
Expand Down
5 changes: 4 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/zsh
set -e
docker build -f setup.dockerfile -o node .
if [ ! -d "/stark/stark_verify" ]; then
docker build -f setup.dockerfile -o node .
fi

pnpx snarkjs zkey export verificationkey node/stark/stark_verify_final.zkey verification_key.json
cd vkey
pnpm i && pnpm run parse-vk ../verification_key.json ../onchain/channel/src/ && \
Expand Down

0 comments on commit 27f3c37

Please sign in to comment.