Barfinex

Getting started

Docker Compose for Barfinex Provider

What containers the Barfinex Provider stack consists of, what each service does, and how they are wired together.

🧱 Stack structure

The Barfinex Provider stack is a small cluster of several services. Each container plays its own role β€” from processing market data and storing state to caching, administration, and managing the Docker environment itself. Thanks to this layout you get a reproducible infrastructure that can be started, stopped, or moved to another server with a single command, without manually untangling dependencies between services.

Why docker-compose.yml is needed

The docker-compose.yml file describes the entire stack required for Barfinex Provider:

  • the provider service itself;
  • data stores and cache (mongo, postgres, redis);
  • web admin interfaces (mongo-express, redis-commander, portainer);
  • a shared network and volumes for data and configs.

Start everything with one command:

docker compose up -d

Overall structure

Below is a typical docker-compose.yml layout (structure, not a full listing):

services:
  provider:
    ...
  mongo:
    ...
  mongo-express:
    ...
  redis:
    ...
  redis-commander:
    ...
  portainer:
    ...
  postgres:
    ...
networks:
  barfinapp-network:
    driver: bridge

Let’s break down what each service does.


🟦 provider β€” the core Barfinex Provider service

The main container that runs the Barfinex Provider application (Node.js + NestJS).

Key sections:

provider:
  container_name: ${PROVIDER_CONTAINER_NAME}
  image: ${PROVIDER_IMAGE}
  restart: "no"
  privileged: true
  env_file:
    - .env
  environment:
    - MONGO_HOST=${MONGO_HOST}
    - REDIS_HOST=${REDIS_HOST}
    - NODE_ENV=production
    - NODE_OPTIONS=--max-old-space-size=4096
    - BINANCE_API_KEY=${BINANCE_API_KEY}
    - BINANCE_API_SECRET=${BINANCE_API_SECRET}
    - TESTNET_BINANCE_SPOT_KEY=${TESTNET_BINANCE_SPOT_KEY}
    - TESTNET_BINANCE_SPOT_SECRET=${TESTNET_BINANCE_SPOT_SECRET}
  command: ${PROVIDER_COMMAND}
  ports:
    - "${PROVIDER_API_PORT}:${PROVIDER_API_PORT}"
  networks:
    - barfinapp-network
  depends_on:
    - redis
    - mongo
  stdin_open: true
  tty: true
  volumes:
    ...

Important points:

  • image β€” Barfinex Provider Docker image (usually from GHCR: ghcr.io/barfinex/provider:tag);
  • env_file + environment β€” environment settings (Mongo, Redis, Binance keys, etc.);
  • ports β€” API port mapping;
  • depends_on β€” Redis and Mongo are started first;
  • volumes β€” mount configs, certificates, and keys.

Barfinex Provider volumes

volumes:
  # πŸ”§ Core configs
  - ./docker-config/config.json:/usr/src/app/config.json:ro
  - ./docker-config/config.provider.json:/usr/src/app/config.provider.json:ro
  - ./docker-config/config.advisor.json:/usr/src/app/config.advisor.json:ro
  - ./docker-config/config.detector.json:/usr/src/app/config.detector.json:ro
  - ./docker-config/config.inspector.json:/usr/src/app/config.inspector.json:ro
  - ./docker-config:/usr/src/app/config:ro

  # πŸ” SSL certificates (mkcert)
  - ./cert/localhost+2-key.pem:/usr/src/app/cert/localhost+2-key.pem:ro
  - ./cert/localhost+2.pem:/usr/src/app/cert/localhost+2.pem:ro

  # πŸ”‘ Access keys (exchanges, services)
  - ./data/keys:/usr/src/app/.keys

  # πŸ•’ Time sync (optional)
  - /etc/localtime:/etc/localtime:ro
  - /etc/timezone:/etc/timezone:ro
  • Configs β€” JSON files configuring modules (provider/advisor/detector/inspector);
  • Certificates β€” for HTTPS (mkcert locally or production certs);
  • Keys β€” secure storage for file‑based keys;
  • Time β€” keep container time zone in sync with the host.

🟩 mongo β€” data store

mongo:
  container_name: ${MONGO_CONTAINER_NAME}
  image: ${MONGO_IMAGE}
  restart: always
  ports:
    - "${MONGO_PORT}:${MONGO_PORT}"
  volumes:
    - ./data/mongo:/data/db
    - ./docker-config/mongo-init-db.js:/docker-entrypoint-initdb.d/init-db.js:ro
  networks:
    - barfinapp-network
  • Stores aggregated data and state.
  • ./data/mongo β€” data folder on the host.
  • mongo-init-db.js runs on first start and initializes the database.

🟦 mongo-express β€” web UI for MongoDB

mongo-express:
  container_name: ${MONGO_EXPRESS_CONTAINER_NAME}
  image: ${MONGO_EXPRESS_IMAGE}
  restart: always
  ports:
    - "${MONGO_EXPRESS_PORT}:8081"
  environment:
    ME_CONFIG_BASICAUTH_USERNAME: ${MONGO_ROOT_USERNAME}
    ME_CONFIG_BASICAUTH_PASSWORD: ${MONGO_ROOT_PASSWORD}
    ME_CONFIG_MONGODB_SERVER: ${MONGO_CONTAINER_NAME}
  depends_on:
    - mongo
  networks:
    - barfinapp-network

Lets you:

  • inspect collections and documents;
  • quickly verify that data is coming from Barfinex Provider;
  • avoid using the Mongo shell for simple checks.

⚠️ Don’t forget to configure basic auth via environment variables.


πŸŸ₯ redis β€” cache and event bus

redis:
  container_name: ${REDIS_CONTAINER_NAME}
  image: ${REDIS_IMAGE}
  restart: always
  ports:
    - "${REDIS_PORT}:${REDIS_PORT}"
  networks:
    - barfinapp-network
  • Barfinex Provider uses Redis as an event bus and cache.
  • Make sure REDIS_HOST in .env points to this service.

πŸŸ₯ redis-commander β€” web UI for Redis

redis-commander:
  container_name: ${REDIS_COMMANDER_CONTAINER_NAME}
  image: ${REDIS_COMMANDER_IMAGE}
  restart: always
  ports:
    - "${REDIS_COMMANDER_PORT}:${REDIS_COMMANDER_PORT}"
  hostname: ${REDIS_COMMANDER_HOSTNAME}
  networks:
    - barfinapp-network
  environment:
    - PORT=${REDIS_COMMANDER_PORT}
    - REDIS_HOSTS=local:${REDIS_COMMANDER_REDIS_HOST}:${REDIS_PORT}

A web dashboard for Redis, useful to:

  • inspect keys and channels;
  • verify that events from Barfinex Provider are actually being published.

🟦 portainer β€” Docker management UI

portainer:
  container_name: ${PONTEINER_CONTAINER_NAME}
  image: ${PONTEINER_IMAGE}
  restart: always
  ports:
    - "${PONTEINER_PORT}:${PONTEINER_PORT}"
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - ./data/portainer:/data
  networks:
    - barfinapp-network
  environment:
    - ADMIN_USERNAME=${PONTEINER_ADMIN_USERNAME}
    - ADMIN_PASSWORD=${PONTEINER_ADMIN_PASSWORD}

Allows you to:

  • manage containers via browser;
  • view logs, restart services, update images;
  • especially handy on remote servers and production environments.

🟨 postgres β€” relational database

postgres:
  container_name: postgres
  image: postgres:15
  restart: always
  environment:
    POSTGRES_USER: ${DB_USERNAME}
    POSTGRES_PASSWORD: ${DB_PASSWORD}
    POSTGRES_DB: ${DB_NAME}
  ports:
    - "${DB_PORT}:5432"
  volumes:
    - ./data/postgres:/var/lib/postgresql/data
  networks:
    - barfinapp-network

Used to store:

  • account state,
  • configurations,
  • logs and other structured data (depending on your project configuration).

🌐 Network

networks:
  barfinapp-network:
    driver: bridge

All services share a single network:

  • they can reach each other by container name (mongo, redis, provider);
  • they are isolated from unrelated containers running on the host.

πŸ“Œ docker-compose.yml recap

  • docker-compose.yml defines the full stack needed for Barfinex Provider.
  • Each service has a clear role: data, cache, admin UIs, container management.
  • Move configuration into .env, and store sensitive data (keys) in volumes/files.
  • This file is the foundation for declarative deployment of Barfinex Provider to dev/stage/prod environments.

Let’s Get in Touch

Have questions or want to join Barfinex? Send us a message.