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

# This docker-compose file contains optional opcua-adapter and opcua-redis services
# for the Mainflux platform. Since this services are optional, this file is dependent on the
# docker-compose.yml file from <project_root>/docker/. In order to run these services,
# core services, as well as the network from the core composition, should be already running.

version: "3.7"

networks:
  docker_mainflux-base-net:
    external: true

volumes:
  mainflux-opcua-adapter-volume:
  mainflux-opcua-redis-volume:

services:
  opcua-redis:
    image: redis:5.0-alpine
    container_name: mainflux-opcua-redis
    restart: on-failure
    networks:
      - docker_mainflux-base-net
    volumes:
      - mainflux-opcua-redis-volume:/data

  opcua-adapter:
    image: mainflux/opcua:latest
    container_name: mainflux-opcua
    restart: on-failure
    environment:
      MF_OPCUA_ADAPTER_HTTP_PORT: ${MF_OPCUA_ADAPTER_HTTP_PORT}
      MF_OPCUA_ADAPTER_LOG_LEVEL: ${MF_OPCUA_ADAPTER_LOG_LEVEL}
      MF_NATS_URL: ${MF_NATS_URL}
      MF_OPCUA_ADAPTER_POLICY: ${MF_OPCUA_ADAPTER_POLICY}
      MF_OPCUA_ADAPTER_MODE: ${MF_OPCUA_ADAPTER_MODE}
      MF_OPCUA_ADAPTER_CERT_FILE: ${MF_OPCUA_ADAPTER_CERT_FILE}
      MF_OPCUA_ADAPTER_KEY_FILE: ${MF_OPCUA_ADAPTER_KEY_FILE}
      MF_OPCUA_ADAPTER_ROUTE_MAP_URL: opcua-redis:${MF_REDIS_TCP_PORT}
      MF_OPCUA_ADAPTER_ROUTE_MAP_PASS: ${MF_OPCUA_ADAPTER_ROUTE_MAP_PASS}
      MF_OPCUA_ADAPTER_ROUTE_MAP_DB: ${MF_OPCUA_ADAPTER_ROUTE_MAP_DB}
      MF_THINGS_ES_URL: es-redis:${MF_REDIS_TCP_PORT}
      MF_THINGS_ES_PASS: ${MF_THINGS_ES_PASS}
      MF_THINGS_ES_DB: ${MF_THINGS_ES_DB}
      MF_OPCUA_ADAPTER_EVENT_CONSUMER: ${MF_OPCUA_ADAPTER_EVENT_CONSUMER}
    ports:
      - ${MF_OPCUA_ADAPTER_HTTP_PORT}:${MF_OPCUA_ADAPTER_HTTP_PORT}
    networks:
      - docker_mainflux-base-net
    volumes:
      - mainflux-opcua-adapter-volume:/store
