From 9684ebf33f5220b804e76aa85186622ce2a266a8 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Thu, 24 Jan 2019 14:28:21 +0200 Subject: [PATCH] Use mailustart package from git --- core/dovecot/Dockerfile | 5 +++-- core/dovecot/start.py | 22 +--------------------- core/postfix/Dockerfile | 5 +++-- core/postfix/start.py | 22 +--------------------- services/rspamd/Dockerfile | 5 +++-- services/rspamd/start.py | 23 +---------------------- 6 files changed, 12 insertions(+), 70 deletions(-) diff --git a/core/dovecot/Dockerfile b/core/dovecot/Dockerfile index 83d23b52..b37fe4d7 100644 --- a/core/dovecot/Dockerfile +++ b/core/dovecot/Dockerfile @@ -1,10 +1,11 @@ FROM alpine:3.8 # python3 shared with most images RUN apk add --no-cache \ - python3 py3-pip \ + python3 py3-pip git \ && pip3 install --upgrade pip # Shared layer between rspamd, postfix, dovecot, unbound and nginx -RUN pip3 install jinja2 +RUN pip3 install jinja2 \ + && pip3 install git+https://github.com/usrpro/MailuStart.git#egg=mailustart # Shared layer between rspamd, postfix, dovecot RUN pip3 install tenacity # Image specific layers under this line diff --git a/core/dovecot/start.py b/core/dovecot/start.py index bae92260..53999bd6 100755 --- a/core/dovecot/start.py +++ b/core/dovecot/start.py @@ -1,15 +1,12 @@ #!/usr/bin/python3 -import jinja2 import os -import socket import glob import multiprocessing -import tenacity import logging as log import sys +from mailustart import resolve, convert -from tenacity import retry from podop import run_server log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) @@ -23,23 +20,6 @@ def start_podop(): ("sieve", "url", url), ]) -def convert(src, dst): - logger = log.getLogger("convert()") - logger.debug("Source: %s, Destination: %s", src, dst) - open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ)) - -@retry( - stop=tenacity.stop_after_attempt(100), - wait=tenacity.wait_random(min=2, max=5), - before=tenacity.before_log(log.getLogger("tenacity.retry"), log.DEBUG), - before_sleep=tenacity.before_sleep_log(log.getLogger("tenacity.retry"), log.INFO), - after=tenacity.after_log(log.getLogger("tenacity.retry"), log.DEBUG) - ) -def resolve(hostname): - logger = log.getLogger("resolve()") - logger.info(hostname) - return socket.gethostbyname(hostname) - # Actual startup script os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front")) os.environ["REDIS_ADDRESS"] = resolve(os.environ.get("REDIS_ADDRESS", "redis")) diff --git a/core/postfix/Dockerfile b/core/postfix/Dockerfile index ac9c8159..5a9bef40 100644 --- a/core/postfix/Dockerfile +++ b/core/postfix/Dockerfile @@ -1,10 +1,11 @@ FROM alpine:3.8 # python3 shared with most images RUN apk add --no-cache \ - python3 py3-pip \ + python3 py3-pip git \ && pip3 install --upgrade pip # Shared layer between rspamd, postfix, dovecot, unbound and nginx -RUN pip3 install jinja2 +RUN pip3 install jinja2 \ + && pip3 install git+https://github.com/usrpro/MailuStart.git#egg=mailustart # Shared layer between rspamd, postfix, dovecot RUN pip3 install tenacity # Image specific layers under this line diff --git a/core/postfix/start.py b/core/postfix/start.py index e3b3eb40..f113dddb 100755 --- a/core/postfix/start.py +++ b/core/postfix/start.py @@ -1,16 +1,13 @@ #!/usr/bin/python3 -import jinja2 import os -import socket import glob import shutil -import tenacity import multiprocessing import logging as log import sys +from mailustart import resolve, convert -from tenacity import retry from podop import run_server log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) @@ -28,23 +25,6 @@ def start_podop(): ("senderlogin", "url", url + "sender/login/ยง") ]) -def convert(src, dst): - logger = log.getLogger("convert()") - logger.debug("Source: %s, Destination: %s", src, dst) - open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ)) - -@retry( - stop=tenacity.stop_after_attempt(100), - wait=tenacity.wait_random(min=2, max=5), - before=tenacity.before_log(log.getLogger("tenacity.retry"), log.DEBUG), - before_sleep=tenacity.before_sleep_log(log.getLogger("tenacity.retry"), log.INFO), - after=tenacity.after_log(log.getLogger("tenacity.retry"), log.DEBUG) - ) -def resolve(hostname): - logger = log.getLogger("resolve()") - logger.info(hostname) - return socket.gethostbyname(hostname) - # Actual startup script os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front")) os.environ["ADMIN_ADDRESS"] = resolve(os.environ.get("ADMIN_ADDRESS", "admin")) diff --git a/services/rspamd/Dockerfile b/services/rspamd/Dockerfile index 6d0cb5d0..57196a4d 100644 --- a/services/rspamd/Dockerfile +++ b/services/rspamd/Dockerfile @@ -1,10 +1,11 @@ FROM alpine:3.8 # python3 shared with most images RUN apk add --no-cache \ - python3 py3-pip \ + python3 py3-pip git \ && pip3 install --upgrade pip # Shared layer between rspamd, postfix, dovecot, unbound and nginx -RUN pip3 install jinja2 +RUN pip3 install jinja2 \ + && pip3 install git+https://github.com/usrpro/MailuStart.git#egg=mailustart # Shared layer between rspamd, postfix, dovecot RUN pip3 install tenacity # Image specific layers under this line diff --git a/services/rspamd/start.py b/services/rspamd/start.py index 744d4a9c..3febed2b 100755 --- a/services/rspamd/start.py +++ b/services/rspamd/start.py @@ -1,34 +1,13 @@ #!/usr/bin/python3 -import jinja2 import os -import socket import glob -import tenacity import logging as log import sys - -from tenacity import retry +from mailustart import resolve, convert log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) -def convert(src, dst): - logger = log.getLogger("convert()") - logger.debug("Source: %s, Destination: %s", src, dst) - open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ)) - -@retry( - stop=tenacity.stop_after_attempt(100), - wait=tenacity.wait_random(min=2, max=5), - before=tenacity.before_log(log.getLogger("tenacity.retry"), log.DEBUG), - before_sleep=tenacity.before_sleep_log(log.getLogger("tenacity.retry"), log.INFO), - after=tenacity.after_log(log.getLogger("tenacity.retry"), log.DEBUG) - ) -def resolve(hostname): - logger = log.getLogger("resolve()") - logger.info(hostname) - return socket.gethostbyname(hostname) - # Actual startup script os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front"))