Files
sugar-crm/README.md
root 1c4a366409
Some checks failed
Docker Build & Push SugarCRM 6.5 CE / build-and-push (push) Has been cancelled
feat: SugarCRM 6.5.26 CE - Docker + compose + CI/CD
- PHP 5.6 Apache Dockerfile (Debian Jessie, archive repos)
- Source from bklein01/sugarcrm GitHub mirror
- MySQL 5.7 database with healthcheck
- Silent install via init.sh (AdminWizard disabled)
- REST v4.1 API test script (test_api.py)
- Gitea Actions CI/CD for registry push
- Full README with API docs and pitfall notes
2026-05-24 14:33:08 +02:00

177 lines
5.4 KiB
Markdown

# SugarCRM 6.5.26 CE — Containerized Docker Environment
**100% containerisierte SugarCRM Community Edition 6.5.26**
Ein `docker compose up -d` — alles läuft: Apache/PHP 5.6 + MySQL 5.7 + REST API v4.1.
## 🚀 Quickstart
```bash
# 1. Clone
git clone https://git.kgessner.de/LuiiCode/sugar-crm.git
cd sugar-crm
# 2. Konfigurieren (Passwörter ändern!)
nano .env
# 3. Starten
docker compose up -d
# 4. Web-UI öffnen
# → http://localhost:2080
# Login: admin / admin123
# 5. API testen
python3 test_api.py
```
## 🏗️ Architektur
```
┌─────────────────────────────────────────┐
│ Docker Compose │
│ │
│ ┌───────────────┐ ┌───────────────┐ │
│ │ SugarCRM 6.5 │ │ MySQL 5.7 │ │
│ │ Apache/PHP5.6 │ │ :3306 │ │
│ │ :2080 │◄─│ │ │
│ │ │ │ │ │
│ └───────────────┘ └───────────────┘ │
│ │
│ Data (volumes): │
│ sugarcrm_custom → custom modules │
│ sugarcrm_upload → uploads │
│ mysql_data → DB Daten │
└─────────────────────────────────────────┘
```
## 📦 Services
| Service | Image | Port | Beschreibung |
|---------|-------|------|-------------|
| `sugarcrm` | Custom (PHP 5.6) | `2080``80` | SugarCRM 6.5.26 CE Web + API |
| `db` | `mysql:5.7` | `3306` | MySQL Datenbank |
## ⚙️ Konfiguration
### Umgebungsvariablen (`.env`)
| Variable | Default | Beschreibung |
|----------|---------|-------------|
| `SUGARCRM_PORT` | `2080` | Web-UI Port |
| `MYSQL_PORT` | `3306` | MySQL Port |
| `MYSQL_ROOT_PASSWORD` | `change_this…` | **Sofort ändern!** |
| `MYSQL_DATABASE` | `sugarcrm` | Datenbank-Name |
| `MYSQL_USER` | `sugarcrm` | DB-Nutzer |
| `MYSQL_PASSWORD` | `change_this…` | **Sofort ändern!** |
| `SUGARCRM_ADMIN_USER` | `admin` | Admin-Login |
| `SUGARCRM_ADMIN_PASSWORD` | `admin123` | Admin-Passwort |
> ⚠️ **Sicherheit**: `.env` vor erstem Start anpassen! Bei Änderung nach erstem Start: `docker compose down -v && docker compose up -d`
## 🔌 REST API v4.1
**Endpoint:** `POST http://localhost:2080/service/v4_1/rest.php`
**Content-Type:** `application/x-www-form-urlencoded`
### Aufbau
```
method=login
input_type=JSON
response_type=JSON
rest_data={"user_auth":{"user_name":"admin","password":"0192023a7bbd73250516f069df18b500"}}
```
### API Client (Python)
```python
import hashlib, json, urllib.request
pwd_hash = hashlib.md5(b"admin123").hexdigest()
rest_data = json.dumps({
"user_auth": {"user_name": "admin", "password": pwd_hash},
"application_name": "My App"
})
body = urllib.parse.urlencode({
"method": "login",
"input_type": "JSON",
"response_type": "JSON",
"rest_data": rest_data
}).encode()
req = urllib.request.Request(
"http://localhost:2080/service/v4_1/rest.php",
data=body,
headers={"Content-Type": "application/x-www-form-urlencoded"}
)
resp = json.loads(urllib.request.urlopen(req).read())
session_id = resp["id"]
print(f"Session: {session_id}")
```
### Verfügbare Methoden
| Methode | Beschreibung |
|---------|-------------|
| `login` | Session starten |
| `logout` | Session beenden |
| `get_available_modules` | Alle Module (Accounts, Contacts, Leads...) |
| `get_entry_list` | Einträge auslesen (mit Filter/Sortierung) |
| `get_entry` | Einzelnen Eintrag per ID |
| `set_entry` | Eintrag erstellen/aktualisieren |
| `set_entries` | Mehrere Einträge erstellen |
| `get_entries_count` | Anzahl Einträge zählen |
| `search_by_module` | Globale Suche |
| `get_module_fields` | Felddefinitionen eines Moduls |
| `set_relationship` | Beziehungen verknüpfen |
| `get_relationships` | Beziehungen auslesen |
## 🛠️ Kommandos
```bash
# Start/Stop
docker compose up -d # Starten
docker compose down # Stoppen (Daten bleiben)
docker compose down -v # Stoppen + ALLE DATEN LÖSCHEN
# Logs
docker compose logs -f sugarcrm # SugarCRM-Logs
docker compose logs db # MySQL-Logs
# Shell
docker compose exec sugarcrm bash # Container-Shell
# Backup
docker compose exec db mysqldump -u sugarcrm -p sugarcrm > backup.sql
```
## 🔧 CI/CD
Bei jedem Push auf `main` baut Gitea Actions automatisch:
1. Docker-Image aus `Dockerfile`
2. Push in die Gitea Container Registry: `git.kgessner.de/luiicode/sugar-crm`
Secrets erforderlich: `REGISTRY_USER`, `REGISTRY_TOKEN` (bereits gesetzt).
## ⚠️ Technische Pitfalls
| Problem | Fix |
|---------|-----|
| SourceForge ZIPs korrupt | GitHub Mirror `bklein01/sugarcrm` verwendet |
| Debian Jessie EOL | APT sources auf `archive.debian.org` umgebogen |
| Admin Wizard blockiert API | `installer_locked=true` + adminwizard DB-Eintrag (init.sh) |
| config.php wird überschrieben | init.sh macht idempotenten Restart |
| Kein mysqladmin im Container | PHP-Socket-Check für DB-Wait-Loop |
## 📋 Systemanforderungen
- Docker 20.10+
- Docker Compose v2
- ~500 MB RAM (Apache + MySQL)
- Ports `2080` und `3306` verfügbar
---
**SugarCRM 6.5.26 CE** | PHP 5.6 | MySQL 5.7 | REST v4.1 | AGPLv3