Milestone 1 scaffold: binary skeleton, schema, deploy, Mox spike

- Confirmed core bet via spike/mimecheck: mox/message parses a messy multipart
  message standalone (envelope, MIME tree, attachment, body) with only an
  io.ReaderAt — no mox store/config. Option B is viable.
- cmd/openmail single binary: serve|migrate|smtpd|sender|version subcommands.
- internal/api: chi router, constant-time bearer auth, /healthz, stubbed v0
  AgentMail-shaped routes (501 until core services land).
- internal/store: pgxpool + embedded, idempotent, tracked SQL migrations.
- internal/store/migrations/0001_init.sql: full native schema (pods, inboxes,
  threads, messages, attachments, drafts, api_keys, webhooks, outbox, events,
  domains) with FTS + GIN indexes. Validated end-to-end against Postgres 16.
- deploy/: docker-compose (postgres+minio+openmail+caddy), Caddyfile, DNS.md
  (MX/SPF/DKIM/DMARC/DANE/MTA-STS). Makefile, .gitignore.
- Verified: go vet clean; build OK; health/auth smoke tests; migrate idempotent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
karti-ai
2026-06-21 12:16:51 -07:00
parent aab2a8558e
commit 551739baa3
15 changed files with 889 additions and 2 deletions
+30
View File
@@ -0,0 +1,30 @@
// Package config loads OpenMail configuration from the environment.
// Twelve-factor style: everything via env vars, sane defaults for local dev.
package config
import (
"os"
)
type Config struct {
HTTPAddr string // OPENMAIL_HTTP_ADDR, e.g. ":8080"
DatabaseURL string // DATABASE_URL, e.g. postgres://user:pass@host:5432/openmail
SMTPAddr string // OPENMAIL_SMTP_ADDR, inbound :25 listener
AdminToken string // OPENMAIL_ADMIN_TOKEN, bootstrap bearer until DB-backed api_keys land
}
func Load() Config {
return Config{
HTTPAddr: envOr("OPENMAIL_HTTP_ADDR", ":8080"),
DatabaseURL: os.Getenv("DATABASE_URL"),
SMTPAddr: envOr("OPENMAIL_SMTP_ADDR", ":25"),
AdminToken: os.Getenv("OPENMAIL_ADMIN_TOKEN"),
}
}
func envOr(key, def string) string {
if v := os.Getenv(key); v != "" {
return v
}
return def
}