-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
69 lines (50 loc) · 2.31 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Base with Rust, Go, CUDA, SP1, and cargo-chef
FROM nvidia/cuda:12.8.1-devel-ubuntu24.04 AS base-dev
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends -y \
clang libclang-dev docker.io curl tar build-essential pkg-config git ca-certificates gnupg2 \
&& rm -rf /var/lib/apt/lists/*
ENV GO_VERSION=1.22.0
ENV GO_URL="https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
RUN curl -L --proto '=https' --tlsv1.2 -sSf ${GO_URL} -o go.tar.gz && \
mkdir -p /opt/go && \
tar -C /opt/go --strip-components=1 -xzf go.tar.gz && \
rm go.tar.gz
ENV PATH="/opt/go/bin:${PATH}"
# Ensure we cache toolchain & components
WORKDIR /app
COPY ./rust-toolchain.toml ./
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# https://github.com/LukeMathWalker/cargo-chef/
RUN cargo install cargo-chef
# https://docs.succinct.xyz/docs/sp1/getting-started/install
RUN curl -L https://sp1up.succinct.xyz | bash && \
/root/.sp1/bin/sp1up
####################################################################################################
FROM base-dev AS planner
WORKDIR /app
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
####################################################################################################
FROM base-dev AS builder
WORKDIR /app
COPY --from=planner /app/recipe.json ./
RUN --mount=type=cache,id=target_cache,target=/app/target \
cargo chef cook --release --recipe-path recipe.json
COPY . .
# Build SP1 ELF to be proven (with optimizations)
RUN --mount=type=cache,id=target_cache,target=/app/target \
/root/.sp1/bin/cargo-prove prove build -p chacha-program
# Build the final binary
RUN --mount=type=cache,id=target_cache,target=/app/target \
cargo build --release && \
strip /app/target/release/pda-proxy && \
cp target/release/pda-proxy /app/pda-proxy # pop out of cache
####################################################################################################
FROM nvidia/cuda:12.8.1-base-ubuntu24.04 AS runtime
# SP1 CUDA support needs Docker-in-Docker to run `moongate-server` prover service
# Internally run on localhost:3000
COPY --from=base-dev /usr/bin/docker /usr/bin/docker
COPY --from=builder /app/pda-proxy /usr/local/bin/pda-proxy
ENTRYPOINT ["/usr/local/bin/pda-proxy"]