version: '2.4'
services:

##  --------------------------
##  If you need rstudio
##  --------------------------

  # rstudio4:
  #   container_name: rstudio4
  #   # image: rocker/rstudio:4.0.3   # base RStudio 4.0.3
  #   image: roncar/kibior-rstudio:4.0.3
  #   environment:
  #   - PASSWORD=myrstudio
  #   - USERID=1000
  #   #
  #   volumes:
  #   - type: bind
  #     source: <path_for_data_folder_on_your_computer>
  #     target: /work/rstudio/data    # we create a folder inside the container
  #     read_only: false
  #   - type: bind
  #     source: ./resolv.conf
  #     target: /etc/resolv.conf
  #     read_only: false
  #   #
  #   ports:
  #   - 8787:8787
  #   networks:
  #   - kibiornet
  #   # cpu and ram constraints
  #   cpu_count: 1
  #   cpu_percent: 75
  #   cpus: 0.75
  #   memswap_limit: 0
  #   mem_reservation: 256m
  #   mem_limit: 6g

##  --------------------------
##  If you need a bash cli + R
##  See https://hub.docker.com/u/rocker for more versions 
##  with preinstalled material (e.g. tidyverse)
##  --------------------------

  # r4:
  #   container_name: r4
  #   # image: rocker/r-ver:4.0.3   # R version 4.0.3
  #   image: roncar/kibior-env:4.0.3
  #   stdin_open: true            # docker run -i
  #   tty: true                   # docker run -t
  #   entrypoint: "/bin/bash"
  #   #
  #   volumes:
  #   - type: bind
  #     source: <path_for_data_folder_on_your_computer>
  #     target: /work/r/data    # we create a folder inside the container
  #     read_only: false
  #   - type: bind
  #     source: ./resolv.conf
  #     target: /etc/resolv.conf
  #     read_only: false
  #   #
  #   networks:
  #   - kibiornet
  #   # cpu and ram constraints
  #   cpu_count: 1
  #   cpu_percent: 75
  #   cpus: 0.75
  #   memswap_limit: 0
  #   mem_reservation: 256m
  #   mem_limit: 6g

##  --------------------------
##  Elasticsearch container
##  --------------------------

  elasticsearch:
    # this configuration will run a service called "elasticsearch"
    container_name: elasticsearch
    # the elasticsearch image used will be version 7
    # but you can use another version, such as 6.8.6
    image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
    # defines env var
    # last line tells us java will use 512MB
    # if you need more, change it for 2GB, for instance
    # "ES_JAVA_OPTS=-Xms2g -Xmx2g"
    environment:
    - discovery.type=single-node
    - bootstrap.memory_lock=true
    - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    # strict limit to 1GB of RAM
    mem_limit: 1g
    memswap_limit: 0
    # lock memory
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    # bind files and folders of your system with those inside of the container 
    volumes:
    # ES data folder
    - type: bind
      source: <path_for_ES_data_folder_on_your_computer>
      target: /usr/share/elasticsearch/data
      read_only: false
    # ES configurations
    - type: bind
      source: ./elasticsearch.yml
      target: /usr/share/elasticsearch/config/elasticsearch.yml
      read_only: true
    # export port to access Elasticsearch service from outside docker
    ports: 
    - 9200:9200
    # networks managed by docker 
    networks:
    - kibiornet

# network declaration
networks:
  kibiornet: