BuyingAgent/docs/DEPLOYMENT.md
Lars 3ac42645ef
All checks were successful
Deploy Development / deploy (push) Successful in 1m6s
Test Suite / smoke-dev (push) Successful in 0s
Richte Develop-Build und Main-Deploy analog zur Jinkendo-Familie ein.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-03 10:47:48 +02:00

88 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Deployment – BuyingAgent
**Stand:** 2026-10-03
**Server:** Raspberry Pi 5 (`192.168.2.49`) — gleicher Host wie Kanshō/Mitai/Shinkan/Kairo, **eigenes** Compose-Projekt
**Runner:** Gitea Actions (`/home/lars/gitea-runner/`, Label `ubuntu-latest` → Host)
**Repo:** `http://192.168.2.144:3000/Lars/BuyingAgent.git`
Fachliche Grundlage: `.specs/buying-agent-v0.1-spec.md` bzw. `docs/buying-agent-v0.1-spec-v1.1.md`.
v0.1 hat keine Web-UI; öffentlich wird nur die API bereitgestellt.
---
## Port- und Pfad-Übersicht
| | Production | Development |
|---|------------|-------------|
| **Git-Branch** | `main` | `develop` |
| **Server-Verzeichnis** | `/home/lars/docker/buyingagent` | `/home/lars/docker/buyingagent-dev` |
| **API-Port** | 8006 | 8095 |
| **PostgreSQL** | nur Compose-Netz, DB `buyingagent` | nur Compose-Netz, DB `buyingagent_dev` |
| **Compose** | `docker-compose.yml` | `docker-compose.dev-env.yml` |
| **Health** | `http://localhost:8006/health/ready` | `http://localhost:8095/health/ready` |
| **LAN** | `http://192.168.2.49:8006` | `http://192.168.2.49:8095` |
Lokal ohne Server: `127.0.0.1:8000` über `docker compose up --build -d` (siehe README).
8006/8095 waren auf dem Pi frei. 8000 ist durch Paperless belegt und darf auf dem Server nicht verwendet werden.
---
## Branch-Regel
- Entwicklung nur auf `develop`.
- Push auf `develop` startet den Dev-Build auf dem Pi.
- Produktiv nur über Merge-Commit `develop` → `main`:
```bash
git checkout main
git pull origin main
git merge --no-ff develop
git push origin main
```
Kein Fast-Forward, kein direkter Commit auf `main`, kein manuelles `git pull` auf dem Prod-Checkout. Gitea (`deploy-prod.yml`) ist der einzige Prod-Schreibpfad für Code.
---
## Einmalige Server-Einrichtung
Die Workflows legen das Verzeichnis an und klonen bei Bedarf selbst. Actions sind im Repo bereits aktiv. Derselbe Pi-Runner wie die Schwesterprodukte (`ubuntu-latest`).
Nach dem ersten erfolgreichen Deploy `.env` prüfen und für Production ein eigenes `DB_PASSWORD` setzen. PostgreSQL übernimmt User/Passwort nur beim **ersten** Start des Volumes.
```bash
mkdir -p /home/lars/docker/buyingagent /home/lars/docker/buyingagent-dev
```
Watchtower bleibt aus.
---
## Gitea Actions
| Workflow | Trigger | Zweck |
|----------|---------|--------|
| `deploy-dev.yml` | Push `develop` | Deploy nach `/home/lars/docker/buyingagent-dev`, Health `localhost:8095` |
| `deploy-prod.yml` | Push `main` | Deploy nach `/home/lars/docker/buyingagent`, Health `localhost:8006` |
| `test.yml` | nach Dev-Deploy bzw. Push `develop` | nicht-schreibender Smoke gegen `/health/live` und `/health/ready` |
---
## Manuelles Deploy
```bash
# Development
cd /home/lars/docker/buyingagent-dev
git fetch origin develop && git reset --hard origin/develop
docker compose -f docker-compose.dev-env.yml build --no-cache api
BUYING_AGENT_API_PORT=8095 docker compose -f docker-compose.dev-env.yml up -d --wait
curl -sf http://localhost:8095/health/ready
# Production
cd /home/lars/docker/buyingagent
git fetch origin main && git reset --hard origin/main
BUYING_AGENT_API_BIND=0.0.0.0 BUYING_AGENT_API_PORT=8006 docker compose build --no-cache api
BUYING_AGENT_API_BIND=0.0.0.0 BUYING_AGENT_API_PORT=8006 docker compose up -d --wait
curl -sf http://localhost:8006/health/ready
```