version: '3'

services:

  mosquitto:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - MOSQUITTO_VERSION=${MOSQUITTO_VERSION:-latest}
    environment:
      - MOSQUITTO_USERNAME=${MOSQUITTO_USERNAME}
      - MOSQUITTO_PASSWORD=${MOSQUITTO_PASSWORD}
    image: eclipse-mosquitto:${MOSQUITTO_VERSION:-latest}
    container_name: eclipse-mosquitto
    restart: always
    ports:
      - 1883:1883
    volumes:
      - mqtt-data:/mosquitto/data
    logging:
      options:
        max-size: '12m'
        max-file: '5'
      driver: json-file

volumes:
  mqtt-data:
    driver: local
    driver_opts:
      type: none
      device: ${VOLUME_MQTT:-/root/mqtt/data}
      o: bind
