version: '3.7'

services:
  # ---------------------------------------------------------------------------------------- Auth ---
  auth:
    image: registry.geekcoders.cz/inspectlife/monorepo/auth-server:master
    environment:
      APP_NAME: "InspectLife Auth Server"
      APP_ENV: "test"
      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: "def0000068e61bbb3469c3a211466213cef612fa5c0637950598f412cb32300e10c7b5c50b5bb7c1eae57cee67652248353fa4b79e7b6560057fa8f04409d393e647a788"
      PRIVATE_KEY_PASSPHRASE: "eh78T9JBxUwbJSRwAHWITWd6d0vuBspW"
      OAUTH_CLIENT_ID: "60c1db0c7039c43054191ea2"
      OAUTH_CLIENT_SECRET: "secret"
      MAIL_DRIVER: "smtp"
      MAIL_HOST: "email-smtp.eu-central-1.amazonaws.com"
      MAIL_ENCRYPTION: "ssl"
      MAIL_PORT: "465"
      MAIL_USERNAME: "AKIAYDH6L4BSR5IMEZZO"
      MAIL_PASSWORD: "BAOjlrUcU6SzN8apjpGIhPu3FdhBQ8fbqyjHaDvRCjoo"
      MAIL_FROM_ADDRESS: "inspectlife@vyvijime.eu"
      FE_URL: "https://${BASE_HOST}"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
      ROCKET_CHAT_USER: "CjWhQhkAihmGwCKBW"
      ROCKET_CHAT_TOKEN: "coG5FmdIL9AJwbekh8fNaqwtw2wAotJXI6a0KBWTpcq"
      ROCKET_CHAT_URL: "https://rocketchat-dev.ilplatform.cz/api/v1/"
      LOG_CHANNEL: stack
    networks:
      - inbound
    volumes:
      # - ./auth-server/storage:/var/www/storage
      - ./assets/prod-oauth-certs:/var/www/storage/certificates
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '1'
          memory: 500M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.auth-http.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/auth_api`)
        - traefik.http.middlewares.auth_strip.stripprefix.prefixes=/auth_api
        - traefik.http.middlewares.auth_strip.stripprefix.forceSlash=false
        - traefik.http.routers.auth-http.middlewares=auth_strip@docker, traefik-https-redirect@docker
        - traefik.http.routers.auth-http.entrypoints=web
        - traefik.http.routers.auth-https.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/auth_api`)
        - traefik.http.routers.auth-https.entrypoints=websecure
        - traefik.http.routers.auth-https.middlewares=auth_strip@docker
        - traefik.http.routers.auth-https.service=auth
        - traefik.http.routers.auth-https.tls=true
        - traefik.http.routers.auth-https.tls.certresolver=zerossl
        - traefik.http.services.auth.loadbalancer.server.port=8000

  # ---------------------------------------------------------------------------------------- Base ---
  base:
    image: registry.geekcoders.cz/inspectlife/monorepo/base-server:master
    environment:
      APP_NAME: "InspectLife Base Server"
      APP_ENV: "test"
      APP_KEY: "base64:0ib0e0+bIea7ItmeSz7DoF4PG7vWTzngYU2iMA4niqE="
      PRIVATE_KEY_PASSPHRASE: "eh78T9JBxUwbJSRwAHWITWd6d0vuBspW"
      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"
      QUEUE_CONNECTION: "rabbitmq"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
      ELASTIC_ENABLED: "false"
      LOG_CHANNEL: stack
    networks:
      - inbound
    volumes:
      - ./assets/prod-oauth-certs:/var/www/storage/certificates
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '0.60'
          memory: 300M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.base-http.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/base_api`)
        - traefik.http.middlewares.base_strip.stripprefix.prefixes=/base_api
        - traefik.http.middlewares.base_strip.stripprefix.forceSlash=false
        - traefik.http.routers.base-http.middlewares=base_strip@docker,traefik-https-redirect@docker
        - traefik.http.routers.base-http.entrypoints=web
        - traefik.http.routers.base-https.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/base_api`)
        - traefik.http.routers.base-https.entrypoints=websecure
        - traefik.http.routers.base-https.middlewares=base_strip@docker
        - traefik.http.routers.base-https.service=base
        - traefik.http.routers.base-https.tls=true
        - traefik.http.routers.base-https.tls.certresolver=zerossl
        - traefik.http.services.base.loadbalancer.server.port=8000

  # ---------------------------------------------------------------------------------- File proxy ---
  file:
    image: registry.geekcoders.cz/inspectlife/monorepo/file-proxy:master
    environment:
      APP_NAME: "InspectLife File Proxy"
      APP_ENV: "test"
      PRIVATE_KEY_PASSPHRASE: "eh78T9JBxUwbJSRwAHWITWd6d0vuBspW"
      APP_KEY: "base64:0ib0e0+bIea7ItmeSz7DoF4PG7vWTzngYU2iMA4niqE="
      APP_DEBUG: "true"
      DB_CONNECTION: "mongodb"
      DB_HOST: "mongo"
      DB_DATABASE: "file_proxy"
      DB_USERNAME: "root"
      DB_PASSWORD: "secret"
      RABBITMQ_HOST: "rabbitmq"
      RABBITMQ_PORT: 5672
      RABBITMQ_USER: "guest"
      RABBITMQ_PASSWORD: "guest"
      AWS_ACCESS_KEY_ID: "minio"
      AWS_SECRET_ACCESS_KEY: "DpJjhp4Y"
      AWS_DEFAULT_REGION: "us-east-1"
      AWS_BUCKET: "inspect"
      AWS_URL: "https://minio.${BASE_HOST}"
      AWS_ENDPOINT: "https://minio.${BASE_HOST}"
      AWS_USE_PATH_STYLE_ENDPOINT: "true"
      OAUTH_CLIENT_ID: "60c1db0c7039c43054191ea2"
      OAUTH_CLIENT_SECRET: "secret"
      LOG_CHANNEL: stack
    networks:
      - inbound
    volumes:
      - ./assets/prod-oauth-certs:/var/www/storage/certificates
    deploy:
      mode: replicated
      replicas: 1
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.file-proxy-http.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/file_proxy`)
        - traefik.http.middlewares.fp_strip.stripprefix.prefixes=/file_proxy
        - traefik.http.middlewares.fp_strip.stripprefix.forceSlash=false
        - traefik.http.routers.file-proxy-http.middlewares=fp_strip@docker,traefik-https-redirect@docker
        - traefik.http.routers.file-proxy-http.entrypoints=web
        - traefik.http.routers.file-proxy-https.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/file_proxy`)
        - traefik.http.routers.file-proxy-https.entrypoints=websecure
        - traefik.http.routers.file-proxy-https.middlewares=fp_strip@docker
        - traefik.http.routers.file-proxy-https.service=file-proxy
        - traefik.http.routers.file-proxy-https.tls=true
        - traefik.http.routers.file-proxy-https.tls.certresolver=zerossl
        - traefik.http.services.file-proxy.loadbalancer.server.port=8000

  # --------------------------------------------------------------------------------- Cal Server ---
  cal:
    image: registry.geekcoders.cz/inspectlife/monorepo/cal-server:master
    environment:
      APP_NAME: "InspectLife Cal Server"
      APP_ENV: "test"
      PRIVATE_KEY_PASSPHRASE: "eh78T9JBxUwbJSRwAHWITWd6d0vuBspW"
      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"
      LOG_CHANNEL: stack
    networks:
      - inbound
    volumes:
      - ./assets/prod-oauth-certs:/var/www/storage/certificates
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '0.60'
          memory: 300M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.cal-http.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/cal_api`)
        - traefik.http.middlewares.cal_strip.stripprefix.prefixes=/cal_api
        - traefik.http.middlewares.cal_strip.stripprefix.forceSlash=false
        - traefik.http.routers.cal-http.middlewares=cal_strip@docker,traefik-https-redirect@docker
        - traefik.http.routers.cal-http.entrypoints=web
        - traefik.http.routers.cal-https.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/cal_api`)
        - traefik.http.routers.cal-https.entrypoints=websecure
        - traefik.http.routers.cal-https.middlewares=cal_strip@docker
        - traefik.http.routers.cal-https.service=cal-server
        - traefik.http.routers.cal-https.tls=true
        - traefik.http.routers.cal-https.tls.certresolver=zerossl
        - traefik.http.services.cal-server.loadbalancer.server.port=8000

  # --------------------------------------------------------------------------- Telerehab Server ---
  telerehab-server:
    image: registry.geekcoders.cz/inspectlife/monorepo/telerehab-server:master
    environment:
      APP_NAME: "InspectLife Telerehab Server"
      APP_ENV: "test"
      PRIVATE_KEY_PASSPHRASE: "eh78T9JBxUwbJSRwAHWITWd6d0vuBspW"
      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"
      LOG_CHANNEL: stack
    networks:
      - inbound
    volumes:
      - ./assets/prod-oauth-certs:/var/www/storage/certificates
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '0.60'
          memory: 300M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.ts-http.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/telerehab_api`)
        - traefik.http.middlewares.ts_strip.stripprefix.prefixes=/telerehab_api
        - traefik.http.middlewares.ts_strip.stripprefix.forceSlash=false
        - traefik.http.routers.ts-http.middlewares=ts_strip@docker,traefik-https-redirect@docker
        - traefik.http.routers.ts-http.entrypoints=web
        - traefik.http.routers.ts-https.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/telerehab_api`)
        - traefik.http.routers.ts-https.entrypoints=websecure
        - traefik.http.routers.ts-https.middlewares=ts_strip@docker
        - traefik.http.routers.ts-https.service=ts-server
        - traefik.http.routers.ts-https.tls=true
        - traefik.http.routers.ts-https.tls.certresolver=zerossl
        - traefik.http.services.ts-server.loadbalancer.server.port=8000

  # --------------------------------------------------------------------------- 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: "test"
      PRIVATE_KEY_PASSPHRASE: "eh78T9JBxUwbJSRwAHWITWd6d0vuBspW"
      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"
      BASE_CONNECTION_URL: "https://api.${BASE_HOST}/edg_api/v1/services/connect/"
      BASE_DISCONNECTION_URL: "https://api.${BASE_HOST}/edg_api/v1/services/disconnect/"
      LOG_CHANNEL: stack
    networks:
      - inbound
    volumes:
      - ./assets/prod-oauth-certs:/var/www/storage/certificates
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '0.60'
          memory: 300M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.es-http.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/edg_api/`)
        - traefik.http.middlewares.es_strip.stripprefix.prefixes=/edg_api
        - traefik.http.middlewares.es_strip.stripprefix.forceSlash=false
        - traefik.http.routers.es-http.middlewares=es_strip@docker,traefik-https-redirect@docker
        - traefik.http.routers.es-http.entrypoints=web
        - traefik.http.routers.es-https.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/edg_api/`)
        - traefik.http.routers.es-https.entrypoints=websecure
        - traefik.http.routers.es-https.middlewares=es_strip@docker
        - traefik.http.routers.es-https.service=es-server
        - traefik.http.routers.es-https.tls=true
        - traefik.http.routers.es-https.tls.certresolver=zerossl
        - traefik.http.services.es-server.loadbalancer.server.port=8000

  # ------------------------------------------------------------------------ Notification Server ---
  notification-server:
    image: registry.geekcoders.cz/inspectlife/monorepo/notification-server:master
    environment:
      APP_NAME: "InspectLife Notification Server"
      APP_ENV: "test"
      PRIVATE_KEY_PASSPHRASE: "eh78T9JBxUwbJSRwAHWITWd6d0vuBspW"
      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"
      LOG_CHANNEL: stack
    networks:
      - inbound
    volumes:
      - ./assets/prod-oauth-certs:/var/www/storage/certificates
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '0.50'
          memory: 300M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.notification-http.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/notification_api`)
        - traefik.http.middlewares.ns_strip.stripprefix.prefixes=/notification_api
        - traefik.http.middlewares.ns_strip.stripprefix.forceSlash=false
        - traefik.http.routers.notification-http.middlewares=ns_strip@docker
        - traefik.http.routers.notification-http.entrypoints=web
        - traefik.http.routers.notification-https.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/notification_api`)
        - traefik.http.routers.notification-https.entrypoints=websecure
        - traefik.http.routers.notification-https.middlewares=ns_strip@docker
        - traefik.http.routers.notification-https.service=notification-server
        - traefik.http.routers.notification-https.tls=true
        - traefik.http.routers.notification-https.tls.certresolver=zerossl
        - traefik.http.services.notification-server.loadbalancer.server.port=8000

  # ----------------------------------------------------------------------------- Ordering Server ---
  order:
    image: registry.geekcoders.cz/inspectlife/monorepo/ordering-server:master
    environment:
      APP_NAME: "InspectLife Ordering Server"
      APP_ENV: "test"
      PRIVATE_KEY_PASSPHRASE: "eh78T9JBxUwbJSRwAHWITWd6d0vuBspW"
      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: "https://minio.${BASE_HOST}"
      AWS_ENDPOINT: "https://minio.${BASE_HOST}"
      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"
      QUEUE_CONNECTION: "rabbitmq"
      LOG_CHANNEL: stack
    networks:
      - inbound
    volumes:
      - ./assets/prod-oauth-certs:/var/www/storage/certificates
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '0.60'
          memory: 300M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.ordering-http.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/order_api`)
        - traefik.http.middlewares.os_strip.stripprefix.prefixes=/order_api
        - traefik.http.middlewares.os_strip.stripprefix.forceSlash=false
        - traefik.http.routers.ordering-http.middlewares=os_strip@docker,traefik-https-redirect@docker
        - traefik.http.routers.ordering-http.entrypoints=web
        - traefik.http.routers.ordering-https.rule=Host(`api.${BASE_HOST}`) && PathPrefix(`/order_api`)
        - traefik.http.routers.ordering-https.entrypoints=websecure
        - traefik.http.routers.ordering-https.middlewares=os_strip@docker
        - traefik.http.routers.ordering-https.service=ordering-server
        - traefik.http.routers.ordering-https.tls=true
        - traefik.http.routers.ordering-https.tls.certresolver=zerossl
        - traefik.http.services.ordering-server.loadbalancer.server.port=8000

  edgy-server:
    image: registry.geekcoders.cz/inspectlife/monorepo/edgy-workers:master
    environment:
      AMQP_DSN: "amqp://guest:guest@rabbitmq:5672"
      IL_AUTH_HOST: "https://api.inspectlife2.vyvijime.eu/auth_api"
      IL_FP_HOST: "https://api.inspectlife2.vyvijime.eu/file_proxy"
      IL_EDGY_CONFIG_HOST: "https://api.inspectlife2.vyvijime.eu/edg_api"
      IL_BASE_HOST: "https://api.inspectlife2.vyvijime.eu/base_api"
    command: [ "/bin/edgy", "server" ]
    depends_on:
      - rabbitmq
    networks:
      - inbound
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '0.50'
          memory: 300M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.edg-http.rule=Host(`edg.${BASE_HOST}`)
        - traefik.http.routers.edg-http.middlewares=traefik-https-redirect@docker
        - traefik.http.routers.edg-http.entrypoints=web
        - traefik.http.routers.edg-https.rule=Host(`edg.${BASE_HOST}`)
        - traefik.http.routers.edg-https.entrypoints=websecure
        - traefik.http.routers.edg-https.tls=true
        - traefik.http.routers.edg-https.tls.certresolver=zerossl
        - traefik.http.services.edg-server.loadbalancer.server.port=8000

  edgy-processor:
    image: registry.geekcoders.cz/inspectlife/monorepo/edgy-workers:master
    environment:
      AMQP_DSN: "amqp://guest:guest@rabbitmq:5672"
      IL_AUTH_HOST: "https://api.inspectlife2.vyvijime.eu/auth_api"
      IL_FP_HOST: "https://api.inspectlife2.vyvijime.eu/file_proxy"
      IL_EDGY_CONFIG_HOST: "https://api.inspectlife2.vyvijime.eu/edg_api"
      IL_BASE_HOST: "https://api.inspectlife2.vyvijime.eu/base_api"
    command: [ "/bin/edgy", "processor" ]
    depends_on:
      - rabbitmq
    networks:
      - inbound
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '0.20'
          memory: 300M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound

  edgy-cron:
    image: registry.geekcoders.cz/inspectlife/monorepo/edgy-workers:master
    environment:
      AMQP_DSN: "amqp://guest:guest@rabbitmq:5672"
      IL_AUTH_HOST: "https://api.inspectlife2.vyvijime.eu/auth_api"
      IL_FP_HOST: "https://api.inspectlife2.vyvijime.eu/file_proxy"
      IL_EDGY_CONFIG_HOST: "https://api.inspectlife2.vyvijime.eu/edg_api"
      IL_BASE_HOST: "https://api.inspectlife2.vyvijime.eu/base_api"
    command: [ "/bin/edgy", "scheduler" ]
    depends_on:
      - rabbitmq
    networks:
      - inbound
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '0.50'
          memory: 300M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound

  telerehab-processor:
    image: registry.geekcoders.cz/inspectlife/monorepo/telerehab-processor:master
    networks:
      - inbound
    environment:
      FILE_PROXY: "https://api.${BASE_HOST}/file_proxy/v1/private_api/files"
      TELEREHAB_API: "https://api.${BASE_HOST}/telerehab_api/v1/private_api/pending_exercises"
      TELEREHAB_REFERENCE: "https://api.${BASE_HOST}/telerehab_api/v1/private_api/pending_presets"
    deploy:
      mode: replicated
      replicas: 1
      resources:
        limits:
          cpus: '1.50'
          memory: 1500M
      update_config:
        parallelism: 1
        order: start-first
        failure_action: rollback
        delay: 5s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 30s
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound

  # ------------------------------------------------------------------------------------ Portal ---
  portal:
    image: registry.geekcoders.cz/inspectlife/monorepo/portal-ui:master
    environment:
      API_BASE_URL: 'https://api.${BASE_HOST}'
      BASE_URL: '/base_api'
      AUTH_URL: '/auth_api'
      CAL_URL: '/cal_api'
      FILE_URL: '/file_proxy'
      ORDER_URL: '/order_api'
      NOTIFICATION_URL: '/notification_api'
      CHAT_BASE_URL: 'https://rocketchat-dev.ilplatform.cz'
      CHAT_URL: '/api/v1'
      TELEREHABILITATION_URL: '/telerehab_api'
      EDG_URL: '/edg_api'
    networks:
      - inbound
    deploy:
      mode: replicated
      replicas: 2
      resources:
        limits:
          cpus: '0.3'
          memory: 100M
      update_config:
        parallelism: 2
        order: start-first
        failure_action: rollback
        delay: 10s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.portal-http.rule=Host(`${BASE_HOST}`)
        - traefik.http.routers.portal-http.entrypoints=web
        - traefik.http.routers.portal-http.middlewares=traefik-https-redirect@docker
        - traefik.http.routers.portal-https.rule=Host(`${BASE_HOST}`)
        - traefik.http.routers.portal-https.entrypoints=websecure
        # - traefik.http.routers.portal-https.middlewares=ratelimit@docker, security-headers@docker
        - traefik.http.routers.portal-https.service=portal
        - traefik.http.routers.portal-https.tls=true
        - traefik.http.routers.portal-https.tls.certresolver=zerossl
        - traefik.http.services.portal.loadbalancer.server.port=80

  #  # ------------------------------------------------------------------------------------ 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:
  #      - inbound
  #    deploy:
  #      mode: global
  #      restart_policy:
  #        condition: any
  #        delay: 5s
  #        max_attempts: 3
  #        window: 120s
  #      update_config:
  #        delay: 10s
  #        order: stop-first
  #        parallelism: 1
  #      rollback_config:
  #        parallelism: 0
  #        order: stop-first
  #
  #  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:
  #      - inbound
  #    deploy:
  #      mode: global
  #      restart_policy:
  #        condition: any
  #        delay: 5s
  #        max_attempts: 3
  #        window: 120s
  #      update_config:
  #        delay: 10s
  #        order: stop-first
  #        parallelism: 1
  #      rollback_config:
  #        parallelism: 0
  #        order: stop-first
  #      labels:
  #        - traefik.enable=true
  #        - traefik.tags=public
  #        - traefik.docker.network=inbound
  #        - traefik.http.routers.kibana-http.rule=Host(`kibana.${BASE_HOST}`)
  #        - traefik.http.routers.kibana-http.entrypoints=web
  #        - traefik.http.routers.kibana-http.middlewares=vpn@docker
  #        - traefik.http.routers.kibana-https.rule=Host(`kibana.${BASE_HOST}`)
  #        - traefik.http.routers.kibana-https.entrypoints=websecure
  #        - traefik.http.routers.kibana-https.middlewares=vpn@docker
  #        - traefik.http.routers.kibana-https.service=kibana
  #        - traefik.http.routers.kibana-https.tls=true
  #        - traefik.http.routers.kibana-https.tls.certresolver=zerossl
  #        - traefik.http.services.kibana.loadbalancer.server.port=5601

  redis:
    image: registry.geekcoders.cz/gc/x/mirror-redis:6.0-buster
    networks:
      - inbound
    deploy:
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      update_config:
        delay: 10s
        order: stop-first
        parallelism: 1
      rollback_config:
        parallelism: 0
        order: stop-first


  mongo:
    image: registry.geekcoders.cz/gc/x/mirror-mongo:5
    networks:
      - inbound
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: secret
    ports:
      - 27017:27017
    volumes:
      - mongo_data:/data/db
      - ./assets/dumps:/mongo-seed
    deploy:
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      update_config:
        delay: 10s
        order: stop-first
        parallelism: 1
      rollback_config:
        parallelism: 0
        order: stop-first
      placement:
        constraints:
          - node.role == manager

  mongo-express:
    image: registry.geekcoders.cz/gc/x/mirror-mongo-express:0.54
    networks:
      - inbound
    environment:
      ME_CONFIG_MONGODB_SERVER: mongo
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: secret
    ports:
      - 8081:8081
    deploy:
      mode: replicated
      replicas: 1
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      update_config:
        delay: 10s
        order: stop-first
        parallelism: 1
      rollback_config:
        parallelism: 0
        order: stop-first
      labels:
        - traefik.enable=true
        - traefik.tags=public
        - traefik.docker.network=inbound
        - traefik.http.routers.mongo-http.rule=Host(`mongo.${BASE_HOST}`)
        - traefik.http.routers.mongo-http.entrypoints=web
        - traefik.http.routers.mongo-http.middlewares=vpn@docker
        - traefik.http.routers.mongo-https.rule=Host(`mongo.${BASE_HOST}`)
        - traefik.http.routers.mongo-https.entrypoints=websecure
        - traefik.http.routers.mongo-https.middlewares=vpn@docker
        - traefik.http.routers.mongo-https.service=mongo
        - traefik.http.routers.mongo-https.tls=true
        - traefik.http.routers.mongo-https.tls.certresolver=zerossl
        - traefik.http.services.mongo.loadbalancer.server.port=8081

  minio:
    image: minio/minio:RELEASE.2021-06-07T21-40-51Z
    environment:
      MINIO_PROMETHEUS_AUTH_TYPE: "public"
      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"
    networks:
      - inbound
    volumes:
      - minio_data:/data
    command: server /data
    deploy:
      labels:
        - traefik.enable=true
        - traefik.docker.network=inbound
        - traefik.http.routers.minio-http.rule=Host(`minio.${BASE_HOST}`)
        # Set the entrypoint (http or https)
        - traefik.http.routers.minio-http.entrypoints=web
        - traefik.http.routers.minio-http.middlewares=traefik-https-redirect@docker
        - traefik.http.routers.minio-https.rule=Host(`minio.${BASE_HOST}`)
        - traefik.http.routers.minio-https.entrypoints=websecure
        # - traefik.http.routers.minio-https.middlewares=vpn@docker
        - traefik.http.routers.minio-https.tls=true
        # Enable Https redirection
        - traefik.http.routers.minio-https.service=minio
        - traefik.http.routers.minio-https.tls.certresolver=zerossl
        - traefik.http.services.minio.loadbalancer.server.port=9000
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      update_config:
        delay: 10s
        order: stop-first
        parallelism: 1
      rollback_config:
        parallelism: 0
        order: stop-first
      placement:
        constraints:
          - node.role == manager

  rabbitmq:
    image: registry.geekcoders.cz/inspectlife/monorepo/rabbitmq:latest
    hostname: 'rabbitmq'
    networks:
      - inbound
    volumes:
      - rabbitmq_data:/var/lib/rabbitmq
    ports:
      - 5672:5672
    deploy:
      labels:
        - traefik.enable=true
        - traefik.docker.network=inbound
        - traefik.http.routers.rabbitmq-http.rule=Host(`rabbitmq.${BASE_HOST}`)
        # Set the entrypoint (http or https)
        - traefik.http.routers.rabbitmq-http.entrypoints=web
        - traefik.http.routers.rabbitmq-http.middlewares=traefik-https-redirect@docker
        - traefik.http.routers.rabbitmq-https.rule=Host(`rabbitmq.${BASE_HOST}`)
        - traefik.http.routers.rabbitmq-https.entrypoints=websecure
        # - traefik.http.routers.minio-https.middlewares=vpn@docker
        - traefik.http.routers.rabbitmq-https.tls=true
        # Enable Https redirection
        - traefik.http.routers.rabbitmq-https.service=rabbitmq
        - traefik.http.routers.rabbitmq-https.tls.certresolver=zerossl
        - traefik.http.services.rabbitmq.loadbalancer.server.port=15672
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      update_config:
        delay: 10s
        order: stop-first
        parallelism: 1
      rollback_config:
        parallelism: 0
        order: stop-first

networks:
  inbound:
    driver: overlay
    external: true
    name: inbound

volumes:
  dbdata:
    driver: local
  minio_data:
    driver: local
  mongo_data:
    driver: local
  rabbitmq_data:
    driver: local


