optionchain_simulator 0.1.0

OptionChain-Simulator is a lightweight REST API service that simulates an evolving option chain with every request. It is designed for developers building or testing trading systems, backtesters, and visual tools that depend on option data streams but want to avoid relying on live data feeds.
version: '3.8'

# Service images are pinned by IMMUTABLE digest (image: name:tag@sha256:...)
# so a redeploy can never silently pull a different build (issue #22). The
# tag is kept as a readable prefix only; the digest is what the engine
# resolves. Digests are the multi-arch manifest-list digests from Docker Hub
# (docker buildx imagetools inspect <image:tag>).
#
# Update workflow: bump ONE image at a time in a dedicated PR - re-resolve
# its digest with imagetools inspect, update tag and digest together, run
# the stack locally (make deploy) against the health checks, and record the
# tested combination in the PR. Never drop the digest or use :latest.

services:
  # Redis service configuration
  redis:
    image: redis:7.4@sha256:b2b95679e3b46fb51864949ed25ea976fc3a6bcc00a40a1bc00d568cb2822e50
    container_name: redis
    command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-password}
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    networks:
      - optionchain-network
    healthcheck:
      test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-password}", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    environment:
      - TZ=UTC
    restart: unless-stopped
  
  # MongoDB service configuration
  mongodb:
    image: mongo:7.0@sha256:d5b3ca8c3f3cdce78d44870dc0871b76d5235e9b2ad4ea6bea5d1fbff8027703
    container_name: mongodb
    ports:
      - "27017:27017"
    volumes:
      - mongodb-data:/data/db
      - mongodb-config:/data/configdb
    networks:
      - optionchain-network
    environment:
      - MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME:-admin}
      - MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:-password}
      - TZ=UTC
    healthcheck:
      test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  # MongoDB Express for web-based MongoDB management (optional)
  mongo-express:
    image: mongo-express:1.0.2@sha256:1b23d7976f0210dbec74045c209e52fbb26d29b2e873d6c6fa3d3f0ae32c2a64
    container_name: mongo-express
    restart: unless-stopped
    ports:
      - "8081:8081"
    environment:
      - ME_CONFIG_MONGODB_ADMINUSERNAME=${MONGO_USERNAME:-admin}
      - ME_CONFIG_MONGODB_ADMINPASSWORD=${MONGO_PASSWORD:-password}
      - ME_CONFIG_MONGODB_SERVER=mongodb
      - ME_CONFIG_BASICAUTH_USERNAME=${MONGOEXPRESS_USERNAME:-admin}
      - ME_CONFIG_BASICAUTH_PASSWORD=${MONGOEXPRESS_PASSWORD:-password}
    networks:
      - optionchain-network
    depends_on:
      - mongodb

  # Redis Commander for web-based Redis management (optional)
  redis-commander:
    image: rediscommander/redis-commander:redis-commander-210@sha256:25f93c06111f8614e3ecc8df5c563272bb465459a2e08e7f5364b5fe4c14f87f
    container_name: redis-commander
    restart: unless-stopped
    ports:
      - "8082:8081"
    environment:
      - REDIS_HOSTS=local:redis:6379:0:${REDIS_PASSWORD:-password}
      - HTTP_USER=${REDIS_COMMANDER_USER:-admin}
      - HTTP_PASSWORD=${REDIS_COMMANDER_PASSWORD:-password}
    networks:
      - optionchain-network
    depends_on:
      - redis
        
  clickhouse:
    image: clickhouse/clickhouse-server:24.8@sha256:1ffa82edee000a42c09313bd9f1293d94c570aee74babc1b3ca9983a35fa597b
    container_name: clickhouse
    ports:
      - "8123:8123"   # HTTP interface
      - "9000:9000"   # Native client (TCP)
    environment:
      CLICKHOUSE_USER: ${CLICKHOUSE_USER:-admin}
      CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:-password}
      CLICKHOUSE_DB: ${CLICKHOUSE_DB:-default}
    volumes:
      - clickhouse_data:/var/lib/clickhouse
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    restart: unless-stopped
    networks:
      - optionchain-network

  backend:
    build:
      context: ..
      dockerfile: Docker/Dockerfile
    container_name: backend
    restart: unless-stopped
    environment:
      CLICKHOUSE_USER: ${CLICKHOUSE_USER:-admin}
      CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:-password}
      CLICKHOUSE_DB: ${CLICKHOUSE_DB:-default}
      CLICKHOUSE_PORT: ${CLICKHOUSE_PORT-8123}
      CLICKHOUSE_HOST: ${CLICKHOUSE_HOST-clickhouse}
      MONGODB_URI: ${MONGODB_URI-mongodb://admin:password@mongodb:27017}
      MONGODB_DATABASE: ${MONGODB_DATABASE-optionchain_simulator}
      MONGODB_STEPS_COLLECTION: ${MONGODB_STEPS_COLLECTION-steps}
      MONGODB_EVENTS_COLLECTION: ${MONGODB_EVENTS_COLLECTION-events}
      MONGODB_TIMEOUT: ${MONGODB_TIMEOUT-30}
      REDIS_PORT: ${REDIS_PORT-6379}
      REDIS_DB: ${REDIS_DB-0}
      REDIS_USER: ${REDIS_USER}
      REDIS_PASSWORD: ${REDIS_PASSWORD-password}
      REDIS_HOST: ${REDIS_HOST-redis}
    depends_on:
      - redis
      - mongodb
      - clickhouse
    ports:
      - "7070:7070"
    networks:
      - optionchain-network
      
networks:
  optionchain-network:
    driver: bridge

volumes:
  redis-data:
    driver: local
  mongodb-data:
    driver: local
  mongodb-config:
    driver: local
  clickhouse_data:
    driver: local