Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add install script fo avahi daemon #4

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,41 @@ alerts using `alerts.clear`.

Alerts are sent only as part of telemetry, so in order to report device alert,
use `send_telemetry` with any payload.

## Running your own VUCM via Docker

A simple Dockerfile can be:
```
FROM python:3.10-alpine3.16

WORKDIR /app

COPY requirements.txt requirements.txt
RUN python -m venv .venv
RUN .venv/bin/pip install -r requirements.txt

COPY script.py script.py

CMD [".venv/bin/python", "script.py"]
```

### Note about Enapter Gateway

If you are using [Enapter Gateway](https://handbook.enapter.com/software/gateway_software/), you should use debian base Docker image and run [`avahi`](https://wiki.debian.org/Avahi) to resolve gateway host name:
```diff
-FROM python:3.10-alpine3.16
+FROM python:3.10-buster

WORKDIR /app
+
+RUN curl -sSfL https://raw.githubusercontent.com/Enapter/python-sdk/main/extenstions/avahi-debian/install.sh | sh -s
rnovatorov marked this conversation as resolved.
Show resolved Hide resolved
+ENTRYPOINT ["bash", "./entrypoint.sh"]

COPY requirements.txt requirements.txt
RUN python -m venv .venv
RUN .venv/bin/pip install -r requirements.txt

COPY script.py script.py

CMD [".venv/bin/python", "script.py"]
```
28 changes: 28 additions & 0 deletions extenstions/avahi-debian/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
set -e

apt-get update && apt-get install -y --no-install-recommends avahi-daemon libnss-mdns

# allow hostnames with more labels to be resolved. so that we can
# resolve node1.mycluster.local.
# (https://github.com/lathiat/nss-mdns#etcmdnsallow)
echo '*' > /etc/mdns.allow

# Configure NSSwitch to use the mdns4 plugin so mdns.allow is respected
sed -i "s/hosts:.*/hosts: files mdns4 dns/g" /etc/nsswitch.conf
printf "[server]\nenable-dbus=no\n" >> /etc/avahi/avahi-daemon.conf
chmod 755 /etc/avahi/avahi-daemon.conf
mkdir -p /var/run/avahi-daemon
chown avahi:avahi /var/run/avahi-daemon
chmod 755 /var/run/avahi-daemon

cat <<EOF > entrypoint.sh
#!/bin/bash

set -e

avahi-daemon --daemonize --no-drop-root

exec "\$@"
EOF
chmod 755 entrypoint.sh