feat(build): Scripts et configuration pour build production
- Ajout de scripts PowerShell et Bash pour build automatisé - Configuration pour connexion à l'API production (api.lions.dev/afterwork) - Documentation complète dans BUILD_CONFIG.md - Fichier .env.example pour référence - Support pour APK, App Bundle, iOS et Web
This commit is contained in:
293
BUILD_CONFIG.md
Normal file
293
BUILD_CONFIG.md
Normal file
@@ -0,0 +1,293 @@
|
||||
# Configuration de Build AfterWork
|
||||
|
||||
Ce document explique comment configurer et builder l'application AfterWork pour différents environnements.
|
||||
|
||||
## 📋 Table des matières
|
||||
|
||||
- [Environnements](#environnements)
|
||||
- [Configuration Rapide](#configuration-rapide)
|
||||
- [Scripts de Build](#scripts-de-build)
|
||||
- [Build Manuel](#build-manuel)
|
||||
- [Variables d'Environnement](#variables-denvironnement)
|
||||
|
||||
---
|
||||
|
||||
## 🌍 Environnements
|
||||
|
||||
### Development (par défaut)
|
||||
- **API URL** : `http://192.168.1.145:8080`
|
||||
- **Usage** : Développement local avec le backend sur le réseau local
|
||||
- **Debug** : Activé
|
||||
|
||||
### Production
|
||||
- **API URL** : `https://api.lions.dev/afterwork`
|
||||
- **Usage** : Déploiement en production
|
||||
- **Debug** : Désactivé
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Configuration Rapide
|
||||
|
||||
### Windows (PowerShell)
|
||||
|
||||
```powershell
|
||||
# Build APK de production
|
||||
.\scripts\build_production.ps1
|
||||
|
||||
# Build avec nettoyage préalable
|
||||
.\scripts\build_production.ps1 -Clean
|
||||
|
||||
# Build pour d'autres plateformes
|
||||
.\scripts\build_production.ps1 -Platform appbundle
|
||||
.\scripts\build_production.ps1 -Platform web
|
||||
```
|
||||
|
||||
### Linux/Mac (Bash)
|
||||
|
||||
```bash
|
||||
# Rendre le script exécutable
|
||||
chmod +x scripts/build_production.sh
|
||||
|
||||
# Build APK de production
|
||||
./scripts/build_production.sh
|
||||
|
||||
# Build avec nettoyage préalable
|
||||
./scripts/build_production.sh apk --clean
|
||||
|
||||
# Build pour d'autres plateformes
|
||||
./scripts/build_production.sh appbundle
|
||||
./scripts/build_production.sh web
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔨 Scripts de Build
|
||||
|
||||
### `build_production.ps1` / `build_production.sh`
|
||||
|
||||
Scripts automatisés pour builder l'application en production.
|
||||
|
||||
**Paramètres** :
|
||||
- `Platform` : `apk` (défaut), `appbundle`, `ios`, `web`
|
||||
- `--clean` / `-Clean` : Nettoie le projet avant le build
|
||||
|
||||
**Configuration automatique** :
|
||||
- ✅ API_BASE_URL = `https://api.lions.dev/afterwork`
|
||||
- ✅ ENVIRONMENT = `production`
|
||||
- ✅ Mode release activé
|
||||
|
||||
**Sortie** :
|
||||
- APK : `build/app/outputs/flutter-apk/app-release.apk`
|
||||
- App Bundle : `build/app/outputs/bundle/release/app-release.aab`
|
||||
- iOS : `build/ios/ipa/`
|
||||
- Web : `build/web/`
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Build Manuel
|
||||
|
||||
Si vous préférez builder manuellement sans les scripts :
|
||||
|
||||
### Android APK
|
||||
|
||||
```bash
|
||||
flutter build apk \
|
||||
--dart-define=API_BASE_URL=https://api.lions.dev/afterwork \
|
||||
--dart-define=ENVIRONMENT=production \
|
||||
--release
|
||||
```
|
||||
|
||||
### Android App Bundle (pour Google Play)
|
||||
|
||||
```bash
|
||||
flutter build appbundle \
|
||||
--dart-define=API_BASE_URL=https://api.lions.dev/afterwork \
|
||||
--dart-define=ENVIRONMENT=production \
|
||||
--release
|
||||
```
|
||||
|
||||
### iOS
|
||||
|
||||
```bash
|
||||
flutter build ios \
|
||||
--dart-define=API_BASE_URL=https://api.lions.dev/afterwork \
|
||||
--dart-define=ENVIRONMENT=production \
|
||||
--release
|
||||
```
|
||||
|
||||
### Web
|
||||
|
||||
```bash
|
||||
flutter build web \
|
||||
--dart-define=API_BASE_URL=https://api.lions.dev/afterwork \
|
||||
--dart-define=ENVIRONMENT=production \
|
||||
--release
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔑 Variables d'Environnement
|
||||
|
||||
### API_BASE_URL
|
||||
|
||||
URL de base de l'API backend.
|
||||
|
||||
- **Type** : String
|
||||
- **Requis** : Non (utilise la valeur par défaut si non défini)
|
||||
- **Défaut** : `http://192.168.1.145:8080` (développement)
|
||||
- **Production** : `https://api.lions.dev/afterwork`
|
||||
|
||||
**Exemple d'utilisation** :
|
||||
```dart
|
||||
import 'package:afterwork/core/constants/env_config.dart';
|
||||
|
||||
final apiUrl = EnvConfig.apiBaseUrl;
|
||||
// En prod: https://api.lions.dev/afterwork
|
||||
```
|
||||
|
||||
### ENVIRONMENT
|
||||
|
||||
Environnement d'exécution de l'application.
|
||||
|
||||
- **Type** : String
|
||||
- **Valeurs** : `development`, `staging`, `production`
|
||||
- **Défaut** : `development`
|
||||
|
||||
**Exemple d'utilisation** :
|
||||
```dart
|
||||
import 'package:afterwork/core/constants/env_config.dart';
|
||||
|
||||
if (EnvConfig.isProduction) {
|
||||
// Code spécifique à la production
|
||||
}
|
||||
```
|
||||
|
||||
### NETWORK_TIMEOUT
|
||||
|
||||
Timeout pour les requêtes réseau en secondes.
|
||||
|
||||
- **Type** : int
|
||||
- **Défaut** : 30
|
||||
- **Production** : 30 (recommandé)
|
||||
|
||||
### DEBUG_MODE
|
||||
|
||||
Active les logs détaillés et fonctionnalités de debug.
|
||||
|
||||
- **Type** : bool
|
||||
- **Défaut** : `true`
|
||||
- **Production** : Automatiquement `false` si `ENVIRONMENT=production`
|
||||
|
||||
### GOOGLE_MAPS_API_KEY
|
||||
|
||||
Clé API Google Maps (optionnelle).
|
||||
|
||||
- **Type** : String
|
||||
- **Requis** : Non
|
||||
- **Défaut** : vide
|
||||
|
||||
**Exemple** :
|
||||
```bash
|
||||
flutter build apk \
|
||||
--dart-define=API_BASE_URL=https://api.lions.dev/afterwork \
|
||||
--dart-define=GOOGLE_MAPS_API_KEY=votre_cle_api
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Endpoints de l'API Production
|
||||
|
||||
L'API production est accessible à l'adresse : **`https://api.lions.dev/afterwork`**
|
||||
|
||||
### Endpoints Principaux
|
||||
|
||||
| Endpoint | Description |
|
||||
|----------|-------------|
|
||||
| `/users` | Gestion des utilisateurs |
|
||||
| `/users/authenticate` | Authentification |
|
||||
| `/events` | Gestion des événements |
|
||||
| `/friends` | Gestion des amis |
|
||||
| `/messages` | Messagerie |
|
||||
| `/posts` | Posts sociaux |
|
||||
| `/stories` | Stories |
|
||||
| `/notifications` | Notifications |
|
||||
|
||||
### WebSockets
|
||||
|
||||
| Endpoint | Description |
|
||||
|----------|-------------|
|
||||
| `/chat/ws/{userId}` | Chat en temps réel |
|
||||
| `/notifications/ws/{userId}` | Notifications en temps réel |
|
||||
|
||||
**URL complète** :
|
||||
```
|
||||
wss://api.lions.dev/afterwork/chat/ws/{userId}
|
||||
wss://api.lions.dev/afterwork/notifications/ws/{userId}
|
||||
```
|
||||
|
||||
### Documentation API
|
||||
|
||||
Swagger UI disponible à :
|
||||
- **URL** : `https://api.lions.dev/afterwork/q/swagger-ui/`
|
||||
|
||||
---
|
||||
|
||||
## 📝 Vérification de la Configuration
|
||||
|
||||
Avant le déploiement, vérifiez que :
|
||||
|
||||
✅ L'API backend est accessible : `https://api.lions.dev/afterwork/users`
|
||||
✅ Les WebSockets fonctionnent
|
||||
✅ Les certificats TLS sont valides
|
||||
✅ Le CORS est correctement configuré
|
||||
✅ L'application se connecte avec succès à l'API
|
||||
|
||||
**Test rapide** :
|
||||
```bash
|
||||
# Tester l'API
|
||||
curl https://api.lions.dev/afterwork/users
|
||||
|
||||
# Devrait retourner: [] (liste vide si aucun utilisateur)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🐛 Dépannage
|
||||
|
||||
### Erreur : "API_BASE_URL is not set"
|
||||
|
||||
**Solution** : Vérifiez que vous utilisez `--dart-define=API_BASE_URL=...` lors du build.
|
||||
|
||||
### Erreur : "Connection refused"
|
||||
|
||||
**Solutions** :
|
||||
1. Vérifiez que l'API est accessible : `curl https://api.lions.dev/afterwork/users`
|
||||
2. Vérifiez votre connexion internet
|
||||
3. Vérifiez que le CORS est configuré sur le backend
|
||||
|
||||
### L'app se connecte au mauvais environnement
|
||||
|
||||
**Solution** : Reconstruisez complètement l'application avec le bon `--dart-define`.
|
||||
|
||||
```bash
|
||||
# Nettoyage complet
|
||||
flutter clean
|
||||
flutter pub get
|
||||
|
||||
# Rebuild avec la bonne configuration
|
||||
flutter build apk --dart-define=API_BASE_URL=https://api.lions.dev/afterwork
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📚 Ressources
|
||||
|
||||
- [Documentation Flutter](https://flutter.dev/docs)
|
||||
- [Flutter Build Modes](https://flutter.dev/docs/testing/build-modes)
|
||||
- [Environment Variables in Flutter](https://flutter.dev/docs/deployment/flavors)
|
||||
- [API Backend Repository](https://git.lions.dev/lionsdev/mic-after-work-server-impl-quarkus-main)
|
||||
|
||||
---
|
||||
|
||||
**Dernière mise à jour** : 2026-01-10
|
||||
**Version** : 1.0.0
|
||||
Reference in New Issue
Block a user