mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
- 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
54 lines
1.2 KiB
Docker
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"]
|