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

Add cruntime package #12

Closed
wants to merge 11 commits into from
Closed

Conversation

endersonmaia
Copy link
Contributor

@endersonmaia endersonmaia commented May 2, 2024

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:

@endersonmaia endersonmaia self-assigned this May 2, 2024
Copy link

changeset-bot bot commented May 2, 2024

🦋 Changeset detected

Latest commit: 7fc8c0a

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

@endersonmaia endersonmaia requested a review from tuler May 2, 2024 11:00
@endersonmaia endersonmaia force-pushed the feat/add-cruntime-for-machine-sdk-17 branch from 4337c8e to eeb9b62 Compare May 3, 2024 14:09
chiselled cruntime rootfs based on ubuntu:24.04
#
FROM ${IMAGE_REGISTRY}/${IMAGE_NAMESPACE}/${IMAGE_NAME}:$IMAGE_TAG AS base-image
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates
Copy link
Member

Choose a reason for hiding this comment

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

ideally this image should be reproducible right? so it's safer to lock the ca-certificates version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only use this so it's possible to download packages with chisel later.

On the reproducibility side, chisel itself doesn't support defining specific versions of packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add the ca-certificates version anyway.

base-passwd_data \
# machine-emulator-tools dependencies
busybox-static_bins \
libgcc-s1_libs \
Copy link
Member

Choose a reason for hiding this comment

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

is this explicitly required, or should come by transitive dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The installation of mahine-emulator-tools is made outside the chisel process, so we need to do this way.

Copy link
Member

Choose a reason for hiding this comment

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

But doesn't the debian installation of the tools bring what is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not installing, but just extracting its contents.

If I install it, it's gonna pollute the /rootfs that should be minimal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants