version: '3.0' 

services:
  backend: 
    build: 
      context: ../ 
      dockerfile: docker/Dockerfile-full-ganache-application
    volumes: 
      - ../api:/usr/src/app/api
    depends_on:
      - postgresdb
      - redis
    env_file:
      - ../.env
    ports:
      - "4000:4000" 
    environment:
      - NODE_ENV=development
      - BLOCKCHAIN_ENV=localhost
      - POSTGRES_HOST=postgresdb
      - REDIS_HOST=redis
      - GANACHE=ganache
      - GANACHE_PORT=8545
  
  meridio-blockchain-service: 
    build: 
      context: ../../meridio-blockchain-service
    ports:
      - "4040:4040" 
    environment:
      - NODE_ENV=development 
      - BLOCKCHAIN_ENV=localhost
      - REDIS_HOST=redis
      - NODE_ADDRESS=http://ganache:8545
      - MERIDIO_API=http://backend:4000
    env_file:
      - ../../meridio-blockchain-service/.env
    depends_on:
      - backend
      - redis
      - ganache

  frontend: 
    build: 
      context: ../../meridio-frontend
    ports:
      - "3000:3000" 
    env_file:
      - ../../meridio-frontend/.env
    environment:
      - REACT_APP_CUSTOM_API=http://localhost:4000 
    volumes: 
      - ../../meridio-frontend/src:/usr/src/app/src

  postgresdb: 
    image: postgres:10.4 
    ports:
      - "5432:5432"
    env_file:
      - ../.env
  
  redis:
    image: redis:4.0 
    ports:
      - "6379:6379"
    env_file:
      - ../.env

  ganache:
    image: trufflesuite/ganache-cli:v6.2.5
    ports:
      - 8545:8545
    command: ["-h=0.0.0.0", "-i 1337",  "-m law thank rubber impulse guard proud usual clown scare trial proud slide" ]  #committing dummy mnemonic for reusable metamask accounts
