version: "3.4"
services:
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    restart: on-failure
    ports:
    - ${PHRASEANET_PHPMYADMIN_PORT}:80
    depends_on:
    - db

  gateway:
    volumes:
    - ../:/var/alchemy
    - .:/var/alchemy/Phraseanet
    - ./docker/nginx/root/entrypoint.sh:/entrypoint.sh

  builder:
    build:
      context: .
      target: builder
      args:
        - SSH_PRIVATE_KEY=${PHRASEANET_SSH_PRIVATE_KEY}
        - PHRASEANET_PLUGINS=${PHRASEANET_PLUGINS}
    stdin_open: true
    tty: true
    volumes:
      - ../:/var/alchemy
      - .:/var/alchemy/Phraseanet
      - ${PHRASEANET_CONFIG_DIR}:/var/alchemy/Phraseanet/config:rw
      - ${PHRASEANET_LOGS_DIR}:/var/alchemy/Phraseanet/logs:rw
      - ${PHRASEANET_DATA_DIR}:/var/alchemy/Phraseanet/datas:rw
      - ${PHRASEANET_THUMBNAILS_DIR}:/var/alchemy/Phraseanet/www/thumbnails:rw
      - ${PHRASEANET_CUSTOM_DIR}:/var/alchemy/Phraseanet/www/custom:rw
      - ${PHRASEANET_CACHE_DIR}:/var/alchemy/Phraseanet/cache:rw
      - ${SSH_AUTH_SOCK}:/ssh-auth-sock
      - ${HOME}/.ssh:/home/app/.ssh
      - dev_vol:/home/app
    environment:
      - PHRASEANET_PROJECT_NAME

  phraseanet:
    environment:
    - XDEBUG_ENABLED
    - XDEBUG_CONFIG=remote_host=${XDEBUG_REMOTE_HOST} idekey=${IDE_KEY} remote_enable=1 profiler_enable=${XDEBUG_PROFILER_ENABLED} profiler_output_dir=/var/alchemy/Phraseanet/cache/profiler
    - PHP_IDE_CONFIG
    volumes:
    - ../:/var/alchemy
    - .:/var/alchemy/Phraseanet

  worker:
    volumes:
    - ../:/var/alchemy
    - .:/var/alchemy/Phraseanet


  rabbitmq:
    ports:
    - ${RABBITMQ_MANAGEMENT_PORT}:15672

  db:
    volumes:
    - ${PHRASEANET_DB_DIR}:/var/lib/mysql:rw

  elasticsearch:
    ports:
    - 9200:9200
    volumes:
    - ${PHRASEANET_ELASTICSEARCH_DIR}:/usr/share/elasticsearch/data:rw

  kibana:
    image: kibana:4.6.6
    ports:
    - 5601:5601
    links:
    - elasticsearch
    depends_on:
    - elasticsearch

  logstash:
    image: logstash:7.6.2
    links:
    - elasticsearch
    volumes:
    - ${PHRASEANET_CONFIG_DIR}:/var/alchemy/Phraseanet/config:rw
    command: logstash -f /var/alchemy/Phraseanet/config/logstash.conf
    depends_on:
    - elasticsearch
    restart: on-failure

  filebeat:
    hostname: filebeat
    image: "docker.elastic.co/beats/filebeat:7.6.2"
    volumes:
    - ${PHRASEANET_CONFIG_DIR}/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
    - ${PHRASEANET_LOGS_DIR}:/var/alchemy/Phraseanet/logs:ro
    command: filebeat run -e --strict.perms=false
    restart: on-failure

networks:
  default:
    ipam:
      config:
        - subnet: $PHRASEANET_SUBNET_IPS
