feat(mail): add Microsoft 365 Graph sync source with delta state

Adds a GET-only Microsoft Graph source to bin/mail/sync (client-credentials,
delta query). Wires it into the CLI (--source m365), the worker pool and the
compose stack:

- m365.go: M365Client (token cache, delta pagination, message normalization,
  attachment download) + m365Source adapter (per-mailbox folders + delta link)
- sync.go: M365Credentials in SyncConfig; Committer interface so delta links
  only advance after a fully successful run (no skips on failure)
- cli.go: --source m365 with M365_/MS_ env passthrough
- Dockerfile: mail-build stage produces /mail-sync into the index image
- docker-entrypoint: mail-sync loop (sync -> import -> index, default 10s)
- compose.yaml: mail-sync service (index image, kb-var volume, secrets ro)
This commit is contained in:
2026-08-14 16:35:20 +00:00
parent fc2723c39f
commit 5ccca2fac9
9 changed files with 700 additions and 6 deletions
+9
View File
@@ -28,6 +28,7 @@ RUN python -m pip install --no-cache-dir -r /tmp/requirements.lock.txt \
COPY . .
RUN chmod +x /app/bin/docker-entrypoint \
&& chown -R 2dph:2dph /app
COPY --from=mail-build /mail-sync /app/bin/mail-sync
USER 2dph
ENV PATH="/app/bin:${PATH}" \
@@ -37,6 +38,14 @@ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import model2vec, ladybug, mistune; print('ok')" || exit 1
ENTRYPOINT ["/app/bin/docker-entrypoint"]
# --- mail-sync: standalone M365/OnlyOffice/Gmail puller (pure Go, no CGO) ---
FROM golang:1.26-bookworm AS mail-build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY bin/mail ./bin/mail
RUN CGO_ENABLED=0 go build -o /mail-sync ./bin/mail/sync.go
# --- Go API: CGO with Zig, not gcc ---
FROM golang:1.26-bookworm AS api-build
WORKDIR /src