Skip to content

Commit

Permalink
perf: slim down Docker image
Browse files Browse the repository at this point in the history
Running the avahi-daemon within Docker can cause conflicts and problems,
plus it is a very heavyweight approach. Instead, we can just mount the
host DBUS and use the host Avahi interface properly.
  • Loading branch information
mKeRix committed Feb 20, 2020
1 parent 67593d4 commit 0fc6d84
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 40 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
*
!docker/
!/*.tgz
10 changes: 3 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ FROM node:12-alpine

WORKDIR /room-assistant

RUN apk add --no-cache supervisor bluez bluez-deprecated libusb avahi avahi-dev dmidecode \
&& mkdir -p /var/run/dbus \
RUN apk add --no-cache bluez bluez-deprecated libusb avahi-dev dmidecode \
&& setcap cap_net_raw+eip $(eval readlink -f `which node`) \
&& setcap cap_net_raw+eip $(eval readlink -f `which hcitool`) \
&& addgroup --gid 998 i2c \
&& addgroup node i2c \
&& ln -s /usr/local/lib/node_modules/room-assistant/bin/room-assistant.js /usr/local/bin/room-assistant
COPY docker/supervisord.conf docker/entrypoint.sh /etc/
COPY --from=build /usr/local/lib/node_modules/room-assistant /usr/local/lib/node_modules/room-assistant

ENTRYPOINT ["/bin/sh", "-c"]
CMD ["/etc/entrypoint.sh"]
ENTRYPOINT ["room-assistant"]
CMD ["--digResolver"]
10 changes: 3 additions & 7 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ FROM node:12-alpine

WORKDIR /room-assistant

RUN apk add --no-cache supervisor bluez bluez-deprecated libusb avahi avahi-dev dmidecode \
&& mkdir -p /var/run/dbus \
RUN apk add --no-cache bluez bluez-deprecated libusb avahi-dev bind-tools dmidecode \
&& setcap cap_net_raw+eip $(eval readlink -f `which node`) \
&& setcap cap_net_raw+eip $(eval readlink -f `which hcitool`) \
&& addgroup --gid 998 i2c \
&& addgroup node i2c \
&& ln -s /usr/local/lib/node_modules/room-assistant/bin/room-assistant.js /usr/local/bin/room-assistant
COPY docker/supervisord.conf docker/entrypoint.sh /etc/
COPY --from=build /usr/local/lib/node_modules/room-assistant /usr/local/lib/node_modules/room-assistant

ENTRYPOINT ["/bin/sh", "-c"]
CMD ["/etc/entrypoint.sh"]
ENTRYPOINT ["room-assistant"]
CMD ["--digResolver"]
6 changes: 0 additions & 6 deletions docker/entrypoint.sh

This file was deleted.

19 changes: 0 additions & 19 deletions docker/supervisord.conf

This file was deleted.

2 changes: 2 additions & 0 deletions docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:
room-assistant:
image: mkerix/room-assistant
network_mode: host
volumes:
- /var/run/dbus:/var/run/dbus
environment:
NODE_CONFIG: >
{
Expand Down

0 comments on commit 0fc6d84

Please sign in to comment.