3 Commits 7ff05ba3f2 ... d189cedd3d

Author SHA1 Message Date
  Fabian Peter Hammerle d189cedd3d release v0.5.0 3 years ago
  Fabian Peter Hammerle 5f7ed542c9 docker: add env vars $MQTT_HOST/PORT/USERNAME/PASSWORD 3 years ago
  Gautam Korlam a807e3d07e Add docker compose support 3 years ago
3 changed files with 35 additions and 3 deletions
  1. 7 1
      CHANGELOG.md
  2. 6 1
      Dockerfile
  3. 22 1
      README.md

+ 7 - 1
CHANGELOG.md

@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+## [0.5.0] - 2020-11-22
+### Added
+- Docker image: support parametrization via environment variables
+  (`MQTT_HOST`, `MQTT_PORT`, `MQTT_USERNAME` & `MQTT_PASSWORD`)
+
 ## [0.4.1] - 2020-06-18
 ### Fixed
 - Compatibility with python3.5:
@@ -38,7 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Subscribe to `homeassistant/switch/switchbot/+/set`.
   Handle `ON` and `OFF` messages.
 
-[Unreleased]: https://github.com/fphammerle/switchbot-mqtt/compare/v0.4.1...HEAD
+[Unreleased]: https://github.com/fphammerle/switchbot-mqtt/compare/v0.5.0...HEAD
+[0.5.0]: https://github.com/fphammerle/switchbot-mqtt/compare/v0.4.1...v0.5.0
 [0.4.1]: https://github.com/fphammerle/switchbot-mqtt/compare/v0.4.0...v0.4.1
 [0.4.0]: https://github.com/fphammerle/switchbot-mqtt/compare/v0.3.0...v0.4.0
 [0.3.0]: https://github.com/fphammerle/switchbot-mqtt/compare/v0.2.0...v0.3.0

+ 6 - 1
Dockerfile

@@ -52,5 +52,10 @@ ARG SOURCE_DIR_PATH
 COPY --from=build $SOURCE_DIR_PATH $SOURCE_DIR_PATH
 ARG VIRTUALENV_PATH
 ENV PATH=$VIRTUALENV_PATH/bin:$PATH
+
+ENV MQTT_HOST ""
+ENV MQTT_PORT "1883"
+ENV MQTT_USERNAME ""
+ENV MQTT_PASSWORD ""
 ENTRYPOINT ["tini", "--"]
-CMD ["switchbot-mqtt", "--help"]
+CMD ["sh", "-c", "switchbot-mqtt --mqtt-host \"$MQTT_HOST\" --mqtt-port \"$MQTT_PORT\" --mqtt-username \"$MQTT_USERNAME\" --mqtt-password \"$MQTT_PASSWORD\""]

+ 22 - 1
README.md

@@ -71,7 +71,7 @@ switch:
 
 ## Docker 🐳
 
-Pre-built docker image are available at https://hub.docker.com/r/fphammerle/switchbot-mqtt/tags
+Pre-built docker images are available at https://hub.docker.com/r/fphammerle/switchbot-mqtt/tags
 
 Annotation of signed tags `docker/*` contains docker image digests: https://github.com/fphammerle/switchbot-mqtt/tags
 
@@ -83,6 +83,24 @@ $ docker run --name spelunca_switchbot \
     switchbot-mqtt --mqtt-host HOSTNAME_OR_IP_ADDRESS
 ```
 
+Alternatively, you can use `docker-compose`:
+```yaml
+version: '3.8'
+
+services:
+  switchbot-mqtt:
+    image: switchbot-mqtt
+    container_name: switchbot-mqtt
+    network_mode: host
+    userns_mode: host
+    environment:
+    - MQTT_HOST=localhost
+    - MQTT_PORT=1883
+    #- MQTT_USERNAME=username
+    #- MQTT_PASSWORD=password
+    restart: unless-stopped
+```
+
 ## MQTT Authentication
 
 ```sh
@@ -91,6 +109,9 @@ switchbot-mqtt --mqtt-username me --mqtt-password secret …
 switchbot-mqtt --mqtt-username me --mqtt-password-file /var/lib/secrets/mqtt/password …
 ```
 
+⚠️  `--mqtt-password` leaks the password to other users on the same machine,
+if `/proc` is mounted with `hidepid=0` (default).
+
 ## Alternatives
 
 * https://github.com/binsentsu/switchbot-ctrl