From d31e8756399d23a8ef181c3b102ea224a7e525f0 Mon Sep 17 00:00:00 2001 From: Amit Gandhi Date: Sat, 24 Dec 2016 03:53:12 +0000 Subject: [PATCH] Adds ability to run container in detached mode. This change also mounts the "persist" folder so we dont lose the homebridge devices in the app on rebuilds. Ping is also installed in the container as a few homebridge plugins such as `homebridge-people` and `homebridge-lgtv2` depend on ping. --- .gitignore | 2 ++ Dockerfile | 2 ++ Makefile | 21 +++++++++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9aa1db1..b853bc3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ config.json plugins.txt tags +persist + diff --git a/Dockerfile b/Dockerfile index 0029eba..fe4283e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,8 @@ RUN apt-get install -y --no-install-recommends \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +RUN apt-get update && apt-get install iputils-ping + RUN npm install -g --unsafe-perm \ homebridge \ hap-nodejs \ diff --git a/Makefile b/Makefile index 4c97e73..964da22 100644 --- a/Makefile +++ b/Makefile @@ -4,22 +4,39 @@ default: build build: docker build -t rpi-homebridge-dev . +clean: + -docker kill homebridge + -docker rm homebridge + # Target to build and run and subsequently remove image run: build docker run --net=host --rm \ - -p "localhost:51826:51826" + -p "51826:51826" \ -v "$(shell pwd)/config.json:/root/.homebridge/config.json" \ -v "$(shell pwd)/plugins.txt:/root/.homebridge/plugins.txt" \ + -v "$(shell pwd)/persist:/root/.homebridge/persist" \ rpi-homebridge-dev # Target to drop into an interractive shell shell: build docker run --net=host --rm \ - -p "localhost:51826:51826" + -p "51826:51826" \ -v "$(shell pwd)/config.json:/root/.homebridge/config.json" \ -v "$(shell pwd)/plugins.txt:/root/.homebridge/plugins.txt" \ + -v "$(shell pwd)/persist:/root/.homebridge/persist" \ -it rpi-homebridge-dev bash +# Target to buld and run in detached mode (continuously) +go: build + make clean + docker run --net=host -d \ + -p "51826:51826" \ + -v "$(shell pwd)/config.json:/root/.homebridge/config.json" \ + -v "$(shell pwd)/plugins.txt:/root/.homebridge/plugins.txt" \ + -v "$(shell pwd)/persist:/root/.homebridge/persist" \ + --name homebridge \ + rpi-homebridge-dev + # Tags dev image so it can be pushed tag: build docker tag rpi-homebridge-dev vividboarder/rpi-homebridge