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 1 commit
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
33 changes: 24 additions & 9 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

RUN <<EOF
set -e
Expand Down Expand Up @@ -37,26 +37,41 @@ 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 depdenency builds
willemolding marked this conversation as resolved.
Show resolved Hide resolved

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

FROM --platform=linux/riscv64 riscv64/ubuntu:22.04
### final image is the dapp itself

ARG MACHINE_EMULATOR_TOOLS_VERSION=0.12.0
ADD https://github.com/cartesi/machine-emulator-tools/releases/download/v${MACHINE_EMULATOR_TOOLS_VERSION}/machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb /
RUN dpkg -i /machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb \
&& rm /machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb
FROM --platform=linux/riscv64 riscv64/ubuntu:22.04

LABEL io.sunodo.sdk_version=0.2.0
LABEL io.cartesi.rollups.ram_size=128Mi

ARG MACHINE_EMULATOR_TOOLS_VERSION=0.12.0

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 \
ca-certificates=20230311ubuntu0.22.04.1 \
curl=7.81.0-1ubuntu1.15
curl -fsSL https://github.com/cartesi/machine-emulator-tools/releases/download/v${MACHINE_EMULATOR_TOOLS_VERSION}/machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.tar.gz \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at the other templates in the main branch.
We switched to use ADD instead of curl.
Just for consistency.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that is much cleaner. Made the change here as well

| tar -C / --overwrite -xvzf -
rm -rf /var/lib/apt/lists/*
EOF

Expand Down
Loading