From 194bc23326a991775835483182ae0064e2846429 Mon Sep 17 00:00:00 2001 From: Ellis Percival <flyte@failcode.co.uk> Date: Sun, 26 May 2019 13:36:01 +0100 Subject: [PATCH] Add Dockerfile and update readme. #55 --- .dockerignore | 6 ++++++ Dockerfile | 17 +++++++++++++++++ README.md | 29 +++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2f616b7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.tox +.eggs +.ignore +.pytest_cache +.vscode +dist \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f947daf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +from python:3.6-stretch + +ENV LANG C.UTF-8 +ENV LC_ALL C.UTF-8 + +RUN pip install --no-cache-dir pipenv + +RUN useradd -m -s /bin/bash mqttgpio +USER mqttgpio +WORKDIR /home/mqttgpio + +COPY Pipfile* ./ +RUN pipenv install --three --deploy + +COPY pi_mqtt_gpio pi_mqtt_gpio + +CMD [ "pipenv", "run", "python", "-m", "pi_mqtt_gpio.server", "/config.yml" ] diff --git a/README.md b/README.md index fee625c..47bb974 100644 --- a/README.md +++ b/README.md @@ -254,3 +254,32 @@ sudo supervisorctl status ``` Check the [supervisor docs](http://supervisord.org/running.html#supervisorctl-command-line-options) for more `supervisorctl` commands. + +Docker +------ + +You may also run this software using Docker. You must create your config file as above, then run the docker image: + +``` +docker run -ti --rm -v /path/to/your/config.yml:/config.yml flyte/mqtt-gpio +``` + +Or to run in the background: + +``` +docker run -d --name mqtt-gpio -v /path/to/your/config.yml:/config.yml flyte/mqtt-gpio +``` + +You'll most likely want to use some hardware devices in your config, since that's what this project is all about. For example, if you wish to use the i2c bus, pass it through with a `--device` parameter: + +``` +docker run -ti --rm -v /path/to/your/config.yml:/config.yml --device /dev/i2c-0 flyte/mqtt-gpio +``` + +If you aren't able to find the exact device path to use, then you can also run the docker container in `--privileged` mode which will pass all of the devices through from the host: + +``` +docker run -ti --rm -v /path/to/your/config.yml:/config.yml --privileged flyte/mqtt-gpio +``` + +_Please raise an issue on Github if any of this information is incorrect._ \ No newline at end of file -- GitLab