The project ships four Docker Compose files that cover every deployment scenario from a single-node CI run to a full production-like cluster. They are intentionally kept separate so you can compose only the services you need, rather than starting everything in one command.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-redis-postgres-pgpool-docker/llms.txt
Use this file to discover all available pages before exploring further.
Service Files
- Pgpool cluster (recommended)
- Single Postgres (CI)
- Redis
- Main compose (strategy container)
File:
docker/pgpool/docker-compose.yamlRuns the all-in-one tripolskypetr/pgpool:latest image, which bundles a full PostgreSQL streaming-replication cluster — one primary and two read replicas — behind a Pgpool-II load balancer, all inside a single container. The external interface is a single port 5432; Pgpool-II routes write queries to the primary and distributes reads across both replicas transparently.Environment variables
The application role that the adapter layer connects as. Must match the
username in
CC_POSTGRES_CONNECTION_STRING.Password for
POSTGRES_USER. Must match the password in
CC_POSTGRES_CONNECTION_STRING and the Redis requirepass value if you
want the defaults to stay consistent across services.Database name created on first boot. Must match the database segment of
CC_POSTGRES_CONNECTION_STRING.Internal replication role used by the standby nodes to stream WAL from the
primary. Never exposed outside the container.
Password for
REPL_USER. Change together with REPL_USER when hardening
the cluster.Root directory inside the container where the primary and replica data
directories live. The volume mount
./data:/var/lib/pgcluster maps this
to a local folder so cluster state survives container restarts.Directory containing the PostgreSQL binary tools (
pg_basebackup,
pg_ctl, etc.) used by the init scripts inside the image. Rarely changed.Volume mount
Cluster data is bind-mounted to./data (relative to
docker/pgpool/). This directory is gitignored so data survives restarts
and is easy to inspect or wipe:Healthcheck and startup time
The healthcheck polls every 10 seconds with a 120-secondstart_period.
The extended start period is necessary because the first boot clones two
streaming replicas from the primary via pg_basebackup, which takes
approximately 60–90 seconds on typical hardware.Why use this in development?
The replica cluster catches a class of bugs that are invisible on a single-node database. PostgreSQL on a single node is one process — all reads and writes go through the same memory, so awrite followed
immediately by a SELECT always returns the just-written value. On a
cluster, reads are load-balanced to asynchronous replicas that lag the
primary by a few milliseconds. Any adapter code that does a follow-up
SELECT after a write will silently return stale data in production but
pass every test on a single node.Port Mapping Summary
| Service | Host port | Container port | Compose file |
|---|---|---|---|
| Pgpool-II / PostgreSQL | 5432 | 5432 | docker/pgpool/docker-compose.yaml |
| Single PostgreSQL | 5432 | 5432 | docker/postgres/docker-compose.yaml |
| Redis | 6379 | 6379 | docker/redis/docker-compose.yaml |
| backtest-kit web UI | 60050 | 60050 | docker-compose.yaml |
Both Postgres compose files bind to host port
5432. Run only one of them at
a time to avoid a port conflict.Volume Mount Locations
| Service | Host path | Container path | Purpose |
|---|---|---|---|
| Pgpool cluster | docker/pgpool/data | /var/lib/pgcluster | Primary + replica data dirs |
| Single Postgres | docker/postgres/pg_data (bind-mount) | /var/lib/postgresql/data | Database data directory |
| Redis | docker/redis/redis_data (bind-mount) | /data | RDB / AOF persistence files |
| backtest-kit | ./ (project root) | /workspace | Strategy bundle + .env + build output |
Connecting from Inside a Container vs. the Host
Running Node on the host
Both PostgreSQL and Redis are reachable at
127.0.0.1 (or localhost)
because the Docker containers publish their ports to the host network.Running strategy in Docker
The strategy container cannot reach
127.0.0.1 on the host. Use
host.docker.internal, which is mapped to the host gateway by extra_hosts.Typical Startup Sequences
Start infrastructure (development)
Boot the Pgpool cluster and Redis. Wait for the Pgpool healthcheck to turn
green before proceeding — the first boot takes 60–90 seconds while replicas
clone.
Run the strategy on the host
With infrastructure running, execute the strategy directly with Node. The
TypeORM
DataSource will create all tables on first connect.Using single Postgres for CI
Using single Postgres for CI
For CI pipelines where a full replica cluster is overkill, substitute
Or start the bundled file directly in your CI script:
docker/postgres/docker-compose.yaml for docker/pgpool/docker-compose.yaml.
The connection string stays identical because both files publish port 5432
with the same credentials: