version: '3'

services:
  botpress:
    build:
      context: ./
      dockerfile: Dockerfile
    image: botpress/server
    container_name: botpress-server
    ports:
      - 3020:3000
    environment:
      - DATABASE_URL=postgres://postgres:secretpw@postgresBotpress:5435/botpress_db
      - BP_MODULE_NLU_DUCKLINGURL=http://botpress_lang:8000
      - BP_MODULE_NLU_LANGUAGESOURCES=[{"endpoint":"http://botpress_lang:3100"}]
      - EXTERNAL_URL=http://localhost:3000
    depends_on:
      - postgres
    volumes:
      -  botpress-data:/botpress/data

  botpress_lang:
    build:
      context: ./
      dockerfile: Dockerfile
    image: botpress/server
    container_name: botpress-lang
    command: bash -c "./duckling -p 8000 & ./bp lang --langDir /botpress/lang --port 3100"
    expose:
      - 3100
      - 8000
    volumes:
      - botpress-lang:/botpress/lang

  postgres:
    image: postgres:11.2-alpine
    container_name: postgresBotpress
    environment:
      PGPORT: 5435
      POSTGRES_DB: botpress_db
      POSTGRES_PASSWORD: secretpw
      POSTGRES_USER: postgres
    volumes:
      - botpress-db:/var/lib/postgresql/data

volumes:
 botpress-db:
    driver: local
    driver_opts:
      type: none
      device: ${VOLUME_DB_BOTPRESS}
      o: bind

 botpress-lang:
    driver: local
    driver_opts:
      type: none
      device: ${VOLUME_LANG_BOTPRESS}
      o: bind

 botpress-data:
    driver: local
    driver_opts:
      type: none
      device: ${VOLUME_DATA_BOTPRESS}
      o: bind