diff --git a/.changeset/fast-pumpkins-tickle.md b/.changeset/fast-pumpkins-tickle.md new file mode 100644 index 00000000..27e324e5 --- /dev/null +++ b/.changeset/fast-pumpkins-tickle.md @@ -0,0 +1,5 @@ +--- +"@cartesi/sdk": patch +--- + +add cartesi/rollups-database container image release diff --git a/.changeset/honest-spoons-appear.md b/.changeset/honest-spoons-appear.md new file mode 100644 index 00000000..c38b6855 --- /dev/null +++ b/.changeset/honest-spoons-appear.md @@ -0,0 +1,5 @@ +--- +"@cartesi/sdk": patch +--- + +bump debian base image to bookworm-20250317-slim diff --git a/.changeset/hot-timers-repair.md b/.changeset/hot-timers-repair.md new file mode 100644 index 00000000..01ef3599 --- /dev/null +++ b/.changeset/hot-timers-repair.md @@ -0,0 +1,5 @@ +--- +"@cartesi/sdk": patch +--- + +create databases and run migrations for preinitialized PostgreSQL database diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml new file mode 100644 index 00000000..cf33965a --- /dev/null +++ b/.github/workflows/database.yaml @@ -0,0 +1,91 @@ +name: database +on: + workflow_call: + secrets: + DOCKERHUB_USERNAME: + required: true + DOCKERHUB_TOKEN: + required: true + pull_request: + paths: + - .github/workflows/database.yaml + - packages/sdk/** +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true +permissions: + contents: read + packages: write + id-token: write + actions: write +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Get package tag/version + id: package-version + if: ${{ github.event_name == 'push' }} + run: | + jq -r '"PACKAGE_VERSION=\(.version)"' packages/sdk/package.json >> "$GITHUB_OUTPUT" + + - name: Docker meta + id: meta + uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 + with: + images: | + docker.io/cartesi/rollups-database,enable=${{ github.event_name != 'pull_request' }} + ghcr.io/cartesi/rollups-database + tags: | + type=raw,value=${{ steps.package-version.outputs.PACKAGE_VERSION }},enable=${{ github.event_name == 'push' }} + type=ref,event=pr + labels: | + org.opencontainers.image.title=Cartesi Rollups Database + org.opencontainers.image.description=Cartesi Rollups SDK Database with pre-initialized PostgreSQL Database + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 + + - name: Login to GitHub Container Registry + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to DockerHub + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/bake-action@4a9a8d494466d37134e2bfca2d3a8de8fb2681ad # v5.13.0 + if: ${{ !startsWith(github.ref, 'refs/tags/sdk@') }} + with: + workdir: packages/sdk + targets: database + files: | + ./docker-bake.hcl + ./docker-bake.platforms.hcl + ${{ steps.meta.outputs.bake-file }} + set: | + *.cache-from=type=gha + *.cache-to=type=gha,mode=max + push: true + + - uses: depot/setup-action@b0b1ea4f69e92ebf5dea3f8713a1b0c37b2126a5 # v1.6.0 + - name: Build and push (depot) + uses: depot/bake-action@58d7160c6bfa64eb85e384209e6f2f5ad17948bb # v1.11.0 + if: ${{ startsWith(github.ref, 'refs/tags/sdk@') }} + with: + project: ${{ vars.DEPOT_PROJECT }} + workdir: packages/sdk + targets: database + files: | + ./docker-bake.hcl + ./docker-bake.platforms.hcl + ${{ steps.meta.outputs.bake-file }} + push: true diff --git a/.github/workflows/runtime.yaml b/.github/workflows/runtime.yaml new file mode 100644 index 00000000..e31f92a0 --- /dev/null +++ b/.github/workflows/runtime.yaml @@ -0,0 +1,91 @@ +name: runtime +on: + workflow_call: + secrets: + DOCKERHUB_USERNAME: + required: true + DOCKERHUB_TOKEN: + required: true + pull_request: + paths: + - .github/workflows/runtime.yaml + - packages/sdk/** +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true +permissions: + contents: read + packages: write + id-token: write + actions: write +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Get package tag/version + id: package-version + if: ${{ github.event_name == 'push' }} + run: | + jq -r '"PACKAGE_VERSION=\(.version)"' packages/sdk/package.json >> "$GITHUB_OUTPUT" + + - name: Docker meta + id: meta + uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 + with: + images: | + docker.io/cartesi/sdk-node,enable=${{ github.event_name != 'pull_request' }} + ghcr.io/cartesi/sdk-node + tags: | + type=raw,value=${{ steps.package-version.outputs.PACKAGE_VERSION }},enable=${{ github.event_name == 'push' }} + type=ref,event=pr + labels: | + org.opencontainers.image.title=Cartesi Rollups SDK Node + org.opencontainers.image.description=Cartesi Rollups SDK Node with optional services + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 + + - name: Login to GitHub Container Registry + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to DockerHub + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/bake-action@4a9a8d494466d37134e2bfca2d3a8de8fb2681ad # v5.13.0 + if: ${{ !startsWith(github.ref, 'refs/tags/sdk@') }} + with: + workdir: packages/sdk + targets: runtime + files: | + ./docker-bake.hcl + ./docker-bake.platforms.hcl + ${{ steps.meta.outputs.bake-file }} + set: | + *.cache-from=type=gha + *.cache-to=type=gha,mode=max + push: true + + - uses: depot/setup-action@b0b1ea4f69e92ebf5dea3f8713a1b0c37b2126a5 # v1.6.0 + - name: Build and push (depot) + uses: depot/bake-action@58d7160c6bfa64eb85e384209e6f2f5ad17948bb # v1.11.0 + if: ${{ startsWith(github.ref, 'refs/tags/sdk@') }} + with: + project: ${{ vars.DEPOT_PROJECT }} + workdir: packages/sdk + targets: runtime + files: | + ./docker-bake.hcl + ./docker-bake.platforms.hcl + ${{ steps.meta.outputs.bake-file }} + push: true diff --git a/packages/sdk/Dockerfile b/packages/sdk/Dockerfile index 2c00f7f5..80818f41 100644 --- a/packages/sdk/Dockerfile +++ b/packages/sdk/Dockerfile @@ -1,25 +1,15 @@ # syntax=docker.io/docker/dockerfile:1 -ARG BASE_IMAGE -ARG CARTESI_ESPRESSO_READER_VERSION -ARG CARTESI_IMAGE_KERNEL_VERSION -ARG CARTESI_MACHINE_EMULATOR_VERSION -ARG CARTESI_ROLLUPS_GRAPHQL_VERSION -ARG CRANE_VERSION -ARG ESPRESSO_DEV_NODE_TAG -ARG FOUNDRY_VERSION -ARG LINUX_KERNEL_VERSION -ARG NODEJS_VERSION -ARG POSTGRES_VERSION -ARG SU_EXEC_VERSION -ARG XGENEXT2_VERSION +ARG CARTESI_BASE_IMAGE +ARG ESPRESSO_DEV_NODE_BASE_IMAGE +ARG POSTGRES_BASE_IMAGE ################################################################################ # https://github.com/EspressoSystems/espresso-sequencer/pkgs/container/espresso-sequencer%2Fespresso-dev-node -FROM ghcr.io/espressosystems/espresso-sequencer/espresso-dev-node:${ESPRESSO_DEV_NODE_TAG} AS espresso-dev-node +FROM ${ESPRESSO_DEV_NODE_BASE_IMAGE} AS espresso-dev-node ################################################################################ # base image -FROM ${BASE_IMAGE} AS base +FROM ${CARTESI_BASE_IMAGE} AS base SHELL ["/bin/bash", "-euo", "pipefail", "-c"] ARG DEBIAN_FRONTEND=noninteractive RUN < /etc/apt/sources.list.d/backports.list apt-get update apt-get install -y --no-install-recommends -t bookworm-backports \ @@ -188,8 +289,8 @@ EOF # Install nodejs packages RUN <