Skip to main content

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.

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.
docker/
  pgpool/docker-compose.yaml    # recommended for dev: 1 primary + 2 replicas + Pgpool-II
  postgres/docker-compose.yaml  # single postgres:16-alpine (CI / simple use)
  redis/docker-compose.yaml     # redis:7.4.1 on :6379
docker-compose.yaml             # main: backtest-kit container, mounts project as /workspace

Service Files

Port Mapping Summary

ServiceHost portContainer portCompose file
Pgpool-II / PostgreSQL54325432docker/pgpool/docker-compose.yaml
Single PostgreSQL54325432docker/postgres/docker-compose.yaml
Redis63796379docker/redis/docker-compose.yaml
backtest-kit web UI6005060050docker-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

ServiceHost pathContainer pathPurpose
Pgpool clusterdocker/pgpool/data/var/lib/pgclusterPrimary + replica data dirs
Single Postgresdocker/postgres/pg_data (bind-mount)/var/lib/postgresql/dataDatabase data directory
Redisdocker/redis/redis_data (bind-mount)/dataRDB / AOF persistence files
backtest-kit./ (project root)/workspaceStrategy 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.
CC_REDIS_HOST=127.0.0.1
CC_POSTGRES_CONNECTION_STRING=postgres://backtest:mysecurepassword@localhost:5432/backtest-pro

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.
CC_REDIS_HOST=host.docker.internal
CC_POSTGRES_CONNECTION_STRING=postgres://backtest:mysecurepassword@host.docker.internal:5432/backtest-pro
When running the strategy inside the tripolskypetr/backtest-kit container, always use host.docker.internal instead of 127.0.0.1 or localhost in your connection strings. Using 127.0.0.1 inside the container resolves to the container’s own loopback interface, where no database is listening, causing the DataSource.initialize() call to hang and eventually time out.

Typical Startup Sequences

1

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.
docker-compose -f docker/pgpool/docker-compose.yaml up -d
docker-compose -f docker/redis/docker-compose.yaml up -d
2

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.
npm run start -- --entry --backtest --ui ./build/index.cjs
3

Or run everything in Docker

Build the strategy bundle first, then start the main compose file. Set MODE, ENTRY, and optionally UI via environment variables.
npm run build
MODE=backtest ENTRY=1 UI=1 STRATEGY_FILE=./build/index.cjs docker-compose up -d
docker-compose logs -f
For CI pipelines where a full replica cluster is overkill, substitute 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:
# .github/workflows/test.yml (example)
services:
  postgres:
    image: postgres:16-alpine
    env:
      POSTGRES_USER: backtest
      POSTGRES_PASSWORD: mysecurepassword
      POSTGRES_DB: backtest-pro
    ports:
      - 5432:5432
  redis:
    image: redis:7.4.1
    ports:
      - 6379:6379
Or start the bundled file directly in your CI script:
docker-compose -f docker/postgres/docker-compose.yaml up -d
docker-compose -f docker/redis/docker-compose.yaml up -d

Build docs developers (and LLMs) love