176 lines
4.9 KiB
Markdown
176 lines
4.9 KiB
Markdown
# Développement Veza sur R720 (Remote-SSH)
|
||
|
||
Guide pour développer Veza sur le serveur Dell PowerEdge R720 depuis un laptop via Cursor Remote-SSH. Le laptop devient un terminal léger ; tout le compute (Docker, tests, builds) tourne sur le R720.
|
||
|
||
## Prérequis
|
||
|
||
- R720 initialisé selon le guide (Debian 13, WireGuard, nftables, Suricata, Incus)
|
||
- Cursor installé sur le laptop
|
||
- Connexion SSH vers le R720 (`Host r720` dans `~/.ssh/config`)
|
||
|
||
## Phase 1 — Installation sur le R720
|
||
|
||
### 1.1 Docker
|
||
|
||
```bash
|
||
# Sur le R720 (en SSH)
|
||
sudo apt update && sudo apt install -y docker.io docker-compose-plugin
|
||
sudo usermod -aG docker senke
|
||
# Reconnecter pour activer le groupe : exit && ssh r720
|
||
```
|
||
|
||
### 1.2 Outils de développement
|
||
|
||
- **Node.js** (20+) : `nvm` ou `sudo apt install nodejs npm`
|
||
- **Go** (1.22+) : `sudo apt install golang-go` ou [go.dev/dl](https://go.dev/dl)
|
||
- **Rust** : `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
|
||
- **Optionnel** : `air` (hot reload Go), `cargo-watch` (hot reload Rust)
|
||
|
||
### 1.3 Cloner le projet
|
||
|
||
```bash
|
||
mkdir -p ~/git
|
||
cd ~/git
|
||
git clone <url-du-repo> veza
|
||
cd veza
|
||
```
|
||
|
||
## Phase 2 — Configuration des variables d'environnement
|
||
|
||
### 2.1 Racine du projet
|
||
|
||
```bash
|
||
cp env.remote-r720.example .env
|
||
```
|
||
|
||
Le fichier `env.remote-r720.example` contient `APP_DOMAIN=localhost` et les URLs localhost pour le port forwarding Cursor.
|
||
|
||
### 2.2 Frontend (apps/web)
|
||
|
||
```bash
|
||
cp apps/web/env.remote-r720.example apps/web/.env
|
||
# ou apps/web/.env.local
|
||
```
|
||
|
||
### 2.3 Backend (veza-backend-api)
|
||
|
||
Le backend charge son `.env` depuis `veza-backend-api/`. Créez-le avec les mêmes valeurs :
|
||
|
||
```bash
|
||
cat > veza-backend-api/.env << 'EOF'
|
||
APP_DOMAIN=localhost
|
||
DATABASE_URL=postgres://veza:devpassword@localhost:15432/veza?sslmode=disable
|
||
REDIS_URL=redis://localhost:16379
|
||
RABBITMQ_URL=amqp://veza:devpassword@localhost:15672/
|
||
CORS_ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000
|
||
JWT_SECRET=dev-secret-key-minimum-32-characters-long
|
||
EOF
|
||
```
|
||
|
||
### 2.4 Stream server (veza-stream-server)
|
||
|
||
Si vous lancez le stream server en local, créez `veza-stream-server/.env` avec :
|
||
|
||
```
|
||
DATABASE_URL=postgres://veza:devpassword@localhost:15432/veza?sslmode=disable
|
||
REDIS_URL=redis://localhost:16379
|
||
```
|
||
|
||
## Phase 3 — Connexion Cursor Remote-SSH
|
||
|
||
### 3.1 SSH config (laptop)
|
||
|
||
Vérifiez `~/.ssh/config` :
|
||
|
||
```
|
||
Host r720
|
||
HostName 192.168.0.102
|
||
User senke
|
||
IdentityFile ~/.ssh/r720
|
||
ServerAliveInterval 60
|
||
```
|
||
|
||
### 3.2 Accès distant (hors LAN)
|
||
|
||
- **Sur le LAN** : SSH vers `192.168.0.102`
|
||
- **Hors LAN** : activez WireGuard sur le laptop, puis SSH. Si le VPN ne route pas `192.168.0.0/24`, ajoutez cette plage dans `AllowedIPs` du client WireGuard.
|
||
|
||
### 3.3 Connexion Cursor
|
||
|
||
1. `Ctrl+Shift+P` → "Remote-SSH: Connect to Host"
|
||
2. Choisir `r720`
|
||
3. Ouvrir le dossier `/home/senke/git/veza` (ou le chemin réel du clone)
|
||
|
||
## Phase 4 — Workflow de développement
|
||
|
||
### 4.1 Démarrage
|
||
|
||
```bash
|
||
# 1. Infra Docker (postgres, redis, rabbitmq, clamav, minio)
|
||
make infra-up-dev
|
||
|
||
# 2. Migrations (si nécessaire)
|
||
make db-migrate
|
||
|
||
# 3. Lancer le dev complet (backend + stream + web avec hot reload)
|
||
make dev-full
|
||
```
|
||
|
||
Ou par service :
|
||
|
||
```bash
|
||
make infra-up-dev
|
||
make dev-web # frontend seul
|
||
make dev-backend-api # backend Go seul
|
||
make dev-stream-server # stream Rust seul
|
||
```
|
||
|
||
### 4.2 Port forwarding Cursor
|
||
|
||
Cursor détecte généralement les serveurs (Vite, etc.) et propose le forwarding. Sinon, vérifiez l’onglet **Ports** :
|
||
|
||
| Port | Service |
|
||
|-------|--------------|
|
||
| 5173 | Vite (web) |
|
||
| 18080 | Backend API |
|
||
| 18082 | Stream |
|
||
| 15432 | PostgreSQL |
|
||
| 16379 | Redis |
|
||
| 25672 | RabbitMQ UI |
|
||
| 6006 | Storybook |
|
||
|
||
### 4.3 Accès depuis le laptop
|
||
|
||
- Frontend : http://localhost:5173
|
||
- API : http://localhost:18080
|
||
- RabbitMQ UI : http://localhost:25672
|
||
|
||
## Phase 5 — Tests
|
||
|
||
```bash
|
||
# Tous les tests (infra doit être up pour les tests backend)
|
||
make test
|
||
|
||
# Par service
|
||
make test-backend-api
|
||
make test-stream-server
|
||
make test-web
|
||
```
|
||
|
||
## Points d’attention
|
||
|
||
1. **`/etc/hosts`** : Avec `APP_DOMAIN=localhost`, pas besoin de `veza.fr` dans `/etc/hosts` pour le dev remote.
|
||
2. **Storybook** : `npm run storybook` dans `apps/web` ; forwarder le port 6006.
|
||
3. **Performances** : Édition et indexation via SSH peuvent être plus lentes ; un lien réseau stable (LAN ou VPN) est important.
|
||
4. **Incus vs Docker** : Docker pour le dev (postgres, redis, etc.) ; Incus reste pour la prod (veza-api, veza-front, etc. dans net-veza).
|
||
|
||
## Ordre d’exécution recommandé
|
||
|
||
1. Installer Docker + outils (Node, Go, Rust) sur le R720
|
||
2. Cloner le repo dans `~/git/veza`
|
||
3. Créer les `.env` : `cp env.remote-r720.example .env` et `cp apps/web/env.remote-r720.example apps/web/.env`
|
||
4. Créer `veza-backend-api/.env` (voir Phase 2.3)
|
||
5. Tester : `make infra-up-dev` puis `make dev-web`
|
||
6. Se connecter en Remote-SSH avec Cursor et ouvrir le dossier
|
||
7. Vérifier le port forwarding et l’accès à http://localhost:5173
|
||
8. Lancer `make dev-full` et valider le flux complet
|