This page describes how to deploy the fullDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-redis-mongo-docker/llms.txt
Use this file to discover all available pages before exploring further.
backtest-kit-redis-mongo-docker stack, from a lightweight local setup where Node.js runs on the host against dockerized infrastructure, through to a fully containerized deployment where the backtest runner, MongoDB, and Redis all run inside Docker.
Deployment Approaches
There are two distinct ways to run the stack depending on your environment and operational preferences. Local run (host Node.js + dockerized infrastructure). MongoDB and Redis run as Docker containers while the strategy bundle executes directly on the host withnpm run start. This is the recommended approach during active strategy development because it gives you fast rollup rebuild cycles without rebuilding a Docker image.
Full Docker deploy. All three services — MongoDB, Redis, and the backtest runner — run inside Docker. The runner container mounts your local workspace at /workspace, so you still build with rollup -c on the host but execution happens inside the container. This is the recommended approach for unattended server deployments.
Full Docker Deploy
Before starting the full stack, build the TypeScript source so the compiled bundle is available for the container to mount.docker-compose.yaml:
| Variable | Value used above | Meaning |
|---|---|---|
MODE | backtest | Instructs the CLI entrypoint to run in backtest mode |
ENTRY | 1 | Equivalent to passing --entry on the CLI; activates the main function |
UI | 1 | Enables the web dashboard on port 60050 |
STRATEGY_FILE | ./build/index.cjs | Path (relative to /workspace inside the container) to the compiled strategy bundle |
npm Shortcuts
Thepackage.json provides two convenience scripts that wrap the commands above.
Start the full stack in backtest mode:
npm run build && cross-env MODE=backtest ENTRY=1 UI=1 STRATEGY_FILE=./build/index.cjs docker-compose up -d.
Stop and remove all containers:
docker-compose down, which stops all containers defined in the main docker-compose.yaml and removes their networks. Persistent data in docker/mongodb/mongo_data and docker/redis/redis_data is preserved on the host.
Docker Compose Layout
The project uses three separate compose files to keep infrastructure concerns isolated. They can be started independently or together depending on which services you need.docker/mongodb/docker-compose.yaml
Runs the official MongoDB Community Server.
- Image:
mongodb/mongodb-community-server:8.0.4-ubi8— a production-supported build of MongoDB 8.0 on UBI 8. - Port:
27017exposed on the host. - Volume:
./mongo_data:/data/dbpersists the WiredTiger data files on the host. - Restart policy:
always— MongoDB restarts automatically on host reboot.
docker/redis/docker-compose.yaml
Runs Redis with password authentication enabled.
- Image:
redis:7.4.1— the official Redis image pinned to a specific patch release. - Port:
6379exposed on the host. - Authentication:
--requirepass mysecurepasswordpassed directly toredis-server. Override this value and updateCC_REDIS_PASSWORDin.envbefore any internet-facing deployment. - Volume:
./redis_data:/datapersists the RDB snapshot between restarts. - Restart policy:
always.
docker-compose.yaml (main runner)
Runs the tripolskypetr/backtest-kit image with your compiled strategy bundle mounted in.
extra_hosts and Host Network Access
The extra_hosts entry:
/etc/hosts record inside the container that maps host.docker.internal to the host machine’s gateway IP. This is the Linux equivalent of the automatic host.docker.internal DNS entry that Docker Desktop provides on macOS and Windows.
Without this entry, the container cannot resolve host.docker.internal, and the .env values for CC_REDIS_HOST and CC_MONGO_CONNECTION_STRING — which both reference host.docker.internal — will fail to connect to the infrastructure containers started from docker/mongodb/ and docker/redis/.
If you are deploying MongoDB and Redis on a separate host or using a managed cloud service, replace
host.docker.internal in .env with the actual hostname or IP address of that service. The extra_hosts entry is not needed in that case.Health Check
The main compose file configures an HTTP health check against thebacktest-kit REST API:
docker inspect backtest-kit-redis-mongo-docker to query the current health status.
Volume Mounts
| Mount | Host path | Container path | Purpose |
|---|---|---|---|
| Workspace | ./ | /workspace | Provides the compiled strategy bundle and .env to the runner |
| MongoDB data | docker/mongodb/mongo_data | /data/db | Persists all collection data across container restarts |
| Redis data | docker/redis/redis_data | /data | Persists the RDB snapshot across container restarts |
working_dir is set to /workspace, the STRATEGY_FILE=./build/index.cjs path resolves to the build/ directory that rollup -c produces on the host. There is no need to copy files into the image or rebuild it when the strategy code changes.
Environment Variable Reference
All variables listed in theenvironment block of the main docker-compose.yaml are passed through from the host shell or the .env file. None have hardcoded values in the compose file itself, which means unset variables are silently ignored by the runner rather than causing a startup error.
| Variable | Purpose |
|---|---|
MODE | Selects the run mode: backtest, live, or paper |
STRATEGY_FILE | Path to the compiled strategy bundle inside the container (default: ./build/index.cjs) |
ENTRY | Set to 1 to activate the main entry point; without this the process exits immediately |
SYMBOL | Override the default trading symbol defined in the strategy |
STRATEGY | Override the strategy name used for MongoDB lookups |
EXCHANGE | Override the exchange name used for MongoDB lookups |
FRAME | Override the frame name used for MongoDB lookups |
UI | Set to 1 to enable the web dashboard on port 60050 |
TELEGRAM | Set to 1 to enable Telegram notifications for signals and risk events |
VERBOSE | Set to 1 to enable verbose logging to stdout |
NO_CACHE | Set to 1 to disable Redis cache reads (all lookups go directly to MongoDB) |
NO_FLUSH | Set to 1 to skip the Redis cache flush performed at startup |