Merge branch 'master' of ssh://raspberrypi/~/git/email-organizer
This commit is contained in:
@@ -30,6 +30,9 @@ A self-hosted AI-powered email organization system that automates folder sorting
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Set up development environment (PostgreSQL and IMAP server)
|
||||
flask setup-dev
|
||||
|
||||
# Configure environment
|
||||
cp .env.example .env
|
||||
# (Edit .env with your DB/IMAP credentials)
|
||||
|
||||
34
app/commands.py
Normal file
34
app/commands.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
from app import create_app, db
|
||||
from app.models import Folder, User
|
||||
from flask.cli import with_appcontext
|
||||
import click
|
||||
|
||||
app = create_app()
|
||||
|
||||
|
||||
@app.cli.command("setup-dev")
|
||||
def setup_dev():
|
||||
"""Set up development environment with Docker Compose."""
|
||||
# Create tmp directory for IMAP data if it doesn't exist
|
||||
os.makedirs('tmp/imap-data', exist_ok=True)
|
||||
|
||||
# Start the services
|
||||
try:
|
||||
subprocess.run(['docker-compose', 'up', '-d'], check=True)
|
||||
print("Services started successfully:")
|
||||
print("- PostgreSQL: localhost:5432 (database: email_organizer_dev, user: postgres, password: password)")
|
||||
print("- IMAP Server: localhost:1143")
|
||||
print(" Users:")
|
||||
print(" - user1@example.com / password1")
|
||||
print(" - user2@example.com / password2")
|
||||
print(" Folders: INBOX, Pending, Work, Personal, Receipts, Marketing, Archived")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error starting services: {e}")
|
||||
sys.exit(1)
|
||||
except FileNotFoundError:
|
||||
print("Docker Compose not found. Please install Docker and Docker Compose.")
|
||||
sys.exit(1)
|
||||
|
||||
32
docker-compose.yml
Normal file
32
docker-compose.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:14
|
||||
environment:
|
||||
POSTGRES_DB: email_organizer_dev
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: password
|
||||
ports:
|
||||
- "5432:5432"
|
||||
tmpfs:
|
||||
- /var/lib/postgresql/data
|
||||
command: >
|
||||
postgres -c log_statement=all
|
||||
|
||||
imap:
|
||||
image: dovecot/dovecot:2.3-latest
|
||||
ports:
|
||||
- "5143:143"
|
||||
- "31143:31143"
|
||||
volumes:
|
||||
# Mount a volume to persist email data during development
|
||||
- ./tmp/imap-data:/srv/mail
|
||||
# Mount configuration overrides
|
||||
- ./dovecot-conf/conf.d:/etc/dovecot/conf.d
|
||||
- ./dovecot-conf/users:/etc/dovecot/users
|
||||
- ./dovecot-conf/dovecot.conf:/etc/dovecot/dovecot.conf
|
||||
environment: {}
|
||||
tmpfs:
|
||||
- /tmp
|
||||
- /run
|
||||
64
docs/design/development-setup.md
Normal file
64
docs/design/development-setup.md
Normal file
@@ -0,0 +1,64 @@
|
||||
# Development Setup
|
||||
|
||||
This document describes how to set up a development environment for the Email Organizer application.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Docker and Docker Compose
|
||||
- Python 3.10+
|
||||
|
||||
## Services
|
||||
|
||||
The development environment consists of two services:
|
||||
|
||||
1. **PostgreSQL Database**: A non-persistent PostgreSQL instance for development
|
||||
2. **IMAP Server**: A fake IMAP server with predefined users and folders
|
||||
|
||||
## Setup Commands
|
||||
|
||||
To set up the development environment, run:
|
||||
|
||||
```bash
|
||||
flask setup-dev
|
||||
```
|
||||
|
||||
This command will:
|
||||
1. Create necessary directories
|
||||
2. Start PostgreSQL and IMAP services via Docker Compose
|
||||
3. Display connection information
|
||||
|
||||
## Service Details
|
||||
|
||||
### PostgreSQL
|
||||
|
||||
- Host: localhost
|
||||
- Port: 5432
|
||||
- Database: email_organizer_dev
|
||||
- User: postgres
|
||||
- Password: password
|
||||
|
||||
### IMAP Server
|
||||
|
||||
- Host: localhost
|
||||
- Port: 1143
|
||||
- Users:
|
||||
- user1@example.com / password1
|
||||
- user2@example.com / password2
|
||||
- Folders:
|
||||
- INBOX
|
||||
- Pending
|
||||
- Work
|
||||
- Personal
|
||||
- Receipts
|
||||
- Marketing
|
||||
- Archived
|
||||
|
||||
## Environment Configuration
|
||||
|
||||
After running `flask setup-dev`, copy the example environment file:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
The default configuration should work with the development services. You can modify the `.env` file if needed.
|
||||
0
dovecot-conf/auth-system.conf.ext
Normal file
0
dovecot-conf/auth-system.conf.ext
Normal file
11
dovecot-conf/conf.d/10-auth.conf
Normal file
11
dovecot-conf/conf.d/10-auth.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
disable_plaintext_auth = no
|
||||
auth_mechanisms = plain login
|
||||
passdb {
|
||||
driver = passwd-file
|
||||
args = username_format=%u /etc/dovecot/users
|
||||
}
|
||||
|
||||
userdb {
|
||||
driver = static
|
||||
args = uid=vmail gid=vmail home=/srv/mail/%d/%n mail=maildir:/srv/mail/%d/%n
|
||||
}
|
||||
39
dovecot-conf/conf.d/10-mailboxes.conf
Normal file
39
dovecot-conf/conf.d/10-mailboxes.conf
Normal file
@@ -0,0 +1,39 @@
|
||||
# Mailbox configuration
|
||||
namespace {
|
||||
separator = /
|
||||
prefix =
|
||||
location = maildir:/srv/mail/%d/%n
|
||||
inbox = yes
|
||||
|
||||
# Auto-create and subscribe mailboxes
|
||||
mailbox INBOX {
|
||||
auto = subscribe
|
||||
}
|
||||
|
||||
mailbox Pending {
|
||||
auto = subscribe
|
||||
}
|
||||
|
||||
mailbox Work {
|
||||
auto = subscribe
|
||||
}
|
||||
|
||||
mailbox Personal {
|
||||
auto = subscribe
|
||||
}
|
||||
|
||||
mailbox Receipts {
|
||||
auto = subscribe
|
||||
}
|
||||
|
||||
mailbox Marketing {
|
||||
auto = subscribe
|
||||
}
|
||||
|
||||
mailbox Archived {
|
||||
auto = subscribe
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
1
dovecot-conf/conf.d/99-local.conf
Normal file
1
dovecot-conf/conf.d/99-local.conf
Normal file
@@ -0,0 +1 @@
|
||||
# Local configuration overrides
|
||||
66
dovecot-conf/dovecot.conf
Executable file
66
dovecot-conf/dovecot.conf
Executable file
@@ -0,0 +1,66 @@
|
||||
## You should mount /etc/dovecot if you want to
|
||||
## manage this file
|
||||
|
||||
mail_home=/srv/mail/%Lu
|
||||
mail_location=sdbox:~/Mail
|
||||
mail_uid=1000
|
||||
mail_gid=1000
|
||||
|
||||
protocols = imap pop3 submission sieve lmtp
|
||||
|
||||
first_valid_uid = 1000
|
||||
last_valid_uid = 1000
|
||||
|
||||
passdb {
|
||||
driver = static
|
||||
args = password=pass
|
||||
}
|
||||
|
||||
ssl=yes
|
||||
ssl_cert=<cert.pem
|
||||
ssl_key=<key.pem
|
||||
|
||||
# namespace {
|
||||
# inbox = yes
|
||||
# separator = /
|
||||
# }
|
||||
|
||||
service lmtp {
|
||||
inet_listener {
|
||||
port = 24
|
||||
}
|
||||
}
|
||||
|
||||
service imap-login {
|
||||
process_min_avail = 1
|
||||
client_limit = 1000
|
||||
service_count = 0
|
||||
}
|
||||
|
||||
service pop3-login {
|
||||
process_min_avail = 1
|
||||
client_limit = 1000
|
||||
service_count = 0
|
||||
}
|
||||
|
||||
service submission-login {
|
||||
process_min_avail = 1
|
||||
client_limit = 1000
|
||||
service_count = 0
|
||||
}
|
||||
|
||||
service managesieve-login {
|
||||
process_min_avail = 1
|
||||
client_limit = 1000
|
||||
service_count = 0
|
||||
}
|
||||
|
||||
listen = *
|
||||
|
||||
log_path=/dev/stdout
|
||||
info_log_path=/dev/stdout
|
||||
debug_log_path=/dev/stdout
|
||||
|
||||
verbose_proctitle = yes
|
||||
|
||||
!include_try /etc/dovecot/conf.d/*.conf
|
||||
2
dovecot-conf/users
Normal file
2
dovecot-conf/users
Normal file
@@ -0,0 +1,2 @@
|
||||
user1@example.com:{PLAIN}password1
|
||||
user2@example.com:{PLAIN}password2
|
||||
121
dovecot-docs.md
Normal file
121
dovecot-docs.md
Normal file
@@ -0,0 +1,121 @@
|
||||
|
||||
Building AI Agents is Now Easy
|
||||
✕
|
||||
|
||||
Explore
|
||||
dovecot
|
||||
dovecot
|
||||
|
||||
dovecot/dovecot
|
||||
By dovecot
|
||||
|
||||
•
|
||||
Updated 7 days ago
|
||||
Dovecot CE repository
|
||||
|
||||
Image
|
||||
34
|
||||
500K+
|
||||
|
||||
dovecot/dovecot repository overview
|
||||
Instructions for 2.4
|
||||
This image comes with default configuration which accepts any user with password pass. To persist data, mount /srv/mail volumes. You can also mount extra configuration to override the default settings to /etc/dovecot/conf.d.
|
||||
|
||||
TLS certificates go to /etc/dovecot/ssl, and by default full-chain certificate filename is tls.crt and private key file is tls.key.
|
||||
|
||||
To run read-only, remember to mount tmpfs to /tmp and /run, and persistent data storage to /srv/vmail.
|
||||
|
||||
If you want to run without any extra linux capabilities, set chroot= to services imap-login, pop3-login, submission-login and managesieve-login.
|
||||
|
||||
Read more at https://doc.dovecot.org/latest/installation/docker.html
|
||||
|
||||
There are dev and root images as well. The dev image is "unlocked" image that can be used to derive your own image. Root image is intended to be ran as root.
|
||||
|
||||
Listeners
|
||||
POP3 on 31110, TLS 31995 (needs config file to enable, disabled by default)
|
||||
IMAP on 31143, TLS 31993
|
||||
Submission on 31587
|
||||
LMTPS on 31024
|
||||
ManageSieve on 34190
|
||||
HTTP API on 8080
|
||||
Metrics on 9090
|
||||
Instructions for 2.3
|
||||
This image comes with default configuration which accepts any user with password password. To customize the image, mount /etc/dovecot and /srv/mail volumes. Since 2.3.20, you can also mount /etc/dovecot/conf.d for overrides and new configuration, make sure the files end up with .conf.
|
||||
|
||||
Listeners
|
||||
POP3 on 110, TLS 995
|
||||
IMAP on 143, TLS 993
|
||||
Submission on 587
|
||||
LMTP on 24
|
||||
ManageSieve on 4190
|
||||
Support
|
||||
Note that these images come with absolutely no warranty or support. For questions and feedback send email to dovecot@dovecot.org.
|
||||
|
||||
You can find the image Dockerfiles at https://github.com/dovecot/docker
|
||||
|
||||
Tag summary
|
||||
latest
|
||||
Recent tags
|
||||
Content type
|
||||
|
||||
Image
|
||||
|
||||
Digest
|
||||
|
||||
sha256:f2eb7a839…
|
||||
|
||||
Size
|
||||
|
||||
56 MB
|
||||
|
||||
Last updated
|
||||
|
||||
7 days ago
|
||||
|
||||
Requires Docker Desktop 4.37.1 or later.
|
||||
|
||||
Was this helpful?
|
||||
Why
|
||||
Overview
|
||||
What is a Container
|
||||
Products
|
||||
Product Overview
|
||||
Product Offerings
|
||||
Docker Desktop
|
||||
Docker Hub
|
||||
Features
|
||||
Container Runtime
|
||||
Developer Tools
|
||||
Docker App
|
||||
Kubernetes
|
||||
Developers
|
||||
Getting Started
|
||||
Play with Docker
|
||||
Community
|
||||
Open Source
|
||||
Documentation
|
||||
Company
|
||||
About Us
|
||||
Resources
|
||||
Blog
|
||||
Customers
|
||||
Partners
|
||||
Newsroom
|
||||
Events and Webinars
|
||||
Careers
|
||||
Contact Us
|
||||
System Status
|
||||
© 2025 Docker, Inc. All rights reserved.
|
||||
|
|
||||
Terms of Service
|
||||
|
|
||||
Subscription Service Agreement
|
||||
|
|
||||
Privacy
|
||||
|
|
||||
Legal
|
||||
|
||||
Cookies Settings
|
||||
By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.
|
||||
Cookies Settings Reject All Accept All Cookies
|
||||
|
||||
28
manage.py
28
manage.py
@@ -1,4 +1,6 @@
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
from app import create_app, db
|
||||
from app.models import Folder, User
|
||||
from flask.cli import with_appcontext
|
||||
@@ -13,6 +15,29 @@ def shell():
|
||||
import code
|
||||
code.interact(local=dict(globals(), **locals()))
|
||||
|
||||
@app.cli.command("setup-dev")
|
||||
def setup_dev():
|
||||
"""Set up development environment with Docker Compose."""
|
||||
# Create tmp directory for IMAP data if it doesn't exist
|
||||
os.makedirs('tmp/imap-data', exist_ok=True)
|
||||
|
||||
# Start the services
|
||||
try:
|
||||
subprocess.run(['docker-compose', 'up', '-d'], check=True)
|
||||
print("Services started successfully:")
|
||||
print("- PostgreSQL: localhost:5432 (database: email_organizer_dev, user: postgres, password: password)")
|
||||
print("- IMAP Server: localhost:1143")
|
||||
print(" Users:")
|
||||
print(" - user1@example.com / password1")
|
||||
print(" - user2@example.com / password2")
|
||||
print(" Folders: INBOX, Pending, Work, Personal, Receipts, Marketing, Archived")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error starting services: {e}")
|
||||
sys.exit(1)
|
||||
except FileNotFoundError:
|
||||
print("Docker Compose not found. Please install Docker and Docker Compose.")
|
||||
sys.exit(1)
|
||||
|
||||
def mock_process_emails():
|
||||
"""Simulate processing emails with defined rules."""
|
||||
with app.app_context():
|
||||
@@ -44,4 +69,5 @@ if __name__ == '__main__':
|
||||
if len(sys.argv) > 1 and sys.argv[1] == 'mock-process':
|
||||
mock_process_emails()
|
||||
else:
|
||||
print("Usage: python manage.py mock-process")
|
||||
print("Usage: python manage.py mock-process")
|
||||
print(" flask setup-dev")
|
||||
|
||||
Reference in New Issue
Block a user