Build with Docker - home-climate-control/esphome2influxdb GitHub Wiki

Pull

Run docker pull climategadgets/esphome2influxdb and then proceed to configuration section below - don't forget to adjust the image name to climategadgets/esphome2influxdb.

Just in case, the image is hosted at https://hub.docker.com/r/climategadgets/esphome2influxdb.

Build

With Jib

This option is much faster and is preferred. Simply run ./gradlew jibDockerBuild, this will build the image into the local Docker container (might need sudo if Docker is only configured to run as root). See Jib Gradle Plugin docs for details.

With Docker

Run sudo docker build -t esphome2influxdb . - this will take much longer, and create a bigger Docker image. This option may be retired in the future.

Configure and Run

By default, the esphome2influxdb Docker image will be created with configuration found in src/main/resources/esphome2influxdb.yaml (specifically, source host of mqtt-esphome and target host of influxdb-esphome).

To make it do something meaningful, either create DNS records for these hosts and pass them to Docker daemon when you create the container, and/or provide your own configuration and map Docker volumes (this is the preferred option since you will have to provide your tags at some point anyway, see Tagging for details).

Option 1 (default configuration, use this to make sure it works)

docker run \
    --name esphome2influxdb-defaultconf \
    --rm -it \
    -e TZ=${your-time-zone} \
    --dns ${your-dns-server-host} \
    --dns-search ${your-search-domain} \
    esphome2influxdb

With this configuration, the logs will be only stored in the container - execute docker exec -it esphome2influxdb-defaultconf /bin/bash to connect to it and see what's going on.

Option 2 (custom configuration, logs exposed - this is what you'll have to do in the long run)

docker run \
    --name esphome2influxdb \
    --restart=unless-stopped \
    -e TZ=${your-time-zone} \
    --dns ${your-dns-server-host} \
    --dns-search ${your-search-domain} \
    -v ${your-esphome2influxdb-config-directory}:/app/conf \
    -v ${your-esphome2influxdb-log-directory}:/app/logs \
    esphome2influxdb

Config directory must have a esphome2influxdb.yaml file containing the configuration (see Minimal Configuration for details).