diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..2f616b73c052ca52e925b336a13092c475da8339 --- /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 0000000000000000000000000000000000000000..f947daf51a1cb1592200cc59d5e11575ccd56013 --- /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 fee625c372782802715562adf9020fdd50da334f..47bb9749c3162c530b25f4553474fdadd4d73da5 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