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.
This commit is contained in:
Amit Gandhi 2016-12-24 03:53:12 +00:00
parent cd40c5bfcc
commit d31e875639
3 changed files with 23 additions and 2 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
config.json config.json
plugins.txt plugins.txt
tags tags
persist

View File

@ -15,6 +15,8 @@ RUN apt-get install -y --no-install-recommends \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get update && apt-get install iputils-ping
RUN npm install -g --unsafe-perm \ RUN npm install -g --unsafe-perm \
homebridge \ homebridge \
hap-nodejs \ hap-nodejs \

View File

@ -4,22 +4,39 @@ default: build
build: build:
docker build -t rpi-homebridge-dev . docker build -t rpi-homebridge-dev .
clean:
-docker kill homebridge
-docker rm homebridge
# Target to build and run and subsequently remove image # Target to build and run and subsequently remove image
run: build run: build
docker run --net=host --rm \ docker run --net=host --rm \
-p "localhost:51826:51826" -p "51826:51826" \
-v "$(shell pwd)/config.json:/root/.homebridge/config.json" \ -v "$(shell pwd)/config.json:/root/.homebridge/config.json" \
-v "$(shell pwd)/plugins.txt:/root/.homebridge/plugins.txt" \ -v "$(shell pwd)/plugins.txt:/root/.homebridge/plugins.txt" \
-v "$(shell pwd)/persist:/root/.homebridge/persist" \
rpi-homebridge-dev rpi-homebridge-dev
# Target to drop into an interractive shell # Target to drop into an interractive shell
shell: build shell: build
docker run --net=host --rm \ docker run --net=host --rm \
-p "localhost:51826:51826" -p "51826:51826" \
-v "$(shell pwd)/config.json:/root/.homebridge/config.json" \ -v "$(shell pwd)/config.json:/root/.homebridge/config.json" \
-v "$(shell pwd)/plugins.txt:/root/.homebridge/plugins.txt" \ -v "$(shell pwd)/plugins.txt:/root/.homebridge/plugins.txt" \
-v "$(shell pwd)/persist:/root/.homebridge/persist" \
-it rpi-homebridge-dev bash -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 # Tags dev image so it can be pushed
tag: build tag: build
docker tag rpi-homebridge-dev vividboarder/rpi-homebridge docker tag rpi-homebridge-dev vividboarder/rpi-homebridge