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

add Docker support #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.7 as base

FROM base as builder

RUN mkdir /install
WORKDIR /install

COPY requirements.txt /requirements.txt

RUN pip install --install-option="--prefix=/install" -r /requirements.txt

FROM python:3.7-alpine

COPY --from=builder /install /usr/local
COPY sonos-doorbell.py /app/sonos-doorbell.py
COPY *.mp3 /app/

WORKDIR /app
ENV ROOM Kitchen
ENV PORT 8080
CMD python3 sonos-doorbell.py $ROOM --port $PORT
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@ service that can be paired with out IoT devices or smart doorbells to play an au

The sonos-doorbell project launches a simple HTTP server that both receives the incoming doorbell requests and hosts the MP3 files to be used by the doorbell ring.

### Launch
1. Install python3 or run from inside a Docker envrionment with python3 setup
1. Edit main.sh to specify the Zone name and port you want the server to be hosted on
### Launch local
1. Install python3
1. Edit `main.sh` to specify the Zone name and port you want the server to be hosted on
1. Run `main.sh`

### Launch in Docker

##### Build Image

`docker build . -t sonos-doorbell`

##### Run Image

Only works on Linux, due to requirment of docker host networking
`docker run -d -e PORT=8888 -e ROOM=Kitchen --name sonos-doorbell --network host --restart always sonos-doorbell`

### Test
http://{hostname:port}/doorbell_press?ringtone=dingdong1&volume=45
Expand Down
9 changes: 4 additions & 5 deletions main.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash

pip install --upgrade pip
pip install SoCo
pip install mutagen
pip install netifaces
python3 -m venv .venv
source .venv/bin/activate

cd doorbell
pip install --upgrade pip
pip install -r requirements.txt

python3 sonos-doorbell.py "Kitchen" --port 8888
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mutagen
netifaces
soco