Spaces:
Running
Running
Enhance Dockerfile to build and install SQLite from source; update mail controller to retrieve and store user ID
Browse files- Dockerfile +24 -7
- app/controllers/mail.py +2 -0
Dockerfile
CHANGED
@@ -1,19 +1,36 @@
|
|
1 |
# Use the official Python 3.10.9 image
|
2 |
FROM python:3.10.9
|
3 |
|
4 |
-
# Install SQLite
|
5 |
-
RUN apt-get update && apt-get install -y
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
COPY . .
|
9 |
|
10 |
-
# Set the working directory to /
|
11 |
WORKDIR /app
|
12 |
|
13 |
-
# Install requirements.txt
|
14 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
15 |
|
16 |
EXPOSE 7860
|
17 |
|
18 |
-
# Start the FastAPI app on port 7860
|
19 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
# Use the official Python 3.10.9 image
|
2 |
FROM python:3.10.9
|
3 |
|
4 |
+
# Install dependencies for building SQLite
|
5 |
+
RUN apt-get update && apt-get install -y \
|
6 |
+
build-essential \
|
7 |
+
wget \
|
8 |
+
libsqlite3-dev \
|
9 |
+
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
+
# Install SQLite 3.35.0 or higher from source
|
12 |
+
RUN wget https://www.sqlite.org/2025/sqlite-autoconf-3410000.tar.gz && \
|
13 |
+
tar -xzf sqlite-autoconf-3410000.tar.gz && \
|
14 |
+
cd sqlite-autoconf-3410000 && \
|
15 |
+
./configure && \
|
16 |
+
make && \
|
17 |
+
make install && \
|
18 |
+
cd .. && \
|
19 |
+
rm -rf sqlite-autoconf-3410000 sqlite-autoconf-3410000.tar.gz
|
20 |
+
|
21 |
+
# Verify SQLite version
|
22 |
+
RUN sqlite3 --version
|
23 |
+
|
24 |
+
# Copy the current directory contents into the container at /app
|
25 |
COPY . .
|
26 |
|
27 |
+
# Set the working directory to /app
|
28 |
WORKDIR /app
|
29 |
|
30 |
+
# Install requirements.txt
|
31 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
32 |
|
33 |
EXPOSE 7860
|
34 |
|
35 |
+
# Start the FastAPI app on port 7860
|
36 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
app/controllers/mail.py
CHANGED
@@ -78,6 +78,7 @@ def list_emails(messages):
|
|
78 |
ids = []
|
79 |
documents = []
|
80 |
for message in messages:
|
|
|
81 |
msg = service.users().messages().get(userId="me", id=message["id"], format="full").execute()
|
82 |
metadata = {}
|
83 |
for header in msg["payload"]["headers"]:
|
@@ -92,6 +93,7 @@ def list_emails(messages):
|
|
92 |
metadata["date"] = datetime.fromtimestamp(int(msg["internalDate"]) / 1000).strftime(
|
93 |
"%d/%m/%Y %H:%M:%S"
|
94 |
)
|
|
|
95 |
metadata["msg_id"] = msg["id"]
|
96 |
print(metadata, msg["payload"]["mimeType"])
|
97 |
ids = []
|
|
|
78 |
ids = []
|
79 |
documents = []
|
80 |
for message in messages:
|
81 |
+
user_id = service.users().getProfile(userId="me").execute().get("emailAddress")
|
82 |
msg = service.users().messages().get(userId="me", id=message["id"], format="full").execute()
|
83 |
metadata = {}
|
84 |
for header in msg["payload"]["headers"]:
|
|
|
93 |
metadata["date"] = datetime.fromtimestamp(int(msg["internalDate"]) / 1000).strftime(
|
94 |
"%d/%m/%Y %H:%M:%S"
|
95 |
)
|
96 |
+
metadata["user_id"] = user_id
|
97 |
metadata["msg_id"] = msg["id"]
|
98 |
print(metadata, msg["payload"]["mimeType"])
|
99 |
ids = []
|