version: '3.7'
services:

  # ---------------------------------------------------------------------------------------- Auth ---
  auth:
    image: registry.geekcoders.cz/inspectlife/monorepo/auth-server:master
    environment:
      APP_NAME: "InspectLife Auth Server"
      APP_ENV: "local"
      APP_KEY: "base64:0ib0e0+bIea7ItmeSz7DoF4PG7vWTzngYU2iMA4niqE="
      APP_DEBUG: "true"
      DB_CONNECTION: "mongodb"
      DB_HOST: "mongo"
      DB_DATABASE: "auth"
      DB_USERNAME: "root"
      DB_PASSWORD: "secret"
      DEFUSE_KEY: "def00000f767c10e4fc7389aac1f8c0deb19e1d4061b2fc492672a6e0cfd02b74f5d3de1e9863da7618c09090bce5f74830f5fd975715bd28a9e70bad4f422ee70a74f49"
      OAUTH_CLIENT_ID: "60c1db0c7039c43054191ea2"
      OAUTH_CLIENT_SECRET: "secret"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
    restart: unless-stopped
    working_dir: /app
    networks:
      - inspect-network
    volumes:
      - $PWD/auth-server:/app
      - $PWD/shared:/shared
      - $PWD/assets/oauth-certs:/app/storage/certificates
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.auth.entrypoints=web"
      - "traefik.http.routers.auth.rule=PathPrefix(`/auth_api`)"
      - "traefik.http.middlewares.auth_strip.stripprefix.prefixes=/auth_api"
      - "traefik.http.middlewares.auth_strip.stripprefix.forceSlash=false"
      - "traefik.http.routers.auth.middlewares=auth_strip@docker"

  # ---------------------------------------------------------------------------------------- Base ---
  base:
    image: registry.geekcoders.cz/inspectlife/monorepo/base-server:master
    environment:
      APP_NAME: "InspectLife Base Server"
      APP_ENV: "local"
      APP_KEY: "base64:0ib0e0+bIea7ItmeSz7DoF4PG7vWTzngYU2iMA4niqE="
      APP_DEBUG: "true"
      DB_CONNECTION: "mongodb"
      DB_HOST: "mongo"
      DB_DATABASE: "base"
      DB_USERNAME: "root"
      DB_PASSWORD: "secret"
      OAUTH_CLIENT_ID: "60c1db0c7039c43054191ea2"
      OAUTH_CLIENT_SECRET: "secret"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
      ELASTIC_ENABLED: "false"
    restart: unless-stopped
    working_dir: /app
    networks:
      - inspect-network
    volumes:
      - $PWD/base-server:/app
      - $PWD/shared:/shared
      - $PWD/assets/oauth-certs:/app/storage/certificates
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.base.entrypoints=web"
      - "traefik.http.routers.base.rule=PathPrefix(`/base_api`)"
      - "traefik.http.middlewares.base_strip.stripprefix.prefixes=/base_api"
      - "traefik.http.middlewares.base_strip.stripprefix.forceSlash=false"
      - "traefik.http.routers.base.middlewares=base_strip@docker"

  # ---------------------------------------------------------------------------------- File proxy ---
  file:
    image: registry.geekcoders.cz/inspectlife/monorepo/file-proxy:master
    environment:
      APP_NAME: "InspectLife File Proxy"
      APP_ENV: "local"
      APP_KEY: "base64:0ib0e0+bIea7ItmeSz7DoF4PG7vWTzngYU2iMA4niqE="
      APP_DEBUG: "true"
      DB_CONNECTION: "mongodb"
      DB_HOST: "mongo"
      DB_DATABASE: "file_proxy"
      DB_USERNAME: "root"
      DB_PASSWORD: "secret"
      AWS_ACCESS_KEY_ID: "minio"
      AWS_SECRET_ACCESS_KEY: "DpJjhp4Y"
      AWS_DEFAULT_REGION: "us-east-1"
      AWS_BUCKET: "inspect"
      AWS_URL: "http://minio:9000"
      AWS_ENDPOINT: "http://minio:9000"
      AWS_USE_PATH_STYLE_ENDPOINT: "true"
      OAUTH_CLIENT_ID: "60c1db0c7039c43054191ea2"
      OAUTH_CLIENT_SECRET: "secret"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
    restart: unless-stopped
    working_dir: /app
    networks:
      - inspect-network
    volumes:
      - $PWD/file-proxy:/app
      - $PWD/shared:/shared
      - $PWD/assets/oauth-certs:/app/storage/certificates
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.fp.entrypoints=web"
      - "traefik.http.routers.fp.rule=PathPrefix(`/file_proxy`)"
      - "traefik.http.middlewares.fp_strip.stripprefix.prefixes=/file_proxy"
      - "traefik.http.middlewares.fp_strip.stripprefix.forceSlash=false"
      - "traefik.http.routers.fp.middlewares=fp_strip@docker"

  # --------------------------------------------------------------------------------- Cal Server ---
  cal:
    image: registry.geekcoders.cz/inspectlife/monorepo/cal-server:master
    environment:
      APP_NAME: "InspectLife Cal Server"
      APP_ENV: "local"
      APP_KEY: "base64:0ib0e0+bIea7ItmeSz7DoF4PG7vWTzngYU2iMA4niqE="
      APP_DEBUG: "true"
      DB_CONNECTION: "mongodb"
      DB_HOST: "mongo"
      DB_DATABASE: "cal"
      DB_USERNAME: "root"
      DB_PASSWORD: "secret"
      OAUTH_CLIENT_ID: "60c1db0c7039c43054191ea2"
      OAUTH_CLIENT_SECRET: "secret"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
    restart: unless-stopped
    working_dir: /app
    networks:
      - inspect-network
    volumes:
      - $PWD/cal-server:/app
      - $PWD/shared:/shared
      - $PWD/assets/oauth-certs:/app/storage/certificates
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.cs.entrypoints=web"
      - "traefik.http.routers.cs.rule=PathPrefix(`/cal_api`)"
      - "traefik.http.middlewares.cs_strip.stripprefix.prefixes=/cal_api"
      - "traefik.http.middlewares.cs_strip.stripprefix.forceSlash=false"
      - "traefik.http.routers.cs.middlewares=cs_strip@docker"

  # ----------------------------------------------------------------------------- Ordering Server ---
  order:
    image: registry.geekcoders.cz/inspectlife/monorepo/ordering-server:master
    environment:
      APP_NAME: "InspectLife Ordering Server"
      APP_ENV: "local"
      APP_KEY: "base64:0ib0e0+bIea7ItmeSz7DoF4PG7vWTzngYU2iMA4niqE="
      APP_DEBUG: "true"
      DB_CONNECTION: "mongodb"
      DB_HOST: "mongo"
      DB_DATABASE: "ordering"
      DB_USERNAME: "root"
      DB_PASSWORD: "secret"
      AWS_ACCESS_KEY_ID: "minio"
      AWS_SECRET_ACCESS_KEY: "DpJjhp4Y"
      AWS_DEFAULT_REGION: "us-east-1"
      AWS_BUCKET: "inspect"
      AWS_URL: "http://minio:9000"
      AWS_ENDPOINT: "http://minio:9000"
      AWS_USE_PATH_STYLE_ENDPOINT: "true"
      OAUTH_CLIENT_ID: "60c1db0c7039c43054191ea2"
      OAUTH_CLIENT_SECRET: "secret"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
    restart: unless-stopped
    working_dir: /app
    networks:
      - inspect-network
    volumes:
      - $PWD/ordering-server:/app
      - $PWD/shared:/shared
      - $PWD/assets/oauth-certs:/app/storage/certificates
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.os.entrypoints=web"
      - "traefik.http.routers.os.rule=PathPrefix(`/order_api`)"
      - "traefik.http.middlewares.os_strip.stripprefix.prefixes=/order_api"
      - "traefik.http.middlewares.os_strip.stripprefix.forceSlash=false"
      - "traefik.http.routers.os.middlewares=os_strip@docker"

  # --------------------------------------------------------------------------- EDG Config Server ---
  edg-config-server:
    image: registry.geekcoders.cz/inspectlife/monorepo/edgy-config-server:master
    environment:
      APP_NAME: "InspectLife EDGy Config Server"
      APP_ENV: "local"
      APP_KEY: "base64:0ib0e0+bIea7ItmeSz7DoF4PG7vWTzngYU2iMA4niqE="
      APP_DEBUG: "true"
      DB_CONNECTION: "mongodb"
      DB_HOST: "mongo"
      DB_DATABASE: "edg"
      DB_USERNAME: "root"
      DB_PASSWORD: "secret"
      OAUTH_CLIENT_ID: "60c1db0c7039c43054191ea2"
      OAUTH_CLIENT_SECRET: "secret"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
      BASE_CONNECTION_URL: "http://localhost:8000/edg_api/v1/services/connect/"
      BASE_DISCONNECTION_URL: "http://localhost:8000/edg_api/v1/services/disconnect/"
    restart: unless-stopped
    working_dir: /app
    networks:
      - inspect-network
    volumes:
      - $PWD/edgy-config-server:/app
      - $PWD/shared:/shared
      - $PWD/assets/oauth-certs:/app/storage/certificates
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.es.entrypoints=web"
      - "traefik.http.routers.es.rule=PathPrefix(`/edg_api/`)"
      - "traefik.http.middlewares.es_strip.stripprefix.prefixes=/edg_api"
      - "traefik.http.middlewares.es_strip.stripprefix.forceSlash=false"
      - "traefik.http.routers.es.middlewares=es_strip@docker"

  # --------------------------------------------------------------------------- Telerehab Server ---
  telerehab-server:
    image: registry.geekcoders.cz/inspectlife/monorepo/telerehab-server:master
    environment:
      APP_NAME: "InspectLife Telerehab Server"
      APP_ENV: "local"
      APP_KEY: "base64:0ib0e0+bIea7ItmeSz7DoF4PG7vWTzngYU2iMA4niqE="
      APP_DEBUG: "true"
      DB_CONNECTION: "mongodb"
      DB_HOST: "mongo"
      DB_DATABASE: "telerehab"
      DB_USERNAME: "root"
      DB_PASSWORD: "secret"
      OAUTH_CLIENT_ID: "60c1db0c7039c43054191ea2"
      OAUTH_CLIENT_SECRET: "secret"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
    restart: unless-stopped
    working_dir: /app
    networks:
      - inspect-network
    volumes:
      - $PWD/telerehab-server:/app
      - $PWD/shared:/shared
      - $PWD/assets/oauth-certs:/app/storage/certificates
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.ts.entrypoints=web"
      - "traefik.http.routers.ts.rule=PathPrefix(`/telerehab_api/`)"
      - "traefik.http.middlewares.ts_strip.stripprefix.prefixes=/telerehab_api"
      - "traefik.http.middlewares.ts_strip.stripprefix.forceSlash=false"
      - "traefik.http.routers.ts.middlewares=ts_strip@docker"

  # ------------------------------------------------------------------------ Notification Server ---
  notification-server:
    image: registry.geekcoders.cz/inspectlife/monorepo/notification-server:master
    environment:
      APP_NAME: "InspectLife Notification Server"
      APP_ENV: "local"
      APP_KEY: "base64:0ib0e0+bIea7ItmeSz7DoF4PG7vWTzngYU2iMA4niqE="
      APP_DEBUG: "true"
      DB_CONNECTION: "mongodb"
      DB_HOST: "mongo"
      DB_DATABASE: "notifications"
      DB_USERNAME: "root"
      DB_PASSWORD: "secret"
      OAUTH_CLIENT_ID: "60c1db0c7039c43054191ea2"
      OAUTH_CLIENT_SECRET: "secret"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
      MAIL_DRIVER: "smtp"
      MAIL_HOST: "email-smtp.eu-central-1.amazonaws.com"
      MAIL_ENCRYPTION: "TLS"
      MAIL_PORT: "587"
      MAIL_USERNAME: "AKIAYDH6L4BSXYMQCCCH"
      MAIL_PASSWORD: "BGI31mOBFwIfZMXIaHJ9yQwcfGvPXB72btEbkeWUAa+q"
      MAIL_FROM_ADDRESS: "no-reply.dev@ilplatform.cz"
    restart: unless-stopped
    working_dir: /app
    networks:
      - inspect-network
    volumes:
      - $PWD/notification-server:/app
      - $PWD/shared:/shared
      - $PWD/assets/oauth-certs:/app/storage/certificates
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.ns.entrypoints=web"
      - "traefik.http.routers.ns.rule=PathPrefix(`/notification_api/`)"
      - "traefik.http.middlewares.ns_strip.stripprefix.prefixes=/notification_api"
      - "traefik.http.middlewares.ns_strip.stripprefix.forceSlash=false"
      - "traefik.http.routers.ns.middlewares=ns_strip@docker"

# ------------------------------------------------------------------------------------------ UI ---

  # ------------------------------------------------------------------------------------ Services ---
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0
    environment:
      - xpack.security.enabled=false
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms750m -Xmx750m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - $PWD/elastic:/data
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - inspect-network

  kibana:
    container_name: kibana
    image: docker.elastic.co/kibana/kibana:7.4.0
    environment:
      - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch
    networks:
      - inspect-network

  traefik:
    image: "traefik:v2.4"
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:8000"
      - "--entrypoints.websecure.address=:443"
    ports:
      - "8000:8000"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    networks:
      - inspect-network
    labels:
      ###               ###
      # Traefik Dashboard #
      ###               ###
      # Enable this endpoint
      - traefik.enable=true
      - traefik.docker.network=inspect-network
      # Set the service route
      - traefik.http.routers.traefik.rule=Host(`monitor.local`)
      # Set the entrypoint (http or https)
      - traefik.http.routers.traefik.entrypoints=web
      - traefik.http.services.traefik.loadbalancer.server.port=8080

  redis:
    image: redis:6.0-buster
    networks:
      - inspect-network

  mongo:
    image: mongo
    restart: always
    networks:
      - inspect-network
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: secret
    volumes:
      - mongo_data:/data/db
      - ./assets/dumps:/mongo-seed

  mongo-express:
    image: mongo-express
    restart: always
    networks:
      - inspect-network
    ports:
      - 8081:8081
    environment:
      ME_CONFIG_MONGODB_SERVER: mongo
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: secret

  minio:
    image: minio/minio:RELEASE.2021-06-07T21-40-51Z
    environment:
      MINIO_ACCESS_KEY: "minio_access_key"
      MINIO_SECRET_KEY: "minio_secret_key"
      MINIO_REGION: "us-east-1"
      MINIO_BUCKET: "inspect"
      MINIO_ROOT_USER: "minio"
      MINIO_ROOT_PASSWORD: "DpJjhp4Y"
    ports:
      - 9000:9000
    networks:
      - inspect-network
    volumes:
      - minio_data:/data
    command: server /data
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=inspect-network"
      - "traefik.http.routers.minio.rule=Host(`minio.local`)"
      # Set the entrypoint (http or https)
      - "traefik.http.routers.minio.entrypoints=web"
      # Enable Https redirection
      - "traefik.http.services.minio.loadbalancer.server.port=9000"

  createbuckets:
    image: minio/mc
    networks:
      - inspect-network
    depends_on:
      - minio
    entrypoint: >
      /bin/sh -c "
      /usr/bin/mc config host add myminio http://minio:9000 minio password;
      /usr/bin/mc mb myminio/inspect;
      /usr/bin/mc policy set public myminio/inspect;
      exit 0;
      "

  rabbitmq:
    image: registry.geekcoders.cz/inspectlife/monorepo/rabbitmq:latest
    networks:
      - inspect-network
    ports:
      - 5672:5672
      - 15672:15672

networks:
  inspect-network:
    driver: bridge
    driver_opts:
      com.docker.network.driver.mtu: 1300

volumes:
  minio_data:
    driver: local
  mongo_data:
    driver: local
