Skip to content

Commit 8747167

Browse files
authored
feat: dockerize (#10)
1 parent f6755a9 commit 8747167

File tree

6 files changed

+379
-11
lines changed

6 files changed

+379
-11
lines changed

.github/workflows/docker.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
name: Build and Push Images
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
paths:
8+
- 'workflows/**'
9+
- 'crates/**'
10+
- 'bin/**'
11+
- 'Dockerfile.gpu'
12+
- 'Dockerfile.cpu'
13+
- 'Cargo.toml'
14+
merge_group:
15+
16+
env:
17+
ECR_REPOSITORY: public.ecr.aws/succinct-labs/prover
18+
19+
jobs:
20+
build-amd64:
21+
runs-on:
22+
[
23+
'runs-on',
24+
'runner=32cpu-linux-x64',
25+
'run-id=${{ github.run_id }}',
26+
'hdd=41',
27+
'spot=false',
28+
'tag=gpu',
29+
'disk=large',
30+
]
31+
steps:
32+
- name: Add SHORT_SHA env property with commit short sha
33+
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
34+
35+
# https://github.com/orgs/community/discussions/25678
36+
- name: Delete huge unnecessary tools folder
37+
run: |
38+
df -h
39+
sudo rm -rf /opt/hostedtoolcache
40+
sudo rm -rf /usr/share/dotnet
41+
sudo rm -rf /usr/local/share/boost
42+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
43+
df -h
44+
45+
- name: Checkout repo
46+
uses: actions/checkout@v4
47+
with:
48+
submodules: true
49+
50+
- name: Setup CI
51+
uses: ./.github/actions/setup
52+
53+
- name: Configure AWS credentials
54+
uses: 'aws-actions/configure-aws-credentials@v1'
55+
with:
56+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
57+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
58+
aws-region: ${{ secrets.AWS_REGION }}
59+
60+
- name: Set up Docker
61+
uses: docker/setup-buildx-action@v3
62+
with:
63+
platforms: linux/amd64,linux/arm64
64+
65+
- name: Set up NVIDIA Container Toolkit
66+
run: |
67+
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
68+
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
69+
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
70+
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
71+
sudo systemctl restart docker
72+
73+
- name: Login to Amazon ECR Public
74+
uses: aws-actions/amazon-ecr-login@v2
75+
with:
76+
registry-type: public
77+
78+
- name: Build and Push AMD64 GPU Image
79+
uses: docker/build-push-action@v5
80+
with:
81+
context: .
82+
file: ./Dockerfile.gpu
83+
platforms: linux/amd64
84+
push: true
85+
tags: ${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-amd64
86+
cache-from: type=gha
87+
cache-to: type=gha,mode=max
88+
89+
- name: Build and Push AMD64 CPU Image
90+
uses: docker/build-push-action@v5
91+
with:
92+
context: .
93+
file: ./Dockerfile.cpu
94+
platforms: linux/amd64
95+
push: true
96+
tags: ${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-amd64
97+
cache-from: type=gha
98+
cache-to: type=gha,mode=max
99+
100+
build-arm64:
101+
runs-on:
102+
[
103+
'runs-on',
104+
'runner=32cpu-linux-arm64',
105+
'run-id=${{ github.run_id }}',
106+
'hdd=41',
107+
'spot=false',
108+
'tag=gpu',
109+
'disk=large',
110+
]
111+
steps:
112+
- name: Add SHORT_SHA env property with commit short sha
113+
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
114+
115+
- name: Delete huge unnecessary tools folder
116+
run: |
117+
df -h
118+
sudo rm -rf /opt/hostedtoolcache
119+
sudo rm -rf /usr/share/dotnet
120+
sudo rm -rf /usr/local/share/boost
121+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
122+
df -h
123+
124+
- name: Checkout repo
125+
uses: actions/checkout@v4
126+
with:
127+
submodules: true
128+
129+
- name: Setup CI
130+
uses: ./.github/actions/setup
131+
132+
- name: Configure AWS credentials
133+
uses: 'aws-actions/configure-aws-credentials@v1'
134+
with:
135+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
136+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
137+
aws-region: ${{ secrets.AWS_REGION }}
138+
139+
- name: Set up Docker
140+
uses: docker/setup-buildx-action@v3
141+
142+
- name: Set up NVIDIA Container Toolkit
143+
run: |
144+
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
145+
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
146+
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
147+
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
148+
sudo systemctl restart docker
149+
150+
- name: Login to Amazon ECR Public
151+
uses: aws-actions/amazon-ecr-login@v2
152+
with:
153+
registry-type: public
154+
155+
- name: Build and Push ARM64 GPU Image
156+
uses: docker/build-push-action@v5
157+
with:
158+
context: .
159+
file: ./Dockerfile.gpu
160+
platforms: linux/arm64
161+
push: true
162+
tags: ${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-arm64
163+
cache-from: type=gha
164+
cache-to: type=gha,mode=max
165+
166+
- name: Build and Push ARM64 CPU Image
167+
uses: docker/build-push-action@v5
168+
with:
169+
context: .
170+
file: ./Dockerfile.cpu
171+
platforms: linux/arm64
172+
push: true
173+
tags: ${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-arm64
174+
cache-from: type=gha
175+
cache-to: type=gha,mode=max
176+
177+
create-manifest:
178+
needs: [build-amd64, build-arm64]
179+
runs-on: ubuntu-latest
180+
steps:
181+
- name: Add SHORT_SHA env property with commit short sha
182+
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
183+
184+
- name: Configure AWS credentials
185+
uses: 'aws-actions/configure-aws-credentials@v1'
186+
with:
187+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
188+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
189+
aws-region: ${{ secrets.AWS_REGION }}
190+
191+
- name: Login to Amazon ECR Public
192+
uses: aws-actions/amazon-ecr-login@v2
193+
with:
194+
registry-type: public
195+
196+
- name: Create and push GPU manifest
197+
run: |
198+
docker buildx imagetools create -t ${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }} \
199+
${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-amd64 \
200+
${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-arm64
201+
docker buildx imagetools create -t ${{ env.ECR_REPOSITORY }}-gpu:latest \
202+
${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-amd64 \
203+
${{ env.ECR_REPOSITORY }}-gpu:${{ env.SHORT_SHA }}-arm64
204+
205+
- name: Create and push CPU manifest
206+
run: |
207+
docker buildx imagetools create -t ${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }} \
208+
${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-amd64 \
209+
${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-arm64
210+
docker buildx imagetools create -t ${{ env.ECR_REPOSITORY }}-cpu:latest \
211+
${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-amd64 \
212+
${{ env.ECR_REPOSITORY }}-cpu:${{ env.SHORT_SHA }}-arm64

Dockerfile.cpu

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Build stage
2+
FROM rustlang/rust:nightly-slim AS build
3+
4+
# Install necessary packages for building
5+
RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && \
6+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
7+
openssl \
8+
libssl-dev \
9+
pkg-config \
10+
protobuf-compiler \
11+
build-essential \
12+
wget \
13+
tar \
14+
libclang-dev \
15+
curl \
16+
git
17+
18+
# Install Go (needed for native-gnark)
19+
ENV GO_VERSION=1.22.1
20+
ARG TARGETARCH
21+
RUN wget -q https://golang.org/dl/go$GO_VERSION.linux-${TARGETARCH}.tar.gz && \
22+
tar -C /usr/local -xzf go$GO_VERSION.linux-${TARGETARCH}.tar.gz && \
23+
rm go$GO_VERSION.linux-${TARGETARCH}.tar.gz
24+
ENV PATH=$PATH:/usr/local/go/bin
25+
26+
# Install sp1up and the SP1 toolchain
27+
ENV SP1_HOME="/root/.sp1"
28+
ENV PATH="${SP1_HOME}/bin:${PATH}"
29+
RUN curl -L https://sp1.succinct.xyz | bash && \
30+
sp1up
31+
32+
# Prepare for git dependencies
33+
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
34+
RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
35+
36+
# Copy the entire workspace (including root Cargo.toml and all crates)
37+
COPY . /app
38+
WORKDIR /app
39+
40+
ENV VERGEN_CARGO_PROFILE=release
41+
42+
# Build only the node binary
43+
RUN --mount=type=ssh \
44+
--mount=type=cache,target=/usr/local/cargo/registry \
45+
--mount=type=cache,target=/usr/local/cargo/git \
46+
--mount=type=cache,target=/app/target \
47+
cargo build --release -p node && \
48+
cp target/release/node /node-temp
49+
50+
# Runtime stage
51+
FROM debian:bookworm-slim AS runtime
52+
53+
# Install necessary runtime dependencies and Docker
54+
RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && \
55+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
56+
ca-certificates \
57+
gcc \
58+
libc6-dev \
59+
wget \
60+
curl \
61+
gnupg && \
62+
update-ca-certificates && \
63+
install -m 0755 -d /etc/apt/keyrings && \
64+
curl -fsSL --insecure https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
65+
chmod a+r /etc/apt/keyrings/docker.gpg && \
66+
echo \
67+
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
68+
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
69+
tee /etc/apt/sources.list.d/docker.list > /dev/null && \
70+
DEBIAN_FRONTEND=noninteractive apt-get update && \
71+
DEBIAN_FRONTEND=noninteractive apt-get install -y docker-ce docker-ce-cli containerd.io && \
72+
DEBIAN_FRONTEND=noninteractive apt-get clean && \
73+
rm -rf /var/lib/apt/lists/*
74+
75+
# Set up working directory
76+
WORKDIR /app
77+
78+
# Copy the built binary from the build stage
79+
COPY --from=build /node-temp /app/node
80+
81+
# Set the entrypoint to run the node binary
82+
ENTRYPOINT ["/app/node"]

Dockerfile.gpu

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Build stage
2+
FROM rustlang/rust:nightly-slim AS build
3+
4+
# Install necessary packages for building
5+
RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && \
6+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
7+
openssl \
8+
libssl-dev \
9+
pkg-config \
10+
protobuf-compiler \
11+
build-essential \
12+
wget \
13+
tar \
14+
libclang-dev \
15+
curl \
16+
git
17+
18+
# Install Go (needed for native-gnark)
19+
ENV GO_VERSION=1.22.1
20+
ARG TARGETARCH
21+
RUN wget -q https://golang.org/dl/go$GO_VERSION.linux-${TARGETARCH}.tar.gz && \
22+
tar -C /usr/local -xzf go$GO_VERSION.linux-${TARGETARCH}.tar.gz && \
23+
rm go$GO_VERSION.linux-${TARGETARCH}.tar.gz
24+
ENV PATH=$PATH:/usr/local/go/bin
25+
26+
# Install sp1up and the SP1 toolchain
27+
ENV SP1_HOME="/root/.sp1"
28+
ENV PATH="${SP1_HOME}/bin:${PATH}"
29+
RUN curl -L https://sp1.succinct.xyz | bash && \
30+
sp1up
31+
32+
# Prepare for git dependencies
33+
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
34+
RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
35+
36+
# Copy the entire workspace (including root Cargo.toml and all crates)
37+
COPY . /app
38+
WORKDIR /app
39+
40+
ENV VERGEN_CARGO_PROFILE=release
41+
42+
# Build only the node binary
43+
RUN --mount=type=ssh \
44+
--mount=type=cache,target=/usr/local/cargo/registry \
45+
--mount=type=cache,target=/usr/local/cargo/git \
46+
--mount=type=cache,target=/app/target \
47+
cargo build --release -p node && \
48+
cp target/release/node /node-temp
49+
50+
# Runtime stage
51+
FROM --platform=linux/amd64 nvidia/cuda:12.5.0-runtime-ubuntu22.04 AS runtime
52+
53+
# Install necessary runtime dependencies and Docker
54+
RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && \
55+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
56+
ca-certificates \
57+
gcc \
58+
libc6-dev \
59+
wget \
60+
curl \
61+
gnupg && \
62+
update-ca-certificates && \
63+
install -m 0755 -d /etc/apt/keyrings && \
64+
curl -fsSL --insecure https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
65+
chmod a+r /etc/apt/keyrings/docker.gpg && \
66+
echo \
67+
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
68+
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
69+
tee /etc/apt/sources.list.d/docker.list > /dev/null && \
70+
DEBIAN_FRONTEND=noninteractive apt-get update && \
71+
DEBIAN_FRONTEND=noninteractive apt-get install -y docker-ce docker-ce-cli containerd.io && \
72+
DEBIAN_FRONTEND=noninteractive apt-get clean && \
73+
rm -rf /var/lib/apt/lists/*
74+
75+
# Set up working directory
76+
WORKDIR /app
77+
78+
# Copy the built binary from the build stage
79+
COPY --from=build /node-temp /app/node
80+
81+
# Set the entrypoint to run the node binary
82+
ENTRYPOINT ["/app/node"]

GETTING_STARTED.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- [A GPU machine](https://docs.succinct.xyz/docs/sp1/generating-proofs/hardware-acceleration)
66
- [A wallet with sepolia ETH](https://sepolia-faucet.pk910.de/)
7+
- You'll export the wallet private key to run your prover from the command line, so it's
8+
recommended to have a wallet without many funds.
79

810
## Step 1: Create a prover
911

0 commit comments

Comments
 (0)