From 3072a83f6bf49b869869b1a85aa34070ff5c4f26 Mon Sep 17 00:00:00 2001 From: Bruno Menezes Date: Mon, 23 Mar 2026 18:11:07 +0000 Subject: [PATCH 1/2] feat(cli): Update explorer compose configuration for new explorer. * Removed database dependencies. * Removed api-service definitions. * Removed indexer definitions. * Setup new docker depends on [anvil , node] * Add a health check for the explorer service. --- .changeset/young-foxes-try.md | 5 ++ apps/cli/src/compose/explorer.ts | 116 ++++--------------------------- 2 files changed, 19 insertions(+), 102 deletions(-) create mode 100644 .changeset/young-foxes-try.md diff --git a/.changeset/young-foxes-try.md b/.changeset/young-foxes-try.md new file mode 100644 index 00000000..fdfa896e --- /dev/null +++ b/.changeset/young-foxes-try.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": patch +--- + +Update explorer compose definitions to integrate with new rollups-explorer service. diff --git a/apps/cli/src/compose/explorer.ts b/apps/cli/src/compose/explorer.ts index 5dfa438c..40a9c5db 100644 --- a/apps/cli/src/compose/explorer.ts +++ b/apps/cli/src/compose/explorer.ts @@ -1,34 +1,26 @@ -import { anvil } from "viem/chains"; import type { ComposeFile, Config, Service } from "../types/compose.js"; import { DEFAULT_HEALTHCHECK } from "./common.js"; type ServiceOptions = { - databaseHost?: string; - databasePassword: string; - databasePort?: number; - apiTag?: string; imageTag?: string; port?: number; }; -// Explorer API service -export const apiService = (options: ServiceOptions): Service => { - const imageTag = options.apiTag ?? "latest"; - const databasePassword = options.databasePassword; - const databaseHost = options.databaseHost ?? "database"; - const databasePort = options.databasePort ?? 5432; +// Explorer service +export const explorerService = (options: ServiceOptions): Service => { + const imageTag = options.imageTag ?? "latest"; + const port = options.port ?? 6571; + + const nodeRpcUrl = `http://127.0.0.1:${port}/anvil`; + const cartesiNodeRpcUrl = `http://127.0.0.1:${port}/rpc`; return { - image: `cartesi/rollups-explorer-api:${imageTag}`, + image: `cartesi/rollups-explorer:${imageTag}`, environment: { - DB_PORT: databasePort.toString(), - DB_HOST: databaseHost, - DB_PASS: databasePassword, - DB_NAME: "explorer", - GQL_PORT: 4350, + NODE_RPC_URL: nodeRpcUrl, + CARTESI_NODE_RPC_URL: cartesiNodeRpcUrl, }, - expose: ["4350"], - command: ["sqd", "serve:prod"], + expose: ["3000"], healthcheck: { ...DEFAULT_HEALTHCHECK, test: [ @@ -36,86 +28,13 @@ export const apiService = (options: ServiceOptions): Service => { "wget", "--spider", "-q", - "http://127.0.0.1:4350/graphql?query=%7B__typename%7D", + `http://127.0.0.1:3000/explorer/api/healthz`, ], }, - depends_on: { - database: { condition: "service_healthy" }, - }, - }; -}; -// Explorer API Proxy configuration -export const explorerApiProxyConfig = (): Config => { - return { - name: "explorer-api-proxy", - content: `http: - routers: - explorer-api: - rule: "PathPrefix(\`/explorer-api\`)" - middlewares: - - "remove-explorer-api-prefix" - service: explorer_api - middlewares: - remove-explorer-api-prefix: - replacePathRegex: - regex: "^/explorer-api/(.*)" - replacement: "/$1" - services: - explorer_api: - loadBalancer: - servers: - - url: "http://explorer_api:4350" -`, - }; -}; - -// Squid Processor service -export const squidProcessorService = (options: ServiceOptions): Service => { - const imageTag = options.apiTag ?? "latest"; - const databasePassword = options.databasePassword; - const databaseHost = options.databaseHost ?? "database"; - const databasePort = options.databasePort ?? 5432; - const chain = anvil; - const environment: Record = { - DB_HOST: databaseHost, - DB_NAME: "explorer", - DB_PASS: databasePassword, - DB_PORT: databasePort.toString(), - CHAIN_IDS: chain.id.toString(), - }; - environment[`RPC_URL_${chain.id}`] = `http://anvil:8545`; - environment[`BLOCK_CONFIRMATIONS_${chain.id}`] = 0; - environment[`GENESIS_BLOCK_${chain.id}`] = 1; - - return { - image: `cartesi/rollups-explorer-api:${imageTag}`, - environment, - command: ["sqd", "process:prod"], - depends_on: { - database: { condition: "service_healthy" }, - }, - }; -}; - -// Explorer service -export const explorerService = (options: ServiceOptions): Service => { - const imageTag = options.imageTag ?? "latest"; - const port = options.port ?? 6571; - - const nodeRpcUrl = `http://127.0.0.1:${port}/anvil`; - const explorerApiUrl = `http://127.0.0.1:${port}/explorer-api/graphql`; - - return { - image: `cartesi/rollups-explorer:${imageTag}`, - environment: { - CHAIN_ID: 31337, - EXPLORER_API_URL: explorerApiUrl, - NODE_RPC_URL: nodeRpcUrl, - }, - expose: ["3000"], depends_on: { - database: { condition: "service_healthy" }, + anvil: { condition: "service_healthy" }, + rollups_node: { condition: "service_healthy" }, }, }; }; @@ -139,23 +58,16 @@ export const explorerProxyConfig = (): Config => { export default (options: ServiceOptions): ComposeFile => ({ configs: { - explorer_api_proxy: explorerApiProxyConfig(), explorer_proxy: explorerProxyConfig(), }, services: { - explorer_api: apiService(options), explorer: explorerService(options), - squid_processor: squidProcessorService(options), proxy: { configs: [ { source: "explorer_proxy", target: "/etc/traefik/conf.d/explorer.yaml", }, - { - source: "explorer_api_proxy", - target: "/etc/traefik/conf.d/explorer-api.yaml", - }, ], }, }, From 20f8daa899669d85460b2b010f99097054467341 Mon Sep 17 00:00:00 2001 From: Bruno Menezes Date: Mon, 23 Mar 2026 18:14:46 +0000 Subject: [PATCH 2/2] feat: Set healthy-semaphore config and target image-tag for explorer service. --- apps/cli/src/exec/rollups.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/cli/src/exec/rollups.ts b/apps/cli/src/exec/rollups.ts index aaa79f77..2c937e41 100644 --- a/apps/cli/src/exec/rollups.ts +++ b/apps/cli/src/exec/rollups.ts @@ -182,7 +182,7 @@ const availableServices: Service[] = [ }, { name: "explorer", - healthySemaphore: "explorer_api", + healthySemaphore: "explorer", healthyTitle: (port) => `${chalk.cyan("explorer")} service ready at ${chalk.cyan(`${host}:${port}/explorer`)}`, waitTitle: `${chalk.cyan("explorer")} service starting...`, @@ -302,9 +302,7 @@ export const startEnvironment = async (options: { if (services.includes("explorer")) { files.push( explorer({ - imageTag: "1.4.0", - apiTag: "1.1.0", - databasePassword, + imageTag: "2.0.0-alpha.1", port, }), );