Browse Source

Fix avahi and clean build

node-8-crossarch
ViViDboarder 5 years ago
parent
commit
aca2060e7b
  1. 17
      Dockerfile
  2. 21
      Makefile
  3. 2
      docker-compose.yaml
  4. 14
      start.sh

17
Dockerfile

@ -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

21
Makefile

@ -1,14 +1,29 @@
default: build
# Default target to build the image
build:
docker build -t rpi-homebridge .
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

2
docker-compose.yaml

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

14
start.sh

@ -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
Loading…
Cancel
Save