From 7c299786f0080ba6d7341f43722a080d05f2fc31 Mon Sep 17 00:00:00 2001 From: Homer S Date: Sun, 11 Jul 2021 16:23:13 +0200 Subject: [PATCH 1/6] Reduced image size furtherly. Now 329MB and based on python:alpine. --- docker/Dockerfile | 16 ++++++++++++---- docker/docker-compose.yml | 2 +- requirements.txt | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1091952..c1956ba 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM alpine:latest +FROM python:alpine ENV TZ=Europe/Berlin ENV UNBUFFERED=1 @@ -11,9 +11,17 @@ VOLUME /app COPY . . RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone; \ - /bin/sh -c 'apk update && apk add --no-cache gcc musl-dev python3-dev py3-pip libffi-dev openssl-dev cargo zlib-dev jpeg-dev speex ffmpeg htop; \ - pip install update pip && pip install -r requirements.txt ; \ - apk del zlib-dev jpeg-dev gcc musl-dev python3-dev libffi-dev openssl-dev cargo;' + apk --no-cache update && apk add --no-cache --virtual .build-deps \ + gcc \ + cargo \ + libffi-dev \ + openssl-dev \ + zlib-dev \ + jpeg-dev ; \ + apk add --no-cache ffmpeg speex; \ + pip install --no-cache-dir upgrade pip; \ + pip install --no-cache-dir -r requirements.txt ; \ + apk del --no-cache .build-deps; diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 49e9071..74ed631 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -7,7 +7,7 @@ services: context: ../. dockerfile: ./docker/Dockerfile working_dir: /app - entrypoint: /bin/sh -c "export UNBUFFERED=1 && python3 -u ./fritzab2matrix.py" +# entrypoint: /bin/sh -c "export UNBUFFERED=1 && python3 -u ./fritzab2matrix.py" volumes: - ../.:/app diff --git a/requirements.txt b/requirements.txt index 8cdb0c7..63f532e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +requests fritzconnection python-dotenv xmltodict From b7fdd6e0e69582f5c811039547c81f65769a7e6d Mon Sep 17 00:00:00 2001 From: Homer S Date: Wed, 14 Jul 2021 19:27:39 +0200 Subject: [PATCH 2/6] Added some condtions to prevent script from breaking if list of missed calls is empty. --- fritzab2matrix.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fritzab2matrix.py b/fritzab2matrix.py index 1a62c2e..d1c5dfa 100755 --- a/fritzab2matrix.py +++ b/fritzab2matrix.py @@ -70,13 +70,20 @@ def get_last_call(): except: print("Couldn't connect to Box") missed_calls = fc.get_missed_calls(False,1,1) - return missed_calls[0] + + if len(missed_calls) > 0: + return missed_calls[0] + else: + return False def lastcall2matrix(tam,tam_no): # Call Watch to Matrix if env_call_watch and not at_least_one_new_message: c = get_last_call() - c_msg = "{} - {} ({})".format(c.Date, c.Caller, c.Name) + if c: + c_msg = "{} - {} ({})".format(c.Date, c.Caller, c.Name) + else: + return False # ... and send message and file to Matrix Room ## if Number of a TAM and the last call match From 1949f9f84a26de68d8310cad65a1a9ac08a94303 Mon Sep 17 00:00:00 2001 From: Homer S Date: Wed, 14 Jul 2021 19:29:28 +0200 Subject: [PATCH 3/6] Corrected the python-magic item (typo). Also if one doesn't upgrade the requirements matrix-nio won't work. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6bafca2..25b1498 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,6 +18,6 @@ markdown matrix-nio # [e2e]>=0.18.3 peewee Pillow -python_magic +python-magic uuid From d91095dcf83a23da4d8d267a9f0f5e55b4e74bbd Mon Sep 17 00:00:00 2001 From: Homer S Date: Wed, 14 Jul 2021 20:30:06 +0200 Subject: [PATCH 4/6] olm-dev was missing in the Dockerfile to build cryptography of matrix-commander. --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index c1956ba..f7d100f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -16,6 +16,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone; cargo \ libffi-dev \ openssl-dev \ + olm-dev \ zlib-dev \ jpeg-dev ; \ apk add --no-cache ffmpeg speex; \ From 60adf393ef95a28f4601f4077cb87cb2f0b82044 Mon Sep 17 00:00:00 2001 From: Homer S Date: Wed, 14 Jul 2021 21:08:24 +0200 Subject: [PATCH 5/6] Further corrections on docker build related files. --- docker/Dockerfile | 4 ++-- docker/docker-compose.yml | 2 +- requirements.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f7d100f..da7b7ac 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -19,8 +19,8 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone; olm-dev \ zlib-dev \ jpeg-dev ; \ - apk add --no-cache ffmpeg speex; \ - pip install --no-cache-dir upgrade pip; \ + apk add --no-cache olm libmagic ffmpeg speex; \ + pip --no-cache-dir install upgrade pip; \ pip install --no-cache-dir -r requirements.txt ; \ apk del --no-cache .build-deps; diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 74ed631..49e9071 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -7,7 +7,7 @@ services: context: ../. dockerfile: ./docker/Dockerfile working_dir: /app -# entrypoint: /bin/sh -c "export UNBUFFERED=1 && python3 -u ./fritzab2matrix.py" + entrypoint: /bin/sh -c "export UNBUFFERED=1 && python3 -u ./fritzab2matrix.py" volumes: - ../.:/app diff --git a/requirements.txt b/requirements.txt index 25b1498..808ef62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ atomicwrites cachetools datetime markdown -matrix-nio # [e2e]>=0.18.3 +matrix-nio[e2e]>=0.18.3 peewee Pillow python-magic From 97eb34814f169b7e3cffb41c9dd4de8d08cf9100 Mon Sep 17 00:00:00 2001 From: Homer S Date: Wed, 14 Jul 2021 21:44:11 +0200 Subject: [PATCH 6/6] Some more fixes on docker build related files. --- docker/Dockerfile | 5 +++-- docker/docker-compose.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index da7b7ac..d7f85f8 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -20,10 +20,11 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone; zlib-dev \ jpeg-dev ; \ apk add --no-cache olm libmagic ffmpeg speex; \ - pip --no-cache-dir install upgrade pip; \ + pip install pip -U --no-cache-dir; \ pip install --no-cache-dir -r requirements.txt ; \ apk del --no-cache .build-deps; -ENTRYPOINT ["python3", "-u", "fritzab2matrix.py "] +# ENTRYPOINT ["python3", "-u", "fritzab2matrix.py"] +ENTRYPOINT /bin/sh -c "export UNBUFFERED=1 && python3 -u ./fritzab2matrix.py" diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 49e9071..74ed631 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -7,7 +7,7 @@ services: context: ../. dockerfile: ./docker/Dockerfile working_dir: /app - entrypoint: /bin/sh -c "export UNBUFFERED=1 && python3 -u ./fritzab2matrix.py" +# entrypoint: /bin/sh -c "export UNBUFFERED=1 && python3 -u ./fritzab2matrix.py" volumes: - ../.:/app