version: "3"
services:
  mongodb:
    image: mongo
    container_name: mongodb
    environment:
      - PUID=1000
      - PGID=1000
    volumes:
      - db:/data/db
    ports:
      - 127.0.0.1:27017:27017
    restart: unless-stopped
  minio:
    image: 'minio/minio'
    command: server /data --address ":9000" --console-address ":9001"
    ports:
      - 9000:9000
    volumes:
      - files:/data
  elastic:
    image: 'elasticsearch:7.14.2'
    command: |
      /bin/sh -c "./bin/elasticsearch-plugin list | grep -q ingest-attachment || yes | ./bin/elasticsearch-plugin install --silent ingest-attachment;      
      /usr/local/bin/docker-entrypoint.sh eswrapper"
    volumes:
      - elastic:/usr/share/elasticsearch/data
    ports:
      - 127.0.0.1:9200:9200
    environment:
      - ELASTICSEARCH_PORT_NUMBER=9200
      - BITNAMI_DEBUG=true
      - discovery.type=single-node
      - ES_JAVA_OPTS=-Xms1024m -Xmx1024m
      - http.cors.enabled=true
      - http.cors.allow-origin=http://localhost:8082      
    healthcheck:
      interval: 20s
      retries: 10
      test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"'
  account:
    image: anticrm/account
    links:
      - mongodb
    ports:
      - 3000:3000
    environment:
      - MONGO_URL=mongodb://mongodb:27017
      - TRANSACTOR_URL=ws://localhost:3333
  front:
    image: anticrm/front
    links:
      - mongodb
      - minio
      - elastic
      - transactor
    ports:
      - 8081:8080
    environment:
      - ACCOUNTS_URL=http://localhost:3000
      - UPLOAD_URL=/files
      - TRANSACTOR_URL=ws://localhost:3333
      - ELASTIC_URL=http://elastic:9200
      - MINIO_ENDPOINT=minio
      - MINIO_ACCESS_KEY=minioadmin
      - MINIO_SECRET_KEY=minioadmin  
  transactor:
    image: anticrm/transactor
    links:
      - mongodb
      - elastic
    ports:
      - 127.0.0.1:3333:3333
    environment:
      - ELASTIC_URL=http://elastic:9200
      - MONGO_URL=mongodb://mongodb:27017
      - METRICS_CONSOLE=true
      # - APM_SERVER_URL=http://apm-server:8200
  # apm-server:
  #   image: docker.elastic.co/apm/apm-server:7.14.2
  #   depends_on:
  #     elastic:
  #       condition: service_healthy
  #     kibana:
  #       condition: service_healthy      
  #     elastic:
  #       condition: service_healthy
  #   cap_add: ["CHOWN", "DAC_OVERRIDE", "SETGID", "SETUID"]
  #   cap_drop: ["ALL"]
  #   ports:
  #   - 8200:8200
  #   command: >
  #      apm-server -e
  #        -E apm-server.rum.enabled=true
  #        -E setup.kibana.host=kibana:5601
  #        -E setup.template.settings.index.number_of_replicas=0
  #        -E apm-server.kibana.enabled=true
  #        -E apm-server.kibana.host=kibana:5601
  #        -E output.elasticsearch.hosts=["elastic:9200"]
  #   healthcheck:
  #     interval: 10s
  #     retries: 12
  #     test: curl --write-out 'HTTP %{http_code}' --fail --silent --output /dev/null http://localhost:8200/  
  # kibana:
  #   image: docker.elastic.co/kibana/kibana:7.14.2
  #   depends_on:
  #     elastic:
  #       condition: service_healthy
  #   environment:
  #     ELASTICSEARCH_URL: http://elastic:9200
  #     ELASTICSEARCH_HOSTS: http://elastic:9200
  #   ports:
  #   - 5601:5601
  #   healthcheck:
  #     interval: 10s
  #     retries: 20
  #     test: curl --write-out 'HTTP %{http_code}' --fail --silent --output /dev/null http://localhost:5601/api/status

volumes:
  db:
  files:
  elastic:
