Fix avahi and clean build

This commit is contained in:
ViViDboarder 2016-11-15 01:01:34 +00:00
parent 9649305adf
commit aca2060e7b
4 changed files with 47 additions and 9 deletions

View File

@ -7,11 +7,13 @@ ENV LC_ALL en_US.UTF-8
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
build-essential \
avahi-daemon \
avahi-discover \
libnss-mdns \
libavahi-compat-libdnssd-dev
build-essential \
libavahi-compat-libdnssd-dev \
libnss-mdns && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN npm install -g --unsafe-perm \
homebridge \
@ -22,11 +24,16 @@ RUN npm install -g --unsafe-perm \
cd /usr/local/lib/node_modules/hap-nodejs/node_modules/mdns && \
node-gyp BUILDTYPE=Release rebuild
EXPOSE 5353 51826
RUN mkdir -p /var/run/dbus/
USER root
RUN mkdir -p /root/.homebridge
VOLUME /root/.homebridge
WORKDIR /root/.homebridge
EXPOSE 5353 51826
ADD start.sh /root/.homebridge/start.sh
CMD cat /root/.homebridge/plugins.txt | xargs npm install -g --unsafe-perm && homebridge
CMD /root/.homebridge/start.sh

View File

@ -1,14 +1,29 @@
build:
docker build -t rpi-homebridge .
default: build
# Default target to build the image
build:
docker build -t rpi-homebridge-dev .
# Target to build and run and subsequently remove image
run: build
docker run --net=host --rm \
-p "localhost:51826:51826"
-v "$(shell pwd)/config.json:/root/.homebridge/config.json" \
-v "$(shell pwd)/plugins.txt:/root/.homebridge/plugins.txt" \
rpi-homebridge
rpi-homebridge-dev
# Target to drop into an interractive shell
shell: build
docker run --net=host --rm \
-p "localhost:51826:51826"
-v "$(shell pwd)/config.json:/root/.homebridge/config.json" \
-v "$(shell pwd)/plugins.txt:/root/.homebridge/plugins.txt" \
-it rpi-homebridge bash
-it rpi-homebridge-dev bash
# Tags dev image so it can be pushed
tag: build
docker tag rpi-homebridge-dev vividboarder/rpi-homebridge
# Pushes tagged image to docker hub
push: tag
docker push vividboarder/rpi-homebridge

View File

@ -1,5 +1,7 @@
homebridge:
build: .
ports:
- "51826:51826"
net: host
volumes:
- ./config.json:/root/.homebridge/config.json

14
start.sh Executable file
View File

@ -0,0 +1,14 @@
#! /bin/sh
# Fix avahi
sed -i "s/rlimit-nproc=3/#rlimit-nproc=3/" /etc/avahi/avahi-daemon.conf
dbus-daemon --system
avahi-daemon -D
service dbus start
service avahi-daemon start
# Install desired plugins
cat /root/.homebridge/plugins.txt | xargs npm install -g --unsafe-perm
# Start service
homebridge