Deploy a Graph Node
This tutorial will guide you to run The Graph self-hosted node on your machine via Docker Compose. Docker and Docker Compose are required to run graph node.
Prepare your docker-compose.yaml file
version: '3'
services:
graph-node:
image: graphprotocol/graph-node
ports:
- '8000:8000'
- '8001:8001'
- '8020:8020'
- '8030:8030'
- '8040:8040'
depends_on:
- ipfs
- postgres
extra_hosts:
- host.docker.internal:host-gateway
environment:
postgres_host: postgres
postgres_user: graph-node
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: 'ipfs:5001'
ethereum: RPC_URL_TO_YOUR_NODE
GRAPH_LOG: info
ipfs:
image: ipfs/kubo:v0.14.0
ports:
- '5001:5001'
volumes:
- ./data/ipfs:/data/ipfs
postgres:
image: postgres:14
ports:
- '5432:5432'
command:
[
"postgres",
"-cshared_preload_libraries=pg_stat_statements",
"-cmax_connections=200"
]
environment:
POSTGRES_USER: YOUR_POSTGRES_USER
POSTGRES_PASSWORD: YOUR_POSTGRES_PASSWORD
POSTGRES_DB: YOUR_POSTGRES_DB
# FIXME: remove this env. var. which we shouldn't need. Introduced by
# <https://github.com/graphprotocol/graph-node/pull/3511>, maybe as a
# workaround for https://github.com/docker/for-mac/issues/6270?
PGDATA: "/var/lib/postgresql/data"
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
volumes:
- ./data/postgres:/var/lib/postgresql/data
In that:
RPC_URL_TO_YOUR_NODE
: is RPC URL to your node (it could be your local U2U node or public tracing node). Example:'solaris:http://host.docker.internal:8545'
or'solaris:https://rpc-mainnet.u2u.xyz'
for Solaris mainnet or'nebulas:https://rpc-nebulas-testnet.u2u.xyz'
for Nebulas testnet.POSTGRES_USER
: your Postgres database username. Example:graph-node
POSTGRES_PASSWORD
: Your Postgres database password. Example:let-me-in
POSTGRES_DB
: your Postgres database database name. Example:graph-node
Once your filled those environment variables, you enter below command to start your graphnode with Docker Compose at the same directory where contains your docker-compose.yaml
file:
docker-compose up
You will see something similar:
[+] Running 39/3
✔ postgres 13 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 34.0s
✔ graph-node 7 layers [⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 34.2s
✔ ipfs 16 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 14.4s
[+] Running 4/4
✔ Network graphnode_default Created 0.2s
✔ Container graphnode-postgres-1 Created 8.0s
✔ Container graphnode-ipfs-1 Created 8.0s
✔ Container graphnode-graph-node-1 Created 0.9s
Attaching to graphnode-graph-node-1, graphnode-ipfs-1, graphnode-postgres-1
graphnode-postgres-1 | The files belonging to this database system will be owned by user "postgres".
graphnode-postgres-1 | This user must also own the server process.
graphnode-postgres-1 |
graphnode-postgres-1 | The database cluster will be initialized with locale "C".
graphnode-postgres-1 | The default text search configuration will be set to "english".
graphnode-postgres-1 |
graphnode-postgres-1 | Data page checksums are disabled.
graphnode-postgres-1 |
graphnode-postgres-1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
graphnode-postgres-1 | creating subdirectories ... ok
graphnode-postgres-1 | selecting dynamic shared memory implementation ... posix
graphnode-postgres-1 | selecting default max_connections ... 100
graphnode-ipfs-1 | Changing user to ipfs
graphnode-postgres-1 | selecting default shared_buffers ... 128MB
graphnode-postgres-1 | selecting default time zone ... Etc/UTC
graphnode-postgres-1 | creating configuration files ... ok
graphnode-ipfs-1 | ipfs version 0.14.0
graphnode-ipfs-1 | generating ED25519 keypair...done
graphnode-ipfs-1 | peer identity: 12D3KooWNhXSghWxBP8R1CdGiNN3aUhFFNwP2WV7siHNK3Xr33Mw
graphnode-ipfs-1 | initializing IPFS node at /data/ipfs
graphnode-postgres-1 | running bootstrap script ... ok
graphnode-postgres-1 | performing post-bootstrap initialization ... ok
graphnode-graph-node-1 | Waiting for IPFS (ipfs:5001)
graphnode-ipfs-1 | to get started, enter:
graphnode-ipfs-1 |
graphnode-ipfs-1 | ipfs cat /ipfs/QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc/readme
graphnode-ipfs-1 |
graphnode-ipfs-1 | Initializing daemon...
graphnode-ipfs-1 | Kubo version: 0.14.0-e0fabd6
graphnode-ipfs-1 | Repo version: 12
graphnode-ipfs-1 | System version: amd64/linux
graphnode-ipfs-1 | Golang version: go1.18.3
graphnode-postgres-1 | syncing data to disk ... ok
graphnode-postgres-1 |
graphnode-postgres-1 |
graphnode-postgres-1 | Success. You can now start the database server using:
graphnode-postgres-1 |
graphnode-postgres-1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
graphnode-postgres-1 |
graphnode-postgres-1 | initdb: warning: enabling "trust" authentication for local connections
graphnode-postgres-1 | You can change this by editing pg_hba.conf or using the option -A, or
graphnode-postgres-1 | --auth-local and --auth-host, the next time you run initdb.
graphnode-ipfs-1 | 2023/10/09 10:08:39 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.
graphnode-postgres-1 | waiting for server to start....2023-10-09 10:08:39.532 UTC [49] LOG: starting PostgreSQL 14.9 (Debian 14.9-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
graphnode-postgres-1 | 2023-10-09 10:08:39.576 UTC [49] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
graphnode-postgres-1 | 2023-10-09 10:08:39.777 UTC [50] LOG: database system was shut down at 2023-10-09 10:08:32 UTC
graphnode-postgres-1 | 2023-10-09 10:08:39.904 UTC [49] LOG: database system is ready to accept connections
graphnode-postgres-1 | done
graphnode-postgres-1 | server started
graphnode-ipfs-1 | Swarm listening on /ip4/127.0.0.1/tcp/4001
graphnode-ipfs-1 | Swarm listening on /ip4/127.0.0.1/udp/4001/quic
graphnode-ipfs-1 | Swarm listening on /ip4/172.21.0.3/tcp/4001
graphnode-ipfs-1 | Swarm listening on /ip4/172.21.0.3/udp/4001/quic
graphnode-ipfs-1 | Swarm listening on /p2p-circuit
graphnode-ipfs-1 | Swarm announcing /ip4/127.0.0.1/tcp/4001
graphnode-ipfs-1 | Swarm announcing /ip4/127.0.0.1/udp/4001/quic
graphnode-ipfs-1 | Swarm announcing /ip4/171.242.12.100/udp/4001/quic
graphnode-ipfs-1 | Swarm announcing /ip4/171.242.12.202/udp/4001/quic
graphnode-ipfs-1 | Swarm announcing /ip4/172.21.0.3/tcp/4001
graphnode-ipfs-1 | Swarm announcing /ip4/172.21.0.3/udp/4001/quic
graphnode-ipfs-1 | API server listening on /ip4/0.0.0.0/tcp/5001
graphnode-ipfs-1 | WebUI: http://0.0.0.0:5001/webui
graphnode-ipfs-1 | Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
graphnode-ipfs-1 | Daemon is ready
graphnode-postgres-1 | CREATE DATABASE
graphnode-postgres-1 |
graphnode-postgres-1 |
graphnode-postgres-1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
graphnode-postgres-1 |
graphnode-postgres-1 | waiting for server to shut down...2023-10-09 10:08:40.881 UTC [49] LOG: received fast shutdown request
graphnode-postgres-1 | .2023-10-09 10:08:40.931 UTC [49] LOG: aborting any active transactions
graphnode-postgres-1 | 2023-10-09 10:08:40.932 UTC [49] LOG: background worker "logical replication launcher" (PID 56) exited with exit code 1
graphnode-postgres-1 | 2023-10-09 10:08:40.932 UTC [51] LOG: shutting down
graphnode-graph-node-1 | Waiting for Postgres (postgres:5432)
graphnode-postgres-1 | 2023-10-09 10:08:41.234 UTC [49] LOG: database system is shut down
graphnode-postgres-1 | done
graphnode-postgres-1 | server stopped
graphnode-postgres-1 |
graphnode-postgres-1 | PostgreSQL init process complete; ready for start up.
graphnode-postgres-1 |
graphnode-postgres-1 | 2023-10-09 10:08:41.364 UTC [1] LOG: starting PostgreSQL 14.9 (Debian 14.9-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
graphnode-postgres-1 | 2023-10-09 10:08:41.365 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
graphnode-postgres-1 | 2023-10-09 10:08:41.365 UTC [1] LOG: listening on IPv6 address "::", port 5432
graphnode-postgres-1 | 2023-10-09 10:08:41.458 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
graphnode-postgres-1 | 2023-10-09 10:08:41.526 UTC [64] LOG: database system was shut down at 2023-10-09 10:08:41 UTC
graphnode-postgres-1 | 2023-10-09 10:08:41.578 UTC [1] LOG: database system is ready to accept connections
graphnode-graph-node-1 | Oct 09 10:08:47.023 INFO Graph Node version: 0.32.0 (2023-08-21)
graphnode-graph-node-1 | Oct 09 10:08:47.023 WARN GRAPH_POI_ACCESS_TOKEN not set; might leak POIs to the public via GraphQL
graphnode-graph-node-1 | Oct 09 10:08:47.023 INFO Generating configuration from command line arguments
graphnode-graph-node-1 | Oct 09 10:08:47.023 WARN No fork base URL specified, subgraph forking is disabled
graphnode-graph-node-1 | Oct 09 10:08:47.023 INFO Starting up
graphnode-graph-node-1 | Oct 09 10:08:47.023 INFO Trying IPFS node at: http://ipfs:5001/
graphnode-graph-node-1 | Oct 09 10:08:47.028 INFO Creating transport, capabilities: archive, traces, url: https://rpc-mainnet.uniultra.xyz, provider: solaris-rpc-0
graphnode-graph-node-1 | Oct 09 10:08:47.029 INFO Successfully connected to IPFS node at: http://ipfs:5001/
graphnode-graph-node-1 | Oct 09 10:08:47.287 WARN Expensive queries file not set to a valid file: /etc/graph-node/expensive-queries.txt
graphnode-graph-node-1 | Oct 09 10:08:47.303 INFO Connecting to Postgres, weight: 1, conn_pool_size: 10, url: postgresql://graph-node:HIDDEN_PASSWORD@postgres:5432/graph-node?sslmode=prefer, pool: main, shard: primary
graphnode-graph-node-1 | Oct 09 10:08:47.303 INFO Pool successfully connected to Postgres, pool: main, shard: primary, component: Store
graphnode-graph-node-1 | Oct 09 10:08:47.309 INFO Setting up fdw, pool: main, shard: primary, component: ConnectionPool
graphnode-graph-node-1 | Oct 09 10:08:47.340 INFO Running migrations, pool: main, shard: primary, component: ConnectionPool
graphnode-graph-node-1 | Oct 09 10:08:58.857 INFO Migrations finished, pool: main, shard: primary, component: ConnectionPool
graphnode-graph-node-1 | Oct 09 10:08:58.858 INFO Mapping primary, pool: main, shard: primary, component: ConnectionPool
graphnode-graph-node-1 | Oct 09 10:08:58.877 INFO Connecting to Ethereum to get network identifier, capabilities: archive, traces, provider: solaris-rpc-0
graphnode-graph-node-1 | Oct 09 10:08:59.184 INFO Connected to Ethereum, capabilities: archive, traces, network_version: 39, provider: solaris-rpc-0
graphnode-graph-node-1 | Oct 09 10:08:59.691 INFO Creating LoadManager in disabled mode, component: LoadManager
graphnode-graph-node-1 | Oct 09 10:08:59.691 INFO Started block ingestor, network_name: solaris
graphnode-graph-node-1 | Oct 09 10:08:59.691 INFO Starting firehose block ingestor for network, network_name: solaris
graphnode-graph-node-1 | Oct 09 10:08:59.691 INFO Starting job runner with 5 jobs, component: JobRunner
graphnode-graph-node-1 | Oct 09 10:08:59.692 INFO Starting JSON-RPC admin server at: http://localhost:8020, component: JsonRpcServer
graphnode-graph-node-1 | Oct 09 10:08:59.692 INFO Starting GraphQL HTTP server at: http://localhost:8000, component: GraphQLServer
graphnode-graph-node-1 | Oct 09 10:08:59.692 INFO Starting index node server at: http://localhost:8030, component: IndexNodeServer
graphnode-graph-node-1 | Oct 09 10:08:59.692 INFO Started all assigned subgraphs, node_id: default, count: 0, component: SubgraphRegistrar
graphnode-graph-node-1 | Oct 09 10:08:59.692 INFO Starting GraphQL WebSocket server at: ws://localhost:8001, component: SubscriptionServer
graphnode-graph-node-1 | Oct 09 10:08:59.692 INFO Starting metrics server at: http://localhost:8040, component: MetricsServer
graphnode-graph-node-1 | Oct 09 10:08:59.866 INFO Downloading latest blocks from Ethereum, this may take a few minutes..., provider: solaris-rpc-0, component: EthereumPollingBlockIngestor
graphnode-graph-node-1 | Oct 09 10:09:46.238 INFO Syncing 27 blocks from Ethereum, code: BlockIngestionLagging, blocks_needed: 27, blocks_behind: 27, latest_block_head: 2043707, current_block_head: 2043680, provider: solaris-rpc-0, component: EthereumPollingBlockIngestor
graphnode-graph-node-1 | Oct 09 10:09:52.082 INFO Syncing 3 blocks from Ethereum, code: BlockIngestionStatus, blocks_needed: 3, blocks_behind: 3, latest_block_head: 2043710, current_block_head: 2043707, provider: solaris-rpc-0, component: EthereumPollingBlockIngestor
graphnode-graph-node-1 | Oct 09 10:09:53.731 INFO Syncing 1 blocks from Ethereum, code: BlockIngestionStatus, blocks_needed: 1, blocks_behind: 1, latest_block_head: 2043711, current_block_head: 2043710, provider: solaris-rpc-0, component: EthereumPollingBlockIngestor
Please take a look at the last line, graphnode has started to sync blocks with the RPC node. Your graphnode now is ready to deploy a subgraph.
Last updated