Step 2. Setup partner-chain dependencies
Now that a Cardano SPO is set up, it is time to configure partner-chain dependencies such as Ogmios, Kupo, Cardano-db-sync, Postgres, and Cardano-node. To simplify the process, a compose-partner-chains.yml
file is provided to easily start these services using Docker Compose. Alternatively, one may choose to build these dependencies from source.
Minimum system requirements
See Partner-chain dependencies server requirements.
Important notice for Ubuntu users:
Ubuntu sometimes ignores Docker's UFW rules, which can compromise your server's security. To address this:
- Enable Docker to Work with UFW: Run
sudo apt-get install docker-compose ufw
followed bysudo ufw allow 22/tcp
for SSH access, andsudo ufw allow 80/tcp
if you're exposing web services. - Configure Docker to Use UFW: Add these lines to
/etc/docker/daemon.json
:
{
"iptables": false
}
- Then, restart Docker with
sudo systemctl restart docker
. - Verify: After setup, ensure your firewall rules are in place by running
sudo ufw status
.
2a. docker-compose up
Partner-chain dependencies
-
Clone the
midnight-node-docker
repo and navigate tocompose-partner-chains.yml
file:git clone git@github.com:midnight-ntwrk/midnight-node-docker.git
cd midnight-node-docker -
Edit
compose-partner-chains.yml
file:For example, with vim:
vim compose-partner-chains.yml
- Enter
I
key to enter insert mode. - Navidate using arrow keys and locate
POSTGRES_*
environment variables.
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_DB=cexplorer
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password123 - Enter
Security Warning: The default POSTGRES_USER
(postgres
), POSTGRES_PASSWORD
(password123
), and POSTGRES_PORT
(5432
) shown above are insecure and predictable. These must be changed to protect your database from unauthorized access and potential attacks.
- If using
vim
editor, make changes, thenESC
+:wq
to save changes to file.
-
docker-compose up
partner-chain dependencies:- Within the same directory as the
compose-partner-chains.yml
, launch partner-chain dependencies in detatched mode.
docker compose -f compose-partner-chains.yml up -d
Example output:
[+] Running 5/5
✔ Container postgres H... 5.7s
✔ Container cardano-node Started 0.1s
✔ Container ogmios Sta... 0.2s
✔ Container kupo Start... 0.2s
✔ Container db-sync St... 5.8simportant⌛ Allow partner-chain dependencies to sync 100% with the Cardano network. This can take a few hours.
- Within the same directory as the
2b. Manage and monitor partner-chain dependencies
-
Verify status of services and ports:
- List active Docker containers along with their status, ports, and container IDs:
docker container list
Example output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aeddf39b71f7 ghcr.io/intersectmbo/cardano-db-sync:13.5.0.2 "/nix/store/mvypj83y…" 9 minutes ago Up 9 minutes db-sync
61a6eb0ed321 cardanosolutions/ogmios:v6.5.0 "/bin/ogmios --node-…" 9 minutes ago Up 9 minutes (healthy) 0.0.0.0:1337->1337/tcp, :::1337->1337/tcp ogmios
b514a818da45 postgres:15.3 "docker-entrypoint.s…" 9 minutes ago Up 9 minutes (healthy) 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp db-sync-postgres
558d2b49eddc ghcr.io/intersectmbo/cardano-node:10.1.2 "entrypoint" 9 minutes ago Up 9 minutes 0.0.0.0:3001->3001/tcp, :::3001->3001/tcp cardano-node -
View logs of specific containers:
To view logs of a particular container, use
docker logs
followed by the container name or ID:docker logs db-sync
docker logs kupo
docker logs ogmios
docker logs db-sync-postgres
docker logs cardano-nodeReplace
db-sync
,ogmios
, etc., with the actual container names or container IDs you want to inspect. -
Useful docker-compose commands:
To learn more about Docker Compose, visit the official Docker Compose documentation. However, here are some common commands:
docker-compose stop # stop containers
docker-compose start # start containers
docker-compose restart # restart containers
docker-compose down # stop and remove containers
docker-compose stats # display resource usage statistics -
Monitor Ogmios service:
- View Ogmios dashboard at http://localhost:1337/. If Ogmios is running on a remote service then simply visit http://x.x.x.x:1337 in a browser with the respective IP address and PORT.
- Query Ogmios healthcheck:
curl -s localhost:1337/health | jq '.'
-
Monitor Kupo service:
- Query Kupo healthcheck:
curl -X GET http://localhost:1442/health
-
Query Cardano-db-sync synchronization progress:
-
Using
psql
directly:If you don’t already have the PostgreSQL client installed, you can install it using:
sudo apt-get install postgresql-client
Log in to PostgreSQL shell using
psql
:psql -h localhost -U postgres -d cexplorer -p 5432
Optionally, log in to PostgreSQL shell using
docker
:docker exec -it db-sync-postgres psql -U postgres -d cexplorer
Then, run the following query inside the PostgreSQL shell:
SELECT 100 * (
EXTRACT(EPOCH FROM (MAX(time) AT TIME ZONE 'UTC')) -
EXTRACT(EPOCH FROM (MIN(time) AT TIME ZONE 'UTC'))
) / (
EXTRACT(EPOCH FROM (NOW() AT TIME ZONE 'UTC')) -
EXTRACT(EPOCH FROM (MIN(time) AT TIME ZONE 'UTC'))
) AS sync_percent
FROM block; -
Using
ssh
remotely:If you want to query remotely, run this command via SSH:
ssh user@x.x.x.x -C "psql -d cexplorer -h localhost -p 5432 -U postgres -c \"SELECT 100 * (EXTRACT(EPOCH FROM (MAX(time) AT TIME ZONE 'UTC')) - EXTRACT(EPOCH FROM (MIN(time) AT TIME ZONE 'UTC'))) / (EXTRACT(EPOCH FROM (NOW() AT TIME ZONE 'UTC')) - EXTRACT(EPOCH FROM (MIN(time) AT TIME ZONE 'UTC'))) AS sync_percent FROM block;\""
Replace
user@x.x.x.x
with your SSH username and server IP address.
-