diff --git a/BASEOS b/BASEOS deleted file mode 100644 index 2dee175..0000000 --- a/BASEOS +++ /dev/null @@ -1 +0,0 @@ -debian diff --git a/VERSION b/VERSION deleted file mode 100644 index f7bed87..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -18.11 diff --git a/docker-build.sh b/docker-build.sh index fa6d10d..4a99022 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -1,27 +1,13 @@ #!/bin/sh BRANCH="$(/usr/bin/git branch|/bin/grep \*|/usr/bin/awk {'print $2'})" -VERSION="$(/bin/cat VERSION)" -BASEOS="$(/bin/cat BASEOS)" -GO="" -while getopts g opt -do - case $opt in - g) GO="go";; - esac -done - -if [ -z "${GO}" ] ; then - echo "Building GULAG@docker on '${BASEOS}' for version '${VERSION}' in branch '${BRANCH}'!" - echo "GO serious with '-g'!" - exit 1 -fi - -IMAGES="gulag-server gulag-db" +#IMAGES="server db" +IMAGES="server" for IMAGE in ${IMAGES}; do /usr/bin/docker build \ - -t "${IMAGE}/${BASEOS}:${VERSION}_${BRANCH}" \ - -f "docker/${IMAGE}/${BASEOS}/Dockerfile" . + -t ${IMAGE}:${BRANCH} \ + -f ./docker/${IMAGE}/Dockerfile \ + ./docker/${IMAGE}/. done diff --git a/docker/gulag-db/debian/Dockerfile b/docker/db/Dockerfile similarity index 81% rename from docker/gulag-db/debian/Dockerfile rename to docker/db/Dockerfile index 4480c5f..934ea32 100644 --- a/docker/gulag-db/debian/Dockerfile +++ b/docker/db/Dockerfile @@ -8,3 +8,5 @@ RUN apt update && \ && rm -rf /var/lib/apt/lists/* COPY db/gulag.sql /. CMD ["/usr/bin/mysqld_safe"] + +### FIXME: /var/run/mysqld ist nur für root beschreibbar! diff --git a/db/gulag.sql b/docker/db/gulag.sql similarity index 100% rename from db/gulag.sql rename to docker/db/gulag.sql diff --git a/docker/gulag-server/debian/Dockerfile b/docker/gulag-server/debian/Dockerfile deleted file mode 100644 index 5aea77e..0000000 --- a/docker/gulag-server/debian/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -ARG http_proxy -ARG https_proxy -FROM debian:buster -LABEL maintainer="Dominik Chilla" - -ENV DEBIAN_FRONTEND=noninteractive \ - TZ=Europe/Berlin - -RUN env; set -ex ; \ - apt-get -qq update \ - && apt-get -qq --no-install-recommends install \ - uwsgi-plugin-python3 python3-setuptools python3-flask \ - python3-flask-restful \ - uwsgi uwsgi-plugin-python3 procps net-tools \ - python3-pip libmagic1 python3-ssdeep \ - && pip3 install python-magic mysql-connector \ - && /bin/mkdir /config /socket /app \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -COPY app/*.py /app/ - -CMD ["/usr/bin/uwsgi","--emperor","/config/vassals"] diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile new file mode 100644 index 0000000..f5846a3 --- /dev/null +++ b/docker/server/Dockerfile @@ -0,0 +1,18 @@ +FROM dockreg-zdf.int.zwackl.de/alpine/amd64:prod +LABEL maintainer="Dominik Chilla" + +RUN env; set -ex ; \ + apk update \ + && apk add gcc python3-dev libc-dev uwsgi-python py3-flask-restful libmagic + +RUN apk add libffi-dev +# ALPINE-TBD: ssdeep +RUN pip3 install python-magic mysql-connector +RUN pip3 install six + +RUN /bin/mkdir /config /socket /app + +ADD ./app/*.py /app/ +ADD ./config/ /config/ + +CMD ["/usr/sbin/uwsgi","--emperor","/config/vassals"] diff --git a/gulag-openapi-2.0.yaml b/docker/server/Swaggerfile.yml similarity index 100% rename from gulag-openapi-2.0.yaml rename to docker/server/Swaggerfile.yml diff --git a/app/Entities.py b/docker/server/app/Entities.py similarity index 100% rename from app/Entities.py rename to docker/server/app/Entities.py diff --git a/app/Gulag.py b/docker/server/app/Gulag.py similarity index 99% rename from app/Gulag.py rename to docker/server/app/Gulag.py index b074f26..3dc0736 100644 --- a/app/Gulag.py +++ b/docker/server/app/Gulag.py @@ -7,7 +7,8 @@ from GulagDB import ( from GulagMailbox import IMAPmailbox,IMAPmailboxException from GulagMailrelay import GulagMailrelay,GulagMailrelayException from GulagUtils import whoami,extract_uris,extract_fqdn -import ssdeep, hashlib +#import ssdeep, hashlib +import hashlib class GulagException(Exception): message = None @@ -131,7 +132,7 @@ class Gulag: ) imap_mb.move_message(str(uid.decode()), 'failed') continue - if(r5321_from is not '<>'): + if(r5321_from != '<>'): r5321_from = r5321_from.replace("<","") r5321_from = r5321_from.replace(">","") r5321_rcpts = None @@ -193,7 +194,8 @@ class Gulag: 'hdr_msgid': msg_id, 'hdr_date': date, 'cf_meta': 'cf_meta', 'mailbox_id': mailbox['id'], 'imap_uid': uid, 'source_id': source_id, 'msg_size': len(msg_serialized), - 'ssdeep': ssdeep.hash(msg_serialized) +# 'ssdeep': ssdeep.hash(msg_serialized) + 'ssdeep': 'ALPINE-LINUX-TBD!' }) except GulagDBBadInputException as e: logging.warn(whoami(self) + e.message) @@ -234,7 +236,8 @@ class Gulag: 'magic': mgc, 'mime_type': mime_type, 'sha256': hashlib.sha256(attach_decoded).hexdigest(), - 'ssdeep': ssdeep.hash(attach_decoded), +# 'ssdeep': ssdeep.hash(attach_decoded), + 'ssdeep': 'ALPINE-LINUX-TBD!', 'size': len(attach_decoded) }) attachments.append(attach_id) diff --git a/app/GulagDB.py b/docker/server/app/GulagDB.py similarity index 100% rename from app/GulagDB.py rename to docker/server/app/GulagDB.py diff --git a/app/GulagMailbox.py b/docker/server/app/GulagMailbox.py similarity index 100% rename from app/GulagMailbox.py rename to docker/server/app/GulagMailbox.py diff --git a/app/GulagMailrelay.py b/docker/server/app/GulagMailrelay.py similarity index 100% rename from app/GulagMailrelay.py rename to docker/server/app/GulagMailrelay.py diff --git a/app/GulagUtils.py b/docker/server/app/GulagUtils.py similarity index 100% rename from app/GulagUtils.py rename to docker/server/app/GulagUtils.py diff --git a/app/Resources.py b/docker/server/app/Resources.py similarity index 100% rename from app/Resources.py rename to docker/server/app/Resources.py diff --git a/app/gulag_helpers.py b/docker/server/app/gulag_helpers.py similarity index 87% rename from app/gulag_helpers.py rename to docker/server/app/gulag_helpers.py index 72660a5..57d4b78 100755 --- a/app/gulag_helpers.py +++ b/docker/server/app/gulag_helpers.py @@ -18,15 +18,15 @@ if(importer_pid == 0): logging.info("Gulag-Importer Exception: " + e.message) sys.exit(1) except: - logging.info("Gulag-Importer Exception: " + str(sys.exc_info())) + logging.info("Gulag-Importer Exception: " + traceback.format_exc()) logging.info("Gulag-Importer: starting") while True: try: gulag.import_quarmails() except GulagException as e: - logging.error("Gulag-Importer-Exception: " + e.message) + logging.error("Gulag-Importer-Exception1: " + traceback.format_exc()) except: - logging.error("Gulag-Importer-Exception: " + traceback.format_exc()) + logging.error("Gulag-Importer-Exception2: " + traceback.format_exc()) time.sleep(gulag.config['importer']['interval']) cleaner_pid = os.fork() diff --git a/app/gulag_server.py b/docker/server/app/gulag_server.py similarity index 97% rename from app/gulag_server.py rename to docker/server/app/gulag_server.py index 2a4d8b5..1eb7bad 100755 --- a/app/gulag_server.py +++ b/docker/server/app/gulag_server.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import traceback import argparse,sys,logging from flask import Flask from flask_restful import Api @@ -94,4 +95,4 @@ try: gulag.db.close() sys.exit(0) except: - logging.error("Gulag-Server-Exception: " + str(sys.exc_info())) + logging.error("Gulag-Server-Exception: " + traceback.format_exc()) diff --git a/app/uwsgi.py b/docker/server/app/uwsgi.py similarity index 100% rename from app/uwsgi.py rename to docker/server/app/uwsgi.py diff --git a/config/gulag-config.json b/docker/server/config/gulag-config.json similarity index 100% rename from config/gulag-config.json rename to docker/server/config/gulag-config.json diff --git a/config/vassals/gulag_helpers.ini b/docker/server/config/vassals/gulag_helpers.ini similarity index 100% rename from config/vassals/gulag_helpers.ini rename to docker/server/config/vassals/gulag_helpers.ini diff --git a/config/vassals/gulag_server.ini b/docker/server/config/vassals/gulag_server.ini similarity index 92% rename from config/vassals/gulag_server.ini rename to docker/server/config/vassals/gulag_server.ini index a3fea90..d860f31 100644 --- a/config/vassals/gulag_server.ini +++ b/docker/server/config/vassals/gulag_server.ini @@ -3,7 +3,7 @@ processes = 4 cheaper = 1 cheaper-initial = 1 cheaper-step = 1 -plugin = python3 +plugin = python python-path = /app wsgi-file = /app/uwsgi.py pyargv = --config /config/gulag-config.json diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29