# Copyright (c) Mainflux
# SPDX-License-Identifier: Apache-2.0

# This docker-compose file contains optional Cassandra and cassandra-writer. Since these are optional, this file is
# dependent of docker-compose file from <project_root>/docker. In order to run these services, execute command:
# docker-compose -f docker/docker-compose.yml -f docker/addons/cassandra-writer/docker-compose.yml up
# from project root.

version: "3.7"

networks:
  docker_mainflux-base-net:
    external: true

volumes:
  mainflux-cassandra-volume:

services:
  cassandra:
    image: cassandra:3.11.3
    container_name: mainflux-cassandra
    restart: on-failure
    networks:
      - docker_mainflux-base-net
    ports:
      - ${MF_CASSANDRA_WRITER_DB_PORT}:${MF_CASSANDRA_WRITER_DB_PORT}
    volumes:
      - mainflux-cassandra-volume:/var/lib/cassandra

  cassandra-writer:
    image: mainflux/cassandra-writer:latest
    container_name: mainflux-cassandra-writer
    depends_on:
      - cassandra
    restart: on-failure
    environment:
      MF_CASSANDRA_WRITER_LOG_LEVEL: ${MF_CASSANDRA_WRITER_LOG_LEVEL}
      MF_NATS_URL: ${MF_NATS_URL}
      MF_CASSANDRA_WRITER_PORT: ${MF_CASSANDRA_WRITER_PORT}
      MF_CASSANDRA_WRITER_DB_PORT: ${MF_CASSANDRA_WRITER_DB_PORT}
      MF_CASSANDRA_WRITER_DB_CLUSTER: ${MF_CASSANDRA_WRITER_DB_CLUSTER}
      MF_CASSANDRA_WRITER_DB_KEYSPACE: ${MF_CASSANDRA_WRITER_DB_KEYSPACE}
    ports:
      - ${MF_CASSANDRA_WRITER_PORT}:${MF_CASSANDRA_WRITER_PORT}
    networks:
      - docker_mainflux-base-net
    volumes:
      - ./subjects.toml:/config/subjects.toml
