version: "3"
services:
  db:
    image: postgres
    environment:
      - DATABASE_URL
    ports:
      - "5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
    networks:
      - database_network
  elasticsearch:
    image: elasticsearch:6.8.1
    ports:
      - "9200:9200"
    volumes:
      - esdata:/usr/share/elasticsearch/data
    networks:
      - phoenix_network
      - es_network
  # Kibana is just for development, really
  kibana:
    image: kibana:6.8.1
    networks:
      - es_network
    ports:
      - "5601:5601"
  # This is for running the occasional graph layout task. It's in docker-compose.yml so that it's built at the same time
  # as everything else, but it should be run regularly with a cron job or similar.
  gephi:
    environment:
      - DATABASE_URL
    build: ./gephi
    volumes:
      - gradle-cache:/code/.gradle
    depends_on:
      - db
    networks:
      - database_network
  phoenix:
    build: ./backend
    networks:
      - database_network
      - phoenix_network
    depends_on:
      - db
    ports:
      - "${PORT}:${PORT}"
    environment:
      - DATABASE_URL
      - SECRET_KEY_BASE
      - PORT
      - BACKEND_HOSTNAME
volumes:
  pgdata:
  esdata:
  gradle-cache:
networks:
  database_network:
    driver: bridge
  phoenix_network:
    driver: bridge
  es_network:
    driver: bridge
