Files
johndoe6345789 a72bf02911 feat(services): create Python email service (IMAP/SMTP)
- Create Flask app with CORS and health check endpoint
- Implement account management: create, list, get, delete
- Implement sync control: trigger IMAP sync, check status, cancel
- Implement compose: send emails, manage drafts
- Add IMAPClient wrapper with incremental sync and UID tracking
- Add SMTP sender with attachment support (images, audio, docs)
- Add Dockerfile with multi-stage build for production
- Add .env.example and comprehensive README with API documentation

Includes:
- Multi-tenant safety with tenantId/userId filtering
- Encrypted credential handling via DBAL
- Celery-ready async task structure
- Full email parsing: headers, recipients, body (text/HTML)
- Folder type inference from IMAP flags
- Attachment parsing and handling
- Base64 encode/decode for attachment data

Task 7.1: Email Service Backend Implementation
2026-01-23 19:35:10 +00:00

54 lines
1.2 KiB
Docker

# Email Service - Multi-stage Docker build
# Build stage
FROM python:3.11-slim as builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements
COPY requirements.txt .
# Install Python dependencies to virtual env
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --no-cache-dir -r requirements.txt
# Runtime stage
FROM python:3.11-slim
WORKDIR /app
# Install runtime dependencies only
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
# Copy application code
COPY app.py .
COPY src/ src/
# Set environment
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
FLASK_ENV=production \
FLASK_HOST=0.0.0.0 \
FLASK_PORT=5000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:5000/health')" || exit 1
# Expose port
EXPOSE 5000
# Run Flask app
CMD ["python", "app.py"]