version: '2.1'
services:
  graphdb:
    image: ontotext/graphdb:9.1.1-ee
    container_name: ${COMPOSE_PROJECT_NAME}-graphdb
    command: [-Dgraphdb.home=/opt/graphdb/home -Dgraphdb.license.file=/opt/graphdb/home/conf/graphdb-licenses/graphdb.license -Xmx4g -Dgraphdb.page.cache.size=0 -Dgraphdb.epool.onheap=false]
    volumes:
      - ${DATA_PATH}/graphdb/home:/opt/graphdb/home
      - $GRAPHDB_LICENSE_DIR:/opt/graphdb/home/conf/graphdb-licenses
    ports:
      - "7200:7200"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7200"]
      interval: 10s
      timeout: 10s
      retries: 100
    networks:
      - resource

  rabbitmq:
    image: rabbitmq:3.8.2-management
    container_name: ${COMPOSE_PROJECT_NAME}-rabbitmq
    environment:
      - RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
      - RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
    ports:
      - "5671:5671"
      - "5672:5672"
      - "25672:25672"
      - "15672:15672"
    healthcheck:
      test: ["CMD", "rabbitmqctl", "node_health_check"]
      interval: 5s
      timeout: 10s
      retries: 100
    networks:
      - resource

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
    container_name: ${COMPOSE_PROJECT_NAME}-elasticsearch
    volumes:
      - ${DATA_PATH}/elasticsearch/data:/usr/share/elasticsearch/data
      - ${DATA_PATH}/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ${DATA_PATH}/elasticsearch/config/jvm.options:/usr/share/elasticsearch/config/jvm.options
      - ${DATA_PATH}/elasticsearch/config/log4j2.properties:/usr/share/elasticsearch/config/log4j2.properties
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      - JAVA_OPTS=-Xms1024m -Xmx3084m
    ulimits:
      nofile:
        soft: 65536
        hard: 65536
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9200"]
      interval: 5s
      timeout: 10s
      retries: 100
    networks:
      - resource

  minio:
    image: minio/minio:RELEASE.2020-03-05T01-04-19Z
    container_name: ${COMPOSE_PROJECT_NAME}-minio
    command: "server /data"
    volumes:
      - ${DATA_PATH}/minio/data:/data
    environment:
      MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
      MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
    ports:
      - "9000:9000"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 5s
      timeout: 10s
      retries: 100
    networks:
      - resource

  tusd:
    image: tusproject/tusd:c7f6428884ffc5f1768697d3ad833fe63ddbbfd1
    container_name: ${COMPOSE_PROJECT_NAME}-tusd
    command: "-s3-endpoint=http://minio:9000 -s3-bucket=${MINIO_BUCKET}"
    volumes:
      - ${DATA_PATH}/minio/data:/data
    environment:
      AWS_ACCESS_KEY_ID: ${MINIO_ACCESS_KEY}
      AWS_SECRET_ACCESS_KEY: ${MINIO_SECRET_KEY}
      AWS_REGION: ${MINIO_REGION}
    ports:
      - "1080:1080"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:1080/metrics"]
      interval: 5s
      timeout: 10s
      retries: 100
    networks:
      - resource

  upload-companion:
    image: transloadit/companion:latest
    container_name: ${COMPOSE_PROJECT_NAME}-upload-companion
#    volumes:
#      - ${DATA_PATH}/thumbor:/data
    environment:
      COMPANION_SECRET: ${COMPANION_SECRET}
      COMPANION_DOMAIN: localhost:3020
      COMPANION_DATADIR: /tmp
      COMPANION_PROTOCOL: http
      COMPANION_GOOGLE_KEY: ${COMPANION_GOOGLE_KEY}
      COMPANION_GOOGLE_SECRET: ${COMPANION_GOOGLE_SECRET}
      COMPANION_SELF_ENDPOINT: "localhost:3020"
      COMPANION_DEBUG: 1
    ports:
      - "3020:3020"
    networks:
      - resource

  thumbor:
    image: apsl/thumbor:6.7.0
    container_name: ${COMPOSE_PROJECT_NAME}-thumbor
    volumes:
      - ${DATA_PATH}/thumbor:/data
    ports:
      - "8000:8000"
    environment:
      RESPECT_ORIENTATION: 'True'
      ALLOW_UNSAFE_URL: 'True'
    networks:
      - resource
networks:
  resource:
    driver: bridge
