FROM docker.io/mailserver/docker-mailserver:latest

LABEL maintainer="andreas.knuth@bayarea-cc.com"
LABEL description="Custom DMS with Python3 support and Sieve Sync"

# 1. Python, pip und dependencies installieren
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        python3 \
        python3-pip \
    && pip3 install --break-system-packages --no-cache-dir boto3 croniter \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# 2. Verzeichnis erstellen
WORKDIR /scripts

# 3. Script kopieren
COPY sync_dynamodb_to_sieve.py /scripts/sync.py
RUN chmod +x /scripts/sync.py

# 4. Schedule Konfiguration kopieren
COPY sieve-schedule /etc/sieve-schedule

# 5. Supervisor Konfiguration kopieren
COPY sieve-supervisor.conf /etc/supervisor/conf.d/sieve-sync.conf

# 6. Dynamic Whitelist Script und Supervisor-Config kopieren
COPY dynamic_whitelist.py /scripts/dynamic_whitelist.py
RUN chmod +x /scripts/dynamic_whitelist.py
COPY whitelist-supervisor.conf /etc/supervisor/conf.d/dynamic-whitelist.conf