A Docker Compose demo of the Participant Query Store (PQS)

Background

The Participant Query Store (PQS) stores a copy of ledger data in a relational database for the purpose of performing fast and efficient queries of that data. This demo starts a minimal PQS in Docker, enabling you to explore the schema and data that is copied into the PQS database.

The PQS is an Enterprise feature. You will need credentials to the Digital Asset Artifactory to run this demo.

Clone the code

To follow along, clone the demo as follows:

git clone https://github.com/wallacekelly-da/daml-public-demos.git --branch pqs-simple-docker-compose --single-branch pqs-simple-docker-compose

cd pqs-simple-docker-compose

daml studio

Explore the Docker Compose file

The docker-compose.yaml file defines six services:

  • mydomain – a Canton sync domain
  • participant1 – a Canton participant node
  • pqs1_db – an initially empty Postgres database
  • pqs1_scribe – a Java application which copies data from the ledger into the database.
  • scripts – a Daml Script for creating and exercising contracts on the ledger
  • adminer1 – a minimal webapp for exploring the contents of pqs1_db.

image

The Docker Compose file relies heavily on the configs folder.

docker-compose.yaml
services:

  mydomain:
    container_name: mydomain
    image: digitalasset-docker.jfrog.io/canton-enterprise:2.8.1
    volumes:
      - ./configs:/canton/host/configs:r
    command: daemon --config "/canton/host/configs/mydomain.conf" --log-profile container
    expose:
      - 5001
      - 5002
    ports:
      - 5001:5001
      - 5002:5002

  participant1:
    container_name: participant1
    image: digitalasset-docker.jfrog.io/canton-enterprise:2.8.1
    volumes:
      - ./configs:/canton/host/configs:r
      - ./.daml/dist/:/canton/host/dist/:r
    command: daemon --config "/canton/host/configs/participant1.conf" --bootstrap "/canton/host/configs/participant1.canton" --log-profile container
    healthcheck:
      test:
        [
          "CMD",
          "/usr/local/bin/grpc_health_probe",
          "--addr",
          "participant1:5861"
        ]
    depends_on:
      - mydomain
    expose:
      - 5003
      - 5004
    ports:
      - 5003:5003
      - 5004:5004

  pqs1_db:
    container_name: pqs1_db
    image: postgres:16
    environment:
      - POSTGRES_PASSWORD=postgres
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready", "-d", "postgres" ]
    ports:
      - 5432:5432

  pqs1_scribe:
    container_name: pqs1_scribe
    image: digitalasset-docker.jfrog.io/participant-query-store:0.1.0
    volumes:
      - ./configs:/canton/host/configs:r
      - ./jars:/canton/host/jars:r
    command: pipeline ledger postgres-document --config /canton/host/configs/pqs1_scribe.conf
    environment:
      - OTEL_JAVAAGENT_ENABLED=false
    depends_on:
      pqs1_db:
        condition: service_healthy
      participant1:
        condition: service_healthy

  scripts:
    container_name: scripts
    image: digitalasset/daml-sdk:2.8.1
    volumes:
      - ./configs:/canton/host/configs:r
      - ./.daml/dist/:/canton/host/dist/:r
    command: daml script --dar /canton/host/dist/demo-0.0.1.dar --all --ledger-host participant1 --ledger-port 5003
    depends_on:
      participant1:
        condition: service_healthy

  adminer1:
    container_name: adminer1
    image: adminer
    depends_on:
      - pqs1_db
    environment:
      - ADMINER_DEFAULT_SERVER=pqs1_db
    ports:
      - 8080:8080

Run the demo

  1. Build the Daml models:
daml build
  1. Pull the required images:
docker login digitalasset-docker.jfrog.io

docker pull digitalasset-docker.jfrog.io/canton-enterprise:2.8.1

docker pull digitalasset/daml-sdk:2.8.1

docker pull digitalasset-docker.jfrog.io/participant-query-store:0.1.0
  1. Start the services.
docker compose up pqs1_scribe adminer1 --detach
  1. Use your favorite database client (e.g., psql, DbBeaver, pgAdmin) to explore the database schema. At this point the tables will be empty.

    • Or use the Adminer instance which is launched by the Docker Compose file. Open http://localhost:8080, using “PostgreSQL”, “pqs1_db”, “postgres”, “postgres”, “postgres”, and Login.
      image

    • Click on the Select links on the left to view the contents of any table.
      image

  2. Create contracts on the ledger with:

docker compose up scripts
  1. Return to your favorite database client (or http://localhost:8080) to view the contract data being inserted into the PQS database.

Source code

https://github.com/wallacekelly-da/daml-public-demos/tree/pqs-simple-docker-compose

4 Likes

Thanks for this Wallace, it is a real smooth demonstration.

1 Like

This is very nice, thanks Wallace!