Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Build artifacts
target/
Dockerfile
.dockerignore

# Git
.git/
.gitignore
93 changes: 93 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build-and-push:
runs-on: ubuntu-24.04-16core
strategy:
matrix:
profile:
- "release"
risczero_version:
- "3.0.3"
risczero_groth16_version:
- "0.1.0"
feature:
- "default"
- "cuda"
exclude:
- profile: "default"
risczero_groth16_version: "0.1.0"
permissions:
contents: read
packages: write
actions: read
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
submodules: recursive
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build docker tag
id: image_tag
shell: bash
run: |
set -euo pipefail
tag='${{ github.ref_name }}'
profile='${{ matrix.profile }}'
feature='${{ matrix.feature }}'

suffix=""
if [[ "${profile}" != "release" && -n "${profile}" ]]; then
suffix="${suffix}-${profile}"
fi

if [[ "${feature}" != "default" && -n "${feature}" ]]; then
suffix="${suffix}-${feature}"
fi

echo "result=${tag}${suffix}" >> "$GITHUB_OUTPUT"
- name: Prepare cache bucket for cache mounts
id: crates-cache
uses: actions/cache@v4
with:
path: cache-mount/${{ matrix.feature }}
key: cargo-mount-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-mount-${{ matrix.feature }}
cargo-mount-
- name: Inject cache mounts
uses: reproducible-containers/buildkit-cache-dance@5b81f4d29dc8397a7d341dba3aeecc7ec54d6361 # v3.3.0
with:
builder: ${{ steps.buildx.outputs.name }}
dockerfile: ./dockerfiles/${{ matrix.feature }}.Dockerfile
cache-dir: cache-mount/${{ matrix.feature }}
skip-extraction: ${{ steps.crates-cache.outputs.cache-hit }}
- name: Build and push
uses: docker/build-push-action@v6
env:
BUILDX_GIT_LABELS: 1
with:
context: .
file: ./dockerfiles/${{ matrix.feature }}.Dockerfile
build-args: |
FEATURES=${{ matrix.feature }}
PROFILE=${{ matrix.profile }}
CARGO_RISCZERO_VARSION=${{ matrix.risczero_version }}
RISCZERO_GROTH16_VERSION=${{ matrix.risczero_groth16_version }}
tags: |
ghcr.io/${{ github.repository }}:${{ steps.image_tag.outputs.result }}
push: true
cache-to: type=gha,mode=max,scope=${{ github.repository }}-${{ matrix.profile }}-${{ matrix.feature }}
cache-from: type=gha,scope=${{ github.repository }}-${{ matrix.profile }}-${{ matrix.feature }}
68 changes: 68 additions & 0 deletions dockerfiles/cuda.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM nvidia/cuda:13.0.1-cudnn-devel-ubuntu24.04 AS builder

WORKDIR /app

ARG FEATURES
ARG PROFILE="release"
ARG CARGO_RISCZERO_VERSION
ARG RISCZERO_GROTH16_VERSION

LABEL jp.datachain.rust.features="[${FEATURES}]" \
jp.datachain.rust.profile=${PROFILE} \
jp.datachain.risczero.runtime.version=${CARGO_RISCZERO_VERSION} \
jp.datachain.risczero.groth16.version=${RISCZERO_GROTH16_VERSION}

RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
gnupg \
build-essential \
clang \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*

# Install Rust
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

COPY . .

# Build bonsai-local
RUN --mount=type=cache,target=${CARGO_HOME}/registry,id=cargo-reg,sharing=locked \
--mount=type=cache,target=${CARGO_HOME}/git,id=cargo-git,sharing=locked \
--mount=type=cache,target=/app/target,id=cargo-target \
cargo build --profile ${PROFILE} --features ${FEATURES} \
&& cp /app/target/${PROFILE}/bonsai-local /usr/local/bin/bonsai-local

FROM nvidia/cuda:13.0.1-cudnn-runtime-ubuntu24.04

RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
curl \
gnupg \
lsb-release \
libssl-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

# Install Rust
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Install RISC Zero runtime
RUN curl -L https://risczero.com/install | bash
ENV PATH="/root/.risc0/bin:${PATH}"
RUN rzup install rust && \
rzup install cargo-risczero ${CARGO_RISCZERO_VERSION} && \
rzup install risc0-groth16 ${RISCZERO_GROTH16_VERSION}
Comment thread
bluele marked this conversation as resolved.

EXPOSE 8080

COPY --from=builder /usr/local/bin/bonsai-local /usr/local/bin/bonsai-local

ENTRYPOINT ["bonsai-local"]
58 changes: 58 additions & 0 deletions dockerfiles/default.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM ubuntu:24.04

WORKDIR /app

ARG FEATURES="default"
ARG PROFILE="release"
ARG CARGO_RISCZERO_VERSION

LABEL jp.datachain.rust.features="[${FEATURES}]" \
jp.datachain.rust.profile=${PROFILE} \
jp.datachain.risczero.runtime.version=${CARGO_RISCZERO_VERSION}

RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
curl \
gnupg \
lsb-release \
build-essential \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*

# Install Rust
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

COPY . .

# Build bonsai-local
RUN --mount=type=cache,target=${CARGO_HOME}/registry,id=cargo-reg,sharing=locked \
--mount=type=cache,target=${CARGO_HOME}/git,id=cargo-git,sharing=locked \
--mount=type=cache,target=/app/target,id=cargo-target \
cargo build --profile ${PROFILE} --features ${FEATURES} \
&& cp /app/target/${PROFILE}/bonsai-local /usr/local/bin/bonsai-local

# Install RISC Zero runtime
RUN curl -L https://risczero.com/install | bash
ENV PATH="/root/.risc0/bin:${PATH}"
RUN rzup install rust && rzup install cargo-risczero ${CARGO_RISCZERO_VERSION}

# Install Docker CLI only
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
apt-get update && \
apt-get install -y docker-ce-cli && \
rm -rf /var/lib/apt/lists/*

RUN groupadd -f docker && usermod -aG docker root

VOLUME /var/run/docker.sock

EXPOSE 8080

ENTRYPOINT ["bonsai-local"]