This PR is a part of https://github.com/jamiebegin/metrics2mqtt/issues/2 and adds a docker folder that contains everything needed to build a Docker image of metrics2mqtt. It uses environment variables to define configuration parameters:
COMMAND_OPTIONS_STRING: a string of options to send to the metrics2mqtt command (e.g., --cpu=60)
For MVP, this is a single-architecture image – nothing fancy going on to determine AMD64 vs. ARM, etc. That can be a future PR.
This assumes the image has been pushed to Docker Hub at jamiebegin/metrics2mqtt and tagged with a version consistent with the PyPI package. Obviously, it can be built off of this repo instead.
We mount /proc inside the container so that metrics2mqtt looks at the host's metrics, not the container's.
This PR doesn't modify the README at all; in my experience, we shouldn't give users instructions that point them toward building the image themselves. Rather, after the image is published to Docker Hub, we should create a GitHub action that kicks off Docker Hub builds appropriately (on every push to master, every tagged version, etc.). Just a recommendation; open to whatever you want to do here.
The Dockerfile pins the current PyPI version number of metrics2mqtt when building. So, each time a new version is released, that version number should be updated there, as well.
This PR is a part of https://github.com/jamiebegin/metrics2mqtt/issues/2 and adds a
docker
folder that contains everything needed to build a Docker image ofmetrics2mqtt
. It uses environment variables to define configuration parameters:COMMAND_OPTIONS_STRING
: a string of options to send to themetrics2mqtt
command (e.g.,--cpu=60
)MQTT_BROKER
: the hostname/IP of the MQTT brokerMQTT_PASSWORD
: the MQTT passwordMQTT_USERNAME
: the MQTT usernameRaw usage:
docker-compose
usage:Notes:
jamiebegin/metrics2mqtt
and tagged with a version consistent with the PyPI package. Obviously, it can be built off of this repo instead./proc
inside the container so thatmetrics2mqtt
looks at the host's metrics, not the container's.master
, every tagged version, etc.). Just a recommendation; open to whatever you want to do here.Dockerfile
pins the current PyPI version number ofmetrics2mqtt
when building. So, each time a new version is released, that version number should be updated there, as well.