version: '2'
services:
  build:
    image: agneta-build
    build:
      context: .
    volumes:
      - .:/home/app
    working_dir: /home/app
    command: agneta image build -m portal
  portal:
    image: '<%-config.image.app%>'
    build:
      context: .
    environment:
      - NODE_ENV=production
      - MODE=portal
      - HOST_NAME=portal.localhost
      - SERVER_NAME=<%-config.serverName%>
      - PORT_HTTP=<%-config.portHttp.portal%>
      - PORT=<%-config.port.portal%>
    expose:
      - '<%-config.portHttp.portal%>'
      - '<%-config.port.portal%>'
  live:
    image: '<%-config.image.app%>'
    build:
      context: .
    environment:
      - NODE_ENV=production
      - MODE=live
      - GIT_BRANCH=live-production
      - HOST_NAME=live.localhost
      - SERVER_NAME=<%-config.serverName%>
      - PORT_HTTP=<%-config.portHttp.live%>
      - PORT=<%-config.port.live%>
    expose:
      - '<%-config.portHttp.live%>'
      - '<%-config.port.live%>'
  portal_dev:
    extends: portal
    environment:
      - HOST_NAME=portal_dev.localhost
      - GIT_BRANCH=portal_dev
      - NODE_ENV=development
    volumes: <%-config.volumes%>
  portal_stg:
    extends: portal
    environment:
      - HOST_NAME=portal_stg.localhost
      - GIT_BRANCH=portal_dev
      - NODE_ENV=development
  live_dev:
    extends: live
    environment:
      - HOST_NAME=live_dev.localhost
      - GIT_BRANCH=live_dev
      - NODE_ENV=development
    volumes: <%-config.volumes%>
  mongoDB:
    image: mongo:3.4-jessie
    environment:
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/dev/null
    volumes:
      - ./storage/db:/data/db
    command: mongod --smallfiles --logpath=/dev/null --auth --port 27018
    expose:
      - "27018"
    ports:
      - "27018:27018"
  proxy:
    image: haproxy:1.7-alpine
    ports:
      - '80:8080'
      - '443:4343'
    expose:
      - "80"
      - "4343"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./.proxy/config.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
