Complete Docker orchestration for the Gainium trading platform with all microservices, databases, and frontend applications.
- Prerequisites
- Quick Start
- Environment Configuration
- Services Overview
- Docker Images
- Usage Commands
- Troubleshooting
- Advanced Configuration
- 📋 Changelog
Before starting, ensure you have:
- Docker (v20.10+) and Docker Compose (v2.0+) installed
- At least 4GB RAM and 5GB free disk space
You need Docker with the Compose plugin. Nothing else: no git, bash, openssl or Node, and no particular folder.
Paste docker-compose.yml into the "stack" / "compose"
screen exactly as it is and start it. It runs without a .env;
every setting has a working default. Do not have it rewritten by an AI first:
almost every broken installation we have seen started that way.
# Get the files: git clone, or download the ZIP from GitHub and unpack it
git clone https://github.com/Gainium/docker-sh.git
cd docker-sh
# Optional: your own settings (Coinbase keys, ports, ...). Without a .env the
# defaults are used.
cp .env.sample .env
docker compose up -d- Give it a few minutes on the first start, then open
http://<this machine's address>:7500from any device: a LAN IP,localhost, a Tailscale name or a domain all work, with nothing to configure. - Back up your encryption key. The first start generated one for this
installation. With a terminal,
./setupEncryptKey.shcopies it into.env(keep a copy of that file somewhere else), or print it withdocker compose run --rm --no-deps secrets-init show. See Encryption key.
Something not starting? docker compose ps shows which service is unhealthy,
and docker compose logs --tail 50 <service> shows why.
The sign-up screen asks for a license key. It's free:
- Sign in or sign up at https://app.gainium.io
- Open Settings → License Key (https://app.gainium.io/settings/license-key)
- Click Generate license key, copy it, and paste it into the sign-up form
Any Gainium account's key lets you register; a paid plan only unlocks premium features.
The exchange API credentials your users add are stored encrypted, and
ENCRYPT_KEY is what encrypts them. A new installation generates its own
key, and its own JWT_SECRET, on first boot (the secrets-init service). To
copy the key into .env as your backup, or to set one before the first boot:
./setupEncryptKey.shA value set in .env always wins over the generated one. An existing
installation never has a key generated for it.
Without a key of its own, the application falls back to a key compiled into the image — the same one in every self-hosted installation, and readable in the public source — so a copy of your database would be enough on its own to decrypt every stored credential. With your own key, it is not.
Back the key up somewhere off this host. If it is lost, the stored exchange credentials cannot be recovered by anyone, and every user has to enter their keys again.
Already running without one? You can set it now and re-encrypt what is already stored afterwards — nothing breaks in between. See Encryption key in the deployment guide.
| Variable | Description | Example | Required |
|---|---|---|---|
COINBASEKEY |
Coinbase Pro API Key | your_api_key |
Only if using Coinbase |
COINBASESECRET |
Coinbase Pro API Secret | your_secret |
Only if using Coinbase |
PRICE_CONNECTOR_EXCHANGES |
Comma-separated list of exchanges for websocket price connector | binance,kucoin,bybit |
No (connects to all if not set) |
| Variable | Default | Description |
|---|---|---|
MONGO_DB_USERNAME |
user |
MongoDB username |
MONGO_DB_PASSWORD |
password |
MongoDB password |
MONGO_DB_NAME |
gainium |
Database name |
REDIS_PASSWORD |
H2Ga1DB1alBg |
Redis password |
RABBIT_USER |
gainium |
RabbitMQ username |
RABBIT_PASSWORD |
bdo3nyVMX5l6 |
RabbitMQ password |
| Service | Port | Description |
|---|---|---|
GRAPH_QL_PORT |
7503 |
Main API GraphQL endpoint |
WS_PORT |
7502 |
WebSocket streaming service |
PORT |
7500 |
Frontend web dashboard |
BACKTEST_PORT |
7515 |
Backtesting service |
The internal services authenticate nothing. They are safe because they are not
reachable, and nothing else. Publish PORT (7500) and GRAPH_QL_PORT (7503)
if you need them; keep everything else on the internal Docker network or bound
to the host's loopback interface, and do not open them in your firewall.
This matters most for two of them:
- exchange-connector. It is a credential pass-through proxy, and
GET /verify/GET /keyPermissionstake any exchange API key you hand them, ask the venue whether it is valid, and answer — including whether the key can withdraw. There is no caller authentication and no throttle by design, because the only intended caller is the balancer. Reachable from outside, it becomes a bulk validator for stolen exchange keys. Never publish its port. - paper-trading.
POST /usercreates an account with a caller-chosen starting balance and has no authentication. The funds are simulated, so the loss is polluted data rather than money, but it is not an endpoint to expose. On a single-host deployment you can setAPP_HOST=127.0.0.1for this service and take it off the network entirely.
If you put a reverse proxy in front of the stack, allow only the dashboard and API routes through it. Nothing else in this compose file is designed to face a network you do not control.
The PRICEROLE environment variable controls how the system handles price updates and can significantly impact resource usage:
| Value | Description | Resource Usage | Use Case |
|---|---|---|---|
all |
Default - Connects to both ticker and candle streams | High - Real-time ticker updates | Paper trading, high-frequency trading |
candle |
Connects only to candle streams, ignores ticker streams | Low - Scheduled updates every 2.5 minutes | Live trading without paper trading |
ticker |
Connects only to ticker streams | Medium - Real-time ticker only | Specific ticker monitoring |
PRICEROLE=allcan consume significant resources due to high-frequency ticker updates- If you're not using paper trading, set
PRICEROLE=candleto reduce resource usage - With
PRICEROLE=candle, bot price-related methods run on a schedule every 2.5 minutes instead of real-time
Example Configuration:
# For production without paper trading (recommended)
PRICEROLE=candle
# For development/paper trading (default)
PRICEROLE=all
# For ticker monitoring only
PRICEROLE=tickerThe PRICE_CONNECTOR_EXCHANGES environment variable allows you to control which exchanges the websocket price connector connects to for receiving price data.
Supported Exchanges:
binance- Binance exchangebinanceus- Binance US exchangekucoin- KuCoin exchangebybit- Bybit exchangeokx- OKX exchangebitget- Bitget exchangecoinbase- Coinbase exchangekraken- Kraken exchangehyperliquid- Hyperliquid exchange
Configuration Options:
# Connect to all exchanges (default behavior)
# Leave variable unset or empty
PRICE_CONNECTOR_EXCHANGES=
# Connect to specific exchanges only
PRICE_CONNECTOR_EXCHANGES=binance,kucoin,bybit
# Connect to a single exchange
PRICE_CONNECTOR_EXCHANGES=binance
# Connect to multiple exchanges
PRICE_CONNECTOR_EXCHANGES=binance,binanceus,coinbase,okxImportant Notes:
- If
PRICE_CONNECTOR_EXCHANGESis not set or empty, the connector will connect to all supported exchanges - Use comma-separated values without spaces between exchange names
- Invalid exchange names will be ignored
- This setting affects only the websocket price connector service
The dashboard runs in the browser, so it has to reach the api, the realtime
stream and the admin page as the browser sees them. By default the
frontend container proxies all three under its own address (/api,
/socket.io, /admin-api), so whatever address you open the dashboard with
just works, including https behind a reverse proxy or tunnel (it honours
X-Forwarded-Proto). Only port PORT (7500) has to be reachable for the
dashboard; GRAPH_QL_PORT (7503) only for TradingView/webhook calls.
To send the browser somewhere else for one of them instead, set it in .env:
VITE_API_ENDPOINT=https://api.example.com
VITE_WS_URL=wss://ws.example.com
VITE_ADMIN_API_URL=https://admin.example.comThen add that dashboard address to CORS_ORIGIN, and recreate the frontend
(docker compose up -d frontend).
- mongo: MongoDB database with persistent storage
- redis: Redis cache and session store
- rabbit: RabbitMQ message broker
- exchange-connector: Exchange API integration
- paper-trading: Paper trading simulation
- user-update-connector: Real-time user updates
- price-connector: Price data streaming
All services share the same codebase but run different commands:
- api: GraphQL API server (Port 7503)
- stream: WebSocket streaming (Port 7502)
- bots-dca: DCA trading bots
- bots-grid: Grid trading bots
- bots-combo: Combination trading bots
- bots-hedge-combo: Hedge combination bots
- bots-hedge-dca: Hedge DCA bots
- indicators: Technical indicators processor
- cron: Scheduled tasks and maintenance
- fill-failsafe: Catches limit-order fills the exchange stream missed
- backtest: Strategy backtesting service
- frontend: Next.js web dashboard (Port 7500)
Total: 19 Services
The following images are used from the registry:
| Image | Version | Services Using |
|---|---|---|
docker.gainium.io/gainium/exchange-connector |
1.0.0 |
exchange-connector |
docker.gainium.io/gainium/paper-trading |
1.0.0 |
paper-trading |
docker.gainium.io/gainium/websocket-connector |
1.0.0 |
user-update-connector, price-connector |
docker.gainium.io/gainium/main-app |
1.0.0 |
All 10 main-app services |
docker.gainium.io/gainium/frontend |
1.0.0 |
frontend |
External Images:
bitnami/mongodb:latestbitnami/redis:latestbitnami/rabbitmq:latest
# Start all services
docker compose up -d
# Start specific services
docker compose up -d mongo redis rabbit
docker compose up -d api frontend
# Start with build (rebuild images)
docker compose up -d --build
# Start and view logs
docker compose up
git pullfirst — it is part of the upgrade, not optional. The image tags are defaults in the trackeddocker-compose.yml(${MAIN_APP_VERSION:-…}), and new releases land by bumping them in this repository. On a stale checkoutdocker compose pullsucceeds while re-fetching the tags you already run, so nothing updates. Alternatively use the dashboard's Admin → Services tab, which pins registry versions in.versions.envand needs nogit pull.
# Update and restart services (the full upgrade)
git pull
docker compose pull && docker compose up -d
# Pull latest images from registry only
docker compose pull
# Pull specific image
docker pull docker.gainium.io/gainium/main-app:1.0.0
docker pull docker.gainium.io/gainium/frontend:1.0.0
# See which tags your checkout would actually pull
docker compose config --images# Stop all services
docker compose down
# Stop and remove volumes (⚠️ deletes database data)
docker compose down -v
# Restart specific service
docker compose restart api
docker compose restart frontend
# Scale a service (if supported)
docker compose up -d --scale bots-dca=2# View logs for all services
docker compose logs -f
# View logs for specific service
docker compose logs -f api
docker compose logs -f frontend
docker compose logs -f mongo
# View service status
docker compose ps
# Execute command in running container
docker compose exec api bash
docker compose exec mongo mongosh
# View resource usage
docker stats# Update images (git pull first — see "Updating Images" above)
git pull
docker compose pull
docker compose up -d
# Clean up unused resources
docker system prune
# Remove all Gainium images
docker images | grep docker.gainium.io | awk '{print $3}' | xargs docker rmi
# Reset everything (⚠️ deletes all data)
docker compose down -v --rmi allThis is the only password-recovery path on a self-hosted install. There is no "forgot password" email link — that flow exists only on Gainium's hosted service, which has mail delivery configured. On your own deployment, a user who cannot sign in needs an operator with shell access to run the command below. Plan for that before you hand accounts to people.
To reset a user's password from the command line:
# Using helper script (recommended)
./resetPassword.sh <username> <newPassword>
# Or using Docker Compose directly
docker compose run --rm cli-runner npm run cli:reset-password -- <username> <newPassword>Password Requirements: Minimum 6 characters with uppercase, lowercase, and a digit.
Example:
./resetPassword.sh admin MyNewPass123This signs the user out everywhere. Every existing session for the account is revoked, so the user (and anyone else holding one of their sessions) must sign in again with the new password. That is deliberate: if you are resetting because an account may be compromised, the intruder's session must not survive the reset.
- Forgot password, cannot sign in. The only route — there is no email link.
- Forgot password but still signed in. Also this route. Since main-app
1.52.0, the in-app Settings → Change Password form requires the account's current password, so a signed-in user who no longer knows it cannot change it themselves. (Before that release a session alone was enough to set a new password, which meant any leaked session was a full account takeover — GHSA-4m6h-m5mj-733x.) - Account suspected compromised. Reset here rather than from the app: this command revokes every session, which is what evicts the intruder.
- The username is the account's email address, matched case-insensitively.
- The new password is written as a bcrypt hash, the same as every other write path — it is never stored reversibly.
- The password appears in your shell history and in the process list while the
command runs. Clear it afterwards (
history -d) on a shared host, and have the user change it once they are back in. - The command runs
cli-runneragainst your live database; the stack does not need to be restarted afterwards.
# Error: pull access denied or image not found
# Solution: Check image names and tags in docker-compose.yml
docker compose pull # Pull all required images# Find what's using the port
lsof -i :7503
# Kill the process or change the port in .env# Check if MongoDB is running
docker compose logs mongo
# Reset database
docker compose restart mongo# Check available resources
docker stats
# Increase Docker memory limit or reduce running servicesProblem: Services fail to start on Mac, especially on Apple Silicon chips
# Common error messages:
# "exec format error"
# "WARNING: The requested image's platform does not match the detected host platform"
# Services keep restarting or fail to startSolutions:
Option 1: Use Docker Desktop Rosetta 2 emulation
- Open Docker Desktop
- Go to Settings → General
- Check "Use Rosetta for x86/amd64 emulation on Apple Silicon"
- Restart Docker Desktop
- Run:
docker compose down && docker compose up -d
Option 2: Enable Docker experimental features
# Enable buildx for multi-platform support
docker buildx create --use
docker buildx inspect --bootstrap
# Pull ARM64 specific images
docker pull --platform linux/arm64 bitnami/redis:latest
docker pull --platform linux/arm64 bitnami/rabbitmq:latestOption 3: Check Docker Desktop settings
- Ensure you're using the latest version of Docker Desktop
- Go to Settings → Resources and allocate sufficient resources:
- Memory: At least 4GB
- CPU: At least 2 cores
- Restart Docker Desktop
Verification:
# Check if all services are running properly
docker compose ps
# Check logs for any platform-related errors
docker compose logs | grep -i "platform\|arch\|format"
# Test database connections
docker compose exec mongo mongosh --version
docker compose exec redis redis-cli pingProblem: Docker registry connection timeouts during image pull
# Common error message:
# "Error response from daemon: Get "https://docker.gainium.io/v2/gainium/main-app/manifests/sha256:..." context deadline exceeded"Solution: This is typically a network timeout issue when pulling images from the Docker registry. In most cases, simply retrying the command will resolve the issue:
# Retry pulling images
docker compose pull
# If pull succeeds, restart the services
docker compose up -d
# Alternative: Pull specific image that failed
docker pull docker.gainium.io/gainium/main-app:1.0.0Note: Registry timeouts are usually temporary network issues. If the problem persists, check your internet connection or try again after a few minutes.
-
Check service status:
docker compose ps
-
View detailed logs:
docker compose logs serviceName
-
Test connectivity:
# Test API curl http://localhost:7503/health # Test WebSocket wscat -c ws://localhost:7502
-
Inspect containers:
docker compose exec api bash
Create different environment files:
# Development
cp .env.sample .env.development
# Production
cp .env.sample .env.production
# Use specific environment
docker compose --env-file .env.production up -d# Limit service resources in docker-compose.yml
services:
api:
deploy:
resources:
limits:
memory: 1G
cpus: '0.5'Add health checks to monitor service status:
# Check all services health
docker compose ps- API Health: http://localhost:7503/health
- API GraphQL: http://localhost:7503/graphql
- WebSocket: ws://localhost:7502
- Frontend: http://localhost:7500
- RabbitMQ Management: http://localhost:15672 (guest/guest)
# Rotate logs to prevent disk space issues
docker compose logs --no-log-prefix api > api.log 2>&1- First Run: Initial image pull may take 5-10 minutes depending on internet speed
- Resource Requirements: Reduced system requirements (4GB+ RAM recommended)
- Data Persistence: Database data is stored in Docker volumes
- Network: All services communicate on the default Docker bridge network
If you encounter issues:
- Check this README's troubleshooting section
- View service logs:
docker compose logs serviceName - Check Docker resources:
docker stats - Verify environment configuration:
cat .env
For additional help, contact the Gainium development team with:
- Your
.envfile (with secrets redacted) - Service logs showing the error
- Output of
docker compose ps