Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aads cargo chef to docker build for rust template #36

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
22 changes: 18 additions & 4 deletions rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# syntax=docker.io/docker/dockerfile:1
FROM ubuntu:22.04 as builder
FROM ubuntu:22.04 as base

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.72.0
RUST_VERSION=1.76.0

ARG DEBIAN_FRONTEND=noninteractive
RUN <<EOF
Expand Down Expand Up @@ -38,11 +38,25 @@ RUN set -eux; \
rustc --version;

RUN rustup target add riscv64gc-unknown-linux-gnu

RUN cargo install cargo-chef
WORKDIR /opt/cartesi/dapp

### the planner helps cache dependency builds

FROM base AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

### Builder cross-compiles the dapp for riscv64

FROM base as builder
COPY --from=planner /opt/cartesi/dapp/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release

### final image is the dapp itself

FROM --platform=linux/riscv64 riscv64/ubuntu:22.04

ARG MACHINE_EMULATOR_TOOLS_VERSION=0.12.0
Expand All @@ -58,7 +72,7 @@ RUN <<EOF
set -e
apt-get update
apt-get install -y --no-install-recommends \
busybox-static=1:1.30.1-7ubuntu3
busybox-static=1:1.30.1-7ubuntu3
rm -rf /var/lib/apt/lists/*
EOF

Expand Down