cartesi / cli

Cartesi CLI tool
Apache License 2.0
3 stars 3 forks source link

Add cruntime package #12

Open endersonmaia opened 2 months ago

endersonmaia commented 2 months ago

This will make it possible for Cartesi application developer to create their application Dockerfile without the need to install machine-emulator-tools and its dependencies but just the application code itself.

For ex., the following Dockerfile could be used for a javascript application:

FROM node:20.8.0-bookworm as build-stage
WORKDIR /opt/cartesi/dapp
COPY . .
RUN yarn install && yarn build

FROM --platform=linux/riscv64 cartesi/node:20.8.0-jammy-slim
WORKDIR /opt/cartesi/dapp
COPY --from=build-stage /opt/cartesi/dapp/dist .
CMD ["node", "index.js"]

How to test:

pnpm install && pnpm build
docker image tag cartesi/cruntime:devel cartesi/cruntime:0.1.0
alias cartesi-dev=$PWD/apps/cli/bin/run.js

With that, you can build an application with the sample Dockerfile above using

cartesi-dev build
cartesi-dev run
cartesi-dev send

You could also try running with cartesi-dev --no-backend and running the application container with docker:

docker build -t jsdapp . -f Dockerfile
cartesi-dev --no-backend
docker run -ti --rm -e ROLLUP_HTTP_SERVER_URL=http://localhost:8080/host-runner --network=host jsdapp
cartesi-dev send

Details:

We used chisel to make a small runtime image with crun and its dependencies.

We compiled crun ourselves to use the latest crun version and remove what we don't need.

References:

changeset-bot[bot] commented 2 months ago

🦋 Changeset detected

Latest commit: 7fc8c0a8abd46eefa5e9e48641a4cff809891b44

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR