Files
forwarder/README.md
T
1sonhador f6b276511a fix(connection): fail-fast IMAP/SMTP tests; add Gitea webhook autodeploy
Connection tests use 5s timeouts and run IMAP/SMTP in parallel so the UI
gets a clear error instead of nginx 504. Add deploy-hook service (:9090) and
deploy-pull.sh for push-to-main deploys on CT 243.
2026-07-01 01:09:53 +01:00

77 lines
2.1 KiB
Markdown

# BizDocs Forwarder
Multi-account IMAP → BizDocs forwarder: detect invoice attachments (PDF/XML/ZIP), re-send via SMTP as `.eml`.
- **Repo:** https://git.bitreport.pt/BitReport.pt/forwarder
- **Paperclip:** http://10.10.50.17:3100/BIT/projects/bizdocs-forwarder
## Stack
| Component | Path | Description |
|-----------|------|-------------|
| API | `src/forwarder/api/` | FastAPI REST |
| Worker | `src/forwarder/worker/` | APScheduler IMAP sync |
| Admin UI | `admin-ui/` | Vite + React |
| DB | MySQL 8 | Alembic migrations |
## Quick start
```bash
cp .env.example .env
# Generate ENCRYPTION_KEY: python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
docker compose up -d --build
docker compose exec api alembic upgrade head
```
- API: http://localhost:8000/api/health
- Admin UI: http://localhost:8080
- Auth: HTTP Basic (`ADMIN_USERNAME` / `ADMIN_PASSWORD`)
## Local dev
```bash
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
docker compose up -d mysql
alembic upgrade head
uvicorn forwarder.api.app:app --reload --app-dir src
forwarder worker # second terminal
cd admin-ui && npm install && npm run dev # third terminal
```
## Deploy (Proxmox CT 243)
**Autodeploy:** push to `main` on Gitea → webhook → `deploy-hook` (:9090) → `deploy/deploy-pull.sh` → `docker compose build && up`.
### One-time setup (CT)
```bash
git clone https://git.bitreport.pt/BitReport.pt/forwarder.git /opt/forwarder
cd /opt/forwarder
cp .env.example .env # or ln -s /etc/forwarder/forwarder.env .env
# Set DEPLOY_WEBHOOK_SECRET in .env (same value as Gitea webhook secret)
export FORWARDER_REPO_DIR=/opt/forwarder
docker compose up -d --build
```
### Gitea webhook
Repo → Settings → Webhooks → Add:
| Field | Value |
|-------|-------|
| URL | `http://10.10.50.43:9090/` |
| Secret | same as `DEPLOY_WEBHOOK_SECRET` in `.env` |
| Events | Push |
Test: `curl -s http://10.10.50.43:9090/` → `{"status":"ok",...}`
Deploy logs: `/opt/forwarder/storage/deploy-logs/`
### Manual deploy (emergency only)
```bash
cd /opt/forwarder && bash deploy/deploy-pull.sh
```