Skip to content

Conversation

@endersonmaia
Copy link
Contributor

@endersonmaia endersonmaia commented Mar 18, 2025

This pull request includes several changes to the @cartesi/sdk package, focusing on updating Docker images, adding new workflows, and modifying the Dockerfile. The most important changes include adding new container image releases, updating base images, creating databases with migrations, and adding new GitHub workflows for building and pushing Docker images.

Updates to Docker images and base images:

  • Updated the Debian base image to bookworm-20250317-slim in .changeset/honest-spoons-appear.md and packages/sdk/docker-bake.hcl. [1] [2]
  • Added new container image releases for cartesi/rollups-database and updated the Dockerfile to use new base images for cartesi, espresso-dev-node, and postgres. [1] [2] [3] [4] [5]

Database migrations:

  • Created databases and ran migrations for a preinitialized PostgreSQL database in .changeset/hot-timers-repair.md.
  • Modified the Dockerfile to include scripts for creating and migrating databases for rollupsdb, graphql, and espresso.

New GitHub workflows:

  • Added rollups-database.yml and runtime.yml workflows to build and push Docker images for rollups-database and sdk-node. [1] [2]

Dockerfile modifications:

  • Refactored the Dockerfile to use new ARGs for base images and added steps to install necessary packages and set up the environment. [1] [2] [3] [4] [5]

Docker bake configuration:

  • Updated docker-bake.hcl and docker-bake.override.hcl to include new targets for runtime and database, and set appropriate tags for the images. [1] [2]

@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2025

🦋 Changeset detected

Latest commit: b842d98

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

This PR includes changesets to release 1 package
Name Type
@cartesi/sdk Patch

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

@tuler tuler changed the title Feature/sdk extra images SDK image = runtime image + development utilities Mar 18, 2025
@endersonmaia endersonmaia force-pushed the feature/sdk-extra-images branch from 1129770 to 1c04a25 Compare March 20, 2025 19:38
@endersonmaia endersonmaia requested a review from tuler March 20, 2025 19:44
@endersonmaia endersonmaia marked this pull request as ready for review March 20, 2025 19:52
@endersonmaia endersonmaia self-assigned this Mar 20, 2025
Copy link
Member

@tuler tuler left a comment

Choose a reason for hiding this comment

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

I think the order should be something like:

FROM debian as runtime
# add cartesi-machine
# add cartesi-rollups-node
# add graphql
# add espresso-reader

FROM runtime as sdk
# add anvil
# add devnet
# add crane
# add genext2fsx
# add migrations

}

target "rollups-node" {
tags = ["cartesi/sdk-node:devel"]
Copy link
Member

Choose a reason for hiding this comment

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

let's discuss a bit more on this name

@tuler tuler linked an issue Mar 20, 2025 that may be closed by this pull request
3 tasks
@endersonmaia
Copy link
Contributor Author

I think the order should be something like:

FROM debian as runtime
# add cartesi-machine
# add cartesi-rollups-node
# add graphql
# add espresso-reader

FROM runtime as sdk
# add anvil
# add devnet
# add crane
# add genext2fsx
# add migrations

Yeah, I decided to use node:slim as the base for the sdk to reduce the size a little bit.

The order you suggested makes the code more clean at the expense of some MB in the final sdk image.

@endersonmaia
Copy link
Contributor Author

I think the order should be something like:

FROM debian as runtime
# add cartesi-machine
# add cartesi-rollups-node
# add graphql
# add espresso-reader

FROM runtime as sdk
# add anvil
# add devnet
# add crane
# add genext2fsx
# add migrations

Yeah, I decided to use node:slim as the base for the sdk to reduce the size a little bit.

The order you suggested makes the code more clean at the expense of some MB in the final sdk image.

Just accepted your suggestion after evaluating the size difference was negligible.

@endersonmaia endersonmaia force-pushed the feature/sdk-extra-images branch from 5343b63 to 2c9ae08 Compare March 24, 2025 13:49
@endersonmaia endersonmaia requested a review from tuler March 24, 2025 13:53
@endersonmaia
Copy link
Contributor Author

We still need to define the naming, and we make the final fixups to stick with whatever naming is decided.

@@ -0,0 +1,91 @@
name: rollups-database
Copy link
Member

Choose a reason for hiding this comment

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

use database and database.yaml to follow name convention.

cartesi
EOF

RUN mkdir -p /tmp/.cartesi && chmod 1777 /tmp/.cartesi
Copy link
Member

Choose a reason for hiding this comment

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

I think we don't need this anymore

EOF

COPY --from=runtime /usr/bin/cartesi-rollups-cli /usr/bin/
COPY --from=runtime /usr/lib/libcartesi* /usr/lib/
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 safe? why is it 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.

We need this to run cartesi-rollups-cli without the need to reinstall its package.

USER root
ARG DEBIAN_FRONTEND=noninteractive
RUN <<EOF
apt-get update
Copy link
Member

Choose a reason for hiding this comment

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

some of the packages below were already installed by runtime base

@tuler
Copy link
Member

tuler commented Mar 24, 2025

Here is a commit organization that may be better to review and merge:

A commit with only the Dockerfile. No other change is necessary to the workflows, as the final default target is the sdk as it is today. That is already mergable by itself.

Then we handle the case for database and runtime on top of that.
I have an idea for the workflow that might simplify it.

A container image will be released only with the binaries needed to run
a rollups-node with optional auxiliary services like rollups-graphql and
espresso-reader.
This container image will be based on postgres and contains a
pre-initialized database with rollups-node, rollups-graphql and espresso-reader
database migrations ready to be used.
@endersonmaia endersonmaia force-pushed the feature/sdk-extra-images branch from 1ae64db to 113129b Compare March 24, 2025 16:00
@endersonmaia
Copy link
Contributor Author

A commit with only the Dockerfile. No other change is necessary to the workflows, as the final default target is the sdk as it is today. That is already mergable by itself.

There's a PR attempt for that at #207

@endersonmaia
Copy link
Contributor Author

endersonmaia commented Mar 24, 2025

Then we handle the case for database and runtime on top of that.

Another PR for that: #209

@tuler
Copy link
Member

tuler commented Mar 25, 2025

Superseded by #209

@tuler tuler closed this Mar 25, 2025
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.

Runtime and SDK images

3 participants