version: '3'
services:
  # https://www.home-assistant.io/docs/installation/docker/#docker-compose
  homeassistant:
    container_name: home-assistant
    image: homeassistant/raspberrypi4-homeassistant:stable
    volumes:
      - './homeassistant/config:/config'
    environment:
      - TZ=Europe/Amsterdam
    devices:
      - '/dev/ttyUSB0:/dev/ttyUSB0'
    restart: always
    network_mode: host

  # https://hub.docker.com/r/pihole/pihole
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      # has no effect in host mode, just keeping for reference
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      - TZ=Europe/Amsterdam
      - WEBPASSWORD=9LCRBFrB
    # Volumes store your data between container upgrades
    volumes:
      - './pihole/etc/pihole/:/etc/pihole/'
      - './pihole/etc/dnsmasq.d/:/etc/dnsmasq.d/'
      - './pihole/etc/lighttpd/external.conf:/etc/lighttpd/external.conf'
    # Recommended but not required (DHCP needs NET_ADMIN)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN
    restart: unless-stopped
    network_mode: host

  # https://hub.docker.com/_/eclipse-mosquitto/
  # https://blog.feabhas.com/2020/02/running-the-eclipse-mosquitto-mqtt-broker-in-a-docker-container/
  mosquitto:
    container_name: mosquitto
    image: eclipse-mosquitto
    ports:
      - "1883:1883"
    volumes:
      - './mosquitto/:/mosquitto/'
    restart: unless-stopped
    network_mode: host

  # https://esphome.io/guides/faq.html
  esphome:
    image: esphome/esphome
    container_name: esphome
    volumes:
      - ./esphome/config/:/config:rw
      # Use local time for logging timestamps
      - /etc/localtime:/etc/localtime:ro
    network_mode: host
#    devices:
#      - '/dev/ttyUSB1:/dev/ttyUSB1'
    restart: unless-stopped