-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
77 lines (62 loc) · 2.63 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
FROM nodesource/jessie
MAINTAINER Jason Kennemer <[email protected]>
##################################################
# Set environment variables #
##################################################
ENV HOMEBRIDGE_USER="homebridge" \
HOMEBRIDGE_GROUP="homebridge" \
HOMEBRIDGE_HOME="/var/homebridge" \
HOMEBRIDGE_LOG_DIR="/var/log/homebridge"
ENV HOMEBRIDGE_INSTALL_DIR="${HOMEBRIDGE_HOME}/.homebridge"
ENV HOMEBRIDGE_CONFIG="${HOMEBRIDGE_INSTALL_DIR}/config.json" \
HOMEBRIDGE_PLUGINS="${HOMEBRIDGE_INSTALL_DIR}/plugins.txt" \
HOMEBRIDGE_PERSIST_DIR="${HOMEBRIDGE_INSTALL_DIR}/persist"
##################################################
# Install tools #
##################################################
RUN apt-get -y update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
avahi-daemon \
avahi-discover \
build-essential \
libavahi-compat-libdnssd-dev \
libnss-mdns \
net-tools \
nano \
apt-utils \
locales \
&& update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \
&& locale-gen en_US.UTF-8 \
&& DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
##################################################
# Install homebridge #
##################################################
RUN npm install -g --unsafe-perm \
homebridge \
hap-nodejs \
node-gyp && \
cd /usr/lib/node_modules/homebridge/ && \
npm install --unsafe-perm bignum && \
cd /usr/lib/node_modules/hap-nodejs/node_modules/mdns && \
node-gyp BUILDTYPE=Release rebuild
##################################################
# Add Homebridge User #
##################################################
USER root
RUN mkdir -p /var/run/dbus
RUN mkdir -p ${HOMEBRIDGE_HOME} && chmod 777 -R ${HOMEBRIDGE_HOME}
RUN groupadd -r ${HOMEBRIDGE_USER} -g 433 \
&& useradd -u 431 -r -g ${HOMEBRIDGE_USER} -d ${HOMEBRIDGE_HOME} -s /sbin/nologin -c "Docker image user" ${HOMEBRIDGE_USER} \
&& chown -R ${HOMEBRIDGE_USER}:${HOMEBRIDGE_GROUP} ${HOMEBRIDGE_HOME}
##################################################
# Start #
##################################################
EXPOSE 5353 51826
COPY ./start.sh ${HOMEBRIDGE_HOME}/start.sh
RUN chmod 755 ${HOMEBRIDGE_HOME}/start.sh
USER ${HOMEBRIDGE_USER}
RUN mkdir -p ${HOMEBRIDGE_INSTALL_DIR}
VOLUME ["${HOMEBRIDGE_CONFIG}", "${HOMEBRIDGE_PLUGINS}", "${HOMEBRIDGE_PERSIST_DIR}"]
WORKDIR ${HOMEBRIDGE_HOME}
ENTRYPOINT ["/var/homebridge/start.sh"]