Skip to content

Commit f6b328b

Browse files
endersonmaiatuler
authored andcommitted
feat(cli): expose graphql endpoint
1 parent db74e30 commit f6b328b

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

.changeset/heavy-penguins-act.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cartesi/cli": major
3+
---
4+
5+
expose graphql endpoint

apps/cli/src/commands/run.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ export default class Run extends BaseCommand<typeof Run> {
3535
"disable local paymaster service to save machine resources",
3636
summary: "disable paymaster service",
3737
}),
38+
"disable-graphql": Flags.boolean({
39+
default: false,
40+
description:
41+
"disable local graphql service to save machine resources",
42+
summary: "disable graphql service",
43+
}),
3844
"epoch-length": Flags.integer({
3945
description: "length of an epoch (in blocks)",
4046
default: 720,
@@ -136,6 +142,11 @@ export default class Run extends BaseCommand<typeof Run> {
136142
// proxy
137143
composeFiles.push("docker-compose-proxy.yaml");
138144

145+
// graphql
146+
if (!flags["disable-graphql"]) {
147+
composeFiles.push("docker-compose-graphql.yaml");
148+
}
149+
139150
// anvil
140151
composeFiles.push("docker-compose-anvil.yaml");
141152

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
services:
2+
graphql_database_creator:
3+
image: postgres:15-alpine
4+
command: ["createdb", "graphql"]
5+
depends_on:
6+
database:
7+
condition: service_healthy
8+
environment:
9+
PGHOST: ${PGHOST:-database}
10+
PGPORT: ${PGPORT:-5432}
11+
PGUSER: ${PGUSER:-postgres}
12+
PGPASSWORD: ${PGPASSWORD:-password}
13+
PGDATABASE: ${PGDATABASE:-postgres}
14+
15+
graphql:
16+
image: cartesi/sdk:devel
17+
environment:
18+
POSTGRES_GRAPHQL_DB_URL: postgres://${PGUSER:-postgres}:${PGPASSWORD:-password}@${PGHOST:-database}:${PGPORT:-5432}/graphql?sslmode=disable
19+
POSTGRES_NODE_DB_URL: postgres://${PGUSER:-postgres}:${PGPASSWORD:-password}@${PGHOST:-database}:${PGPORT:-5432}/${PGDATABASE:-postgres}?sslmode=disable
20+
expose:
21+
- 8080
22+
command: ["cartesi-rollups-graphql", "--graphile-disable-sync"]
23+
depends_on:
24+
graphql_database_creator:
25+
condition: service_completed_successfully
26+
27+
prompt:
28+
image: debian:bookworm-slim
29+
environment:
30+
PROMPT_TXT_04_GRAPHQL: "graphql endpoint running at http://localhost:${CARTESI_LISTEN_PORT}/graphql/"
31+
32+
traefik-config-generator:
33+
environment:
34+
TRAEFIK_CONFIG_GRAPHQL: |
35+
http:
36+
routers:
37+
graphql:
38+
rule: "PathPrefix(`/graphql`)"
39+
middlewares:
40+
- "remove-graphql-prefix"
41+
service: graphql
42+
middlewares:
43+
remove-graphql-prefix:
44+
replacePathRegex:
45+
regex: "^/graphql/(.*)"
46+
replacement: "/$1"
47+
services:
48+
graphql:
49+
loadBalancer:
50+
servers:
51+
- url: "http://graphql:8080"

0 commit comments

Comments
 (0)