From c8a5aa9a41d47b8ad1522cc841d2d13599efebf7 Mon Sep 17 00:00:00 2001 From: oznu Date: Sun, 12 Mar 2017 23:09:27 +1100 Subject: [PATCH] first commit --- .gitignore | 1 + Dockerfile | 18 ++++++++++++++++++ README.md | 35 +++++++++++++++++++++++++++++++++++ default.config.json | 20 ++++++++++++++++++++ default.package.json | 5 +++++ entrypoint.sh | 14 ++++++++++++++ 6 files changed, 93 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 default.config.json create mode 100644 default.package.json create mode 100755 entrypoint.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2dcd769b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +test-volume diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..2cbe1af2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM node:7.7.2-alpine + +RUN apk add --no-cache git python make g++ libffi-dev openssl-dev avahi-compat-libdns_sd avahi-dev openrc dbus + +RUN npm install --silent -g homebridge + +RUN mkdir /homebridge && mkdir -p /home/root/homebridge +WORKDIR /homebridge + +COPY default.package.json /home/root/homebridge +COPY default.config.json /home/root/homebridge +COPY entrypoint.sh /sbin/entrypoint.sh + +VOLUME /homebridge + +ENTRYPOINT ["/sbin/entrypoint.sh"] + +CMD ["homebridge", "-U", "/homebridge", "-P", "/homebridge/node_modules"] diff --git a/README.md b/README.md new file mode 100644 index 00000000..f2b1209f --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# Docker Homebridge + +This a lightweight alpine-based docker image allows you to run [Nfarina's](https://github.com/nfarina) [Homebridge](https://github.com/nfarina/homebridge) on your home network that emulates the iOS HomeKit API. + +## Compatibility + +Homebridge requires full access to your local network to function correctly which can be achieved using the ```--net=host``` flag. +Currently this will not work when using [Docker for Mac](https://docs.docker.com/docker-for-mac/) due to [this issue](https://github.com/docker/for-mac/issues/68). + +## Usage + +Quick Setup: + +```shell +docker run --net=host -v :/homebridge oznu/homebridge +``` + +## Config + +The Homebridge config file is located at **//config.json*** +This file will be created the first time you run the container with a sample [FakeBulb](https://www.npmjs.com/package/homebridge-fakebulb) accessory. + +## Plugins + +Plugins should be defined in the **//package.json** file in the standard NPM format. +This file will be created the first time you run the container with the [FakeBulb](https://www.npmjs.com/package/homebridge-fakebulb) module. + +Any plugins added to the **package.json** will be installed each time the container is restarted. +Plugins can be uninstalled by removing the entry from the **package.json** and restarting the container. + +## Troubleshooting + +### 1. Verify your config.json and package.json syntax + +Many issues appear because of invalid JSON. A good way to verify your config is to use the jsonlint.com validator. diff --git a/default.config.json b/default.config.json new file mode 100644 index 00000000..1f09f6b9 --- /dev/null +++ b/default.config.json @@ -0,0 +1,20 @@ +{ + "bridge": { + "name": "Homebridge", + "username": "CC:22:3D:E3:CE:30", + "port": 51826, + "pin": "031-45-154" + }, + + "description": "This is an example configuration file. You can use this as a template for creating your own configuration file containing devices you actually own.", + + "accessories": [ + { + "accessory": "FakeBulb", + "name": "Fake Light" + } + ], + + "platforms": [ + ] +} diff --git a/default.package.json b/default.package.json new file mode 100644 index 00000000..a78ad5a1 --- /dev/null +++ b/default.package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "homebridge-fakebulb": "^0.0.3" + } +} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..55da0e97 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +dbus-daemon --system +avahi-daemon -D + +[ -f /homebridge/package.json ] || cp /home/root/homebridge/default.package.json /homebridge/package.json +[ -f /homebridge/config.json ] || cp /home/root/homebridge/default.config.json /homebridge/config.json + +echo "Removing old plugins..." +npm prune +echo "Installing plugins..." +npm install --silent + +exec "$@"