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

# This docker-compose file contains optional bootstrap services. Since it's optional, this file is
# dependent of docker-compose file from <project_root>/docker. In order to run this services, execute command:
# docker-compose -f docker/docker-compose.yml -f docker/addons/bootstrap/docker-compose.yml up
# from project root.

version: "3.7"

networks:
  docker_mainflux-base-net:
    external: true

volumes:
  mainflux-bootstrap-db-volume:

services:
  bootstrap-db:
    image: postgres:10.2-alpine
    container_name: mainflux-bootstrap-db
    restart: on-failure
    environment:
      POSTGRES_USER: ${MF_BOOTSTRAP_DB_USER}
      POSTGRES_PASSWORD: ${MF_BOOTSTRAP_DB_PASS}
      POSTGRES_DB: ${MF_BOOTSTRAP_DB}
    networks:
      - docker_mainflux-base-net
    volumes:
      - mainflux-bootstrap-db-volume:/var/lib/postgresql/data

  bootstrap:
    image: mainflux/bootstrap:latest
    container_name: mainflux-bootstrap
    depends_on:
      - bootstrap-db
    restart: on-failure
    ports:
      - ${MF_BOOTSTRAP_PORT}:${MF_BOOTSTRAP_PORT}
    environment:
      MF_BOOTSTRAP_LOG_LEVEL: ${MF_BOOTSTRAP_LOG_LEVEL}
      MF_BOOTSTRAP_DB_HOST: bootstrap-db
      MF_BOOTSTRAP_DB_PORT: ${MF_BOOTSTRAP_DB_PORT}
      MF_BOOTSTRAP_DB_USER: ${MF_BOOTSTRAP_DB_USER}
      MF_BOOTSTRAP_DB_PASS: ${MF_BOOTSTRAP_DB_PASS}
      MF_BOOTSTRAP_DB: ${MF_BOOTSTRAP_DB}
      MF_BOOTSTRAP_DB_SSL_MODE: ${MF_BOOTSTRAP_DB_SSL_MODE}
      MF_BOOTSTRAP_PORT: ${MF_BOOTSTRAP_PORT}
      MF_SDK_BASE_URL: http://mainflux-things:${MF_THINGS_HTTP_PORT}
      MF_THINGS_ES_URL: es-redis:${MF_REDIS_TCP_PORT}
      MF_BOOTSTRAP_ES_URL: es-redis:${MF_REDIS_TCP_PORT}
      MF_JAEGER_URL: ${MF_JAEGER_URL}
      MF_AUTHN_GRPC_URL: ${MF_AUTHN_GRPC_URL}
      MF_AUTHN_GRPC_TIMMEOUT: ${MF_AUTHN_GRPC_TIMEOUT}
    networks:
      - docker_mainflux-base-net
