version: "2"

volumes:
  database:
    driver: local
  website:

services:
  # Build the frontend with node into a Docker volume
  # This container does nothing useful beside providing an
  # assets container to the nginx service
  frontend:
    image: villas-web
    volumes:
      - website:/usr/src/app/build

  nginx:
    image: nginx:stable-alpine
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - website:/www
      - ./etc/nginx:/etc/nginx/conf.d/

  # The VILLASweb backend
  backend:
    image: villas-backend
    environment:
      - NODE_ENV=production
    restart: always

  # The MongoDB database for the VILLASweb backend
  database:
    image: mongo:latest
    user: mongodb
    volumes:
      - database:/data/db
    restart: always
    user: mongodb

  # AMQP broker for VILLAScontroller
#  broker:
#    image: rabbitmq:management
#    environment:
#      RABBITMQ_DEFAULT_USER: "villas"
#      RABBITMQ_DEFAULT_PASS: "s3c0sim4!"
#    ports:
#      - "8080:15672"
#      - "5672:5672"
#    networks:
#      villas:

  # VILLASnode, the gateway between UDP and WebSocket traffic
  node:
    image: villas/node
    privileged: true
    restart: always
    command: node /etc/villas/node/websocket-demo.conf
    volumes:
      - ./etc/node:/etc/villas/node/