diff --git a/.changeset/heavy-penguins-act.md b/.changeset/heavy-penguins-act.md new file mode 100644 index 00000000..ce6f4941 --- /dev/null +++ b/.changeset/heavy-penguins-act.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": major +--- + +expose graphql endpoint diff --git a/apps/cli/src/commands/run.ts b/apps/cli/src/commands/run.ts index 4dd12bb6..f989f437 100644 --- a/apps/cli/src/commands/run.ts +++ b/apps/cli/src/commands/run.ts @@ -35,6 +35,12 @@ export default class Run extends BaseCommand { "disable local paymaster service to save machine resources", summary: "disable paymaster service", }), + "disable-graphql": Flags.boolean({ + default: false, + description: + "disable local graphql service to save machine resources", + summary: "disable graphql service", + }), "epoch-length": Flags.integer({ description: "length of an epoch (in blocks)", default: 720, @@ -136,6 +142,11 @@ export default class Run extends BaseCommand { // proxy composeFiles.push("docker-compose-proxy.yaml"); + // graphql + if (!flags["disable-graphql"]) { + composeFiles.push("docker-compose-graphql.yaml"); + } + // anvil composeFiles.push("docker-compose-anvil.yaml"); diff --git a/apps/cli/src/node/docker-compose-graphql.yaml b/apps/cli/src/node/docker-compose-graphql.yaml new file mode 100644 index 00000000..2f4431fe --- /dev/null +++ b/apps/cli/src/node/docker-compose-graphql.yaml @@ -0,0 +1,51 @@ +services: + graphql_database_creator: + image: postgres:15-alpine + command: ["createdb", "hlgraphql"] + depends_on: + database: + condition: service_healthy + environment: + PGHOST: ${PGHOST:-database} + PGPORT: ${PGPORT:-5432} + PGUSER: ${PGUSER:-postgres} + PGPASSWORD: ${PGPASSWORD:-password} + PGDATABASE: ${PGDATABASE:-postgres} + + graphql: + image: cartesi/sdk:devel + environment: + POSTGRES_GRAPHQL_DB_URL: postgres://${PGUSER:-postgres}:${PGPASSWORD:-password}@${PGHOST:-database}:${PGPORT:-5432}/hlgraphql?sslmode=disable + POSTGRES_NODE_DB_URL: postgres://${PGUSER:-postgres}:${PGPASSWORD:-password}@${PGHOST:-database}:${PGPORT:-5432}/${PGDATABASE:-postgres}?sslmode=disable + expose: + - 8080 + command: ["cartesi-rollups-hl-graphql", "--graphile-disable-sync"] + depends_on: + graphql_database_creator: + condition: service_completed_successfully + + prompt: + image: debian:bookworm-slim + environment: + PROMPT_TXT_04_GRAPHQL: "graphql endpoint running at http://localhost:${CARTESI_LISTEN_PORT}/graphql/" + + traefik-config-generator: + environment: + TRAEFIK_CONFIG_GRAPHQL: | + http: + routers: + graphql: + rule: "PathPrefix(`/graphql`)" + middlewares: + - "remove-graphql-prefix" + service: graphql + middlewares: + remove-graphql-prefix: + replacePathRegex: + regex: "^/graphql/(.*)" + replacement: "/$1" + services: + graphql: + loadBalancer: + servers: + - url: "http://graphql:8080"