summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorexatombe <jeremy27.clara22@gmail.com>2025-11-03 00:01:52 +0100
committerexatombe <jeremy27.clara22@gmail.com>2025-11-03 00:01:52 +0100
commitf232228974b12b1c2b5b07718532eec26a88841d (patch)
tree2fc8127e5248c59ff6596bfafcda30965d3e7dc5
parent549a8b6b8c97c357495c9df198c21e940f56b6a5 (diff)
feat: ajouter la configuration de l'utilisateur super et améliorer la gestion de la configuration
-rw-r--r--.dockerignore4
-rw-r--r--Dockerfile8
-rw-r--r--Makefile44
-rw-r--r--README.md267
-rw-r--r--cmd/server/main.go11
-rw-r--r--config.example.yaml32
-rw-r--r--config.yaml9
-rw-r--r--docker-compose.yml21
-rw-r--r--internal/config/config.go19
9 files changed, 375 insertions, 40 deletions
diff --git a/.dockerignore b/.dockerignore
index 5509e3c..929b30e 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -12,6 +12,10 @@ README.md
docs/
LICENSE
+# Configuration (should be mounted as volume)
+config.yaml
+config.*.yaml
+
# Development
.devenv
.direnv
diff --git a/Dockerfile b/Dockerfile
index cdd456f..1f19a96 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -38,12 +38,6 @@ COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
# Copy binary
COPY --from=builder /build/sovrabase /sovrabase
-
-# Copy config file
-COPY --from=builder /build/config.yaml /config.yaml
-
-# Expose gRPC port (adjust based on your config)
-EXPOSE 50051
-
# Run the application
+# The config file must be provided via volume mount at /config/config.yaml
ENTRYPOINT ["/sovrabase"]
diff --git a/Makefile b/Makefile
index e558582..75def23 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: build run test clean proto
+.PHONY: build run test clean proto docker-build docker-run docker-stop docker-clean docker-logs
build:
go build -o bin/server ./cmd/server
@@ -9,12 +9,52 @@ run:
test:
go test ./...
+test-orchestrator:
+ go test ./internal/orchestrator -v
+
proto:
protoc \
--go_out=pkg --go_opt=paths=source_relative \
--go-grpc_out=pkg --go-grpc_opt=paths=source_relative \
proto/*.proto
-
clean:
rm -rf bin/
+
+# Docker commands
+docker-build:
+ docker build -t sovrabase:latest .
+
+docker-run:
+ docker compose up -d
+
+docker-stop:
+ docker compose stop
+
+docker-down:
+ docker compose down
+
+docker-clean:
+ docker compose down -v
+ docker rmi sovrabase:latest || true
+
+docker-logs:
+ docker compose logs -f sovrabase
+
+docker-shell:
+ docker compose exec sovrabase sh
+
+# Setup config from example
+setup-config:
+ @if [ ! -f config.yaml ]; then \
+ cp config.example.yaml config.yaml; \
+ echo "✅ config.yaml created from example. Please edit it before running!"; \
+ else \
+ echo "⚠️ config.yaml already exists"; \
+ fi
+
+# Quick start (setup + build + run)
+start: setup-config docker-build docker-run
+ @echo "🚀 Sovrabase is starting..."
+ @echo "📝 Check logs with: make docker-logs"
+ @echo "🔍 Health check: curl http://localhost:8080/health"
diff --git a/README.md b/README.md
index 6aca575..b5c6a15 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,51 @@
# Sovrabase
-> Une plateforme Backend-as-a-Service (BaaS) open source, souveraine et composable — conçue pour reprendre le contrôle de votre infrastructure.
+> Une plateforme Backend-as-a-Service (BaaS) open source, souveraine et composable.
[![License](https://img.shields.io/badge/license-AGPLv3-blue.svg)](LICENSE)
-[![Go Version](https://img.shields.io/badge/go-1.25.2-00ADD8.svg)](https://go.dev/)
-
----
## 🎯 Vision
-**Sovrabase** est une alternative moderne et souveraine aux plateformes BaaS existantes (Firebase, Supabase, Appwrite). Elle répond aux besoins des entreprises et développeurs qui cherchent :
+Sovrabase est une alternative souveraine à Firebase/Supabase : contrôle total, multi-tenant, multi-région, et extensible.
-- **L'indépendance technologique** : aucun vendor lock-in, aucune dépendance à Google Cloud ou AWS
-- **La souveraineté des données** : hébergement on-premises ou cloud privé (RGPD-friendly)
-- **La flexibilité architecturale** : infrastructure modulaire et composable
-- **La scalabilité multi-région** : distribution géographique native des données
-- **La transparence totale** : open source, auditable, gouvernance claire
+## 🚀 Quick Start
----
+```bash
+git clone https://github.com/ketsuna-org/sovrabase.git
+cd sovrabase
+cp config.example.yaml config.yaml # Éditez config.yaml
+docker compose up -d
+curl http://localhost:8080/health
+```
+
+Voir [docs/config.md](docs/config.md) pour la config détaillée.
+
+## 📦 Fonctionnalités principales
+
+- Authentication & Authorization
+- Database Management (PostgreSQL, MongoDB)
+- Storage S3-compatible
+- Real-time (WebSocket)
+- Multi-tenancy & Multi-region
+- RBAC avancé
+
+## 🛠️ Technologies
+
+- Backend : Go 1.25+
+- Infra : Docker, Kubernetes-ready
+- DB : PostgreSQL, MongoDB, Redis
+
+## 🚧 Statut
+
+En développement. Roadmap : [Phase 1-4 détaillée dans docs](docs/ROADMAP.md).
+
+## 🤝 Contribution
+
+Fork, branche, commit, PR. Voir [CONTRIBUTING.md](CONTRIBUTING.md).
+
+## 📄 Licence
+
+AGPLv3.
## 🚀 Pourquoi Sovrabase ?
@@ -116,7 +144,222 @@ Sovrabase est conçu pour les entreprises exigeantes en matière de conformité
---
-## 🚧 Statut du projet
+## 🐳 Installation et Déploiement avec Docker
+
+Sovrabase utilise Docker pour orchestrer les bases de données des projets. L'application elle-même s'exécute dans un conteneur et a besoin d'accéder au daemon Docker de l'hôte.
+
+### 🚀 Quick Start
+
+```bash
+# 1. Cloner le repository
+git clone https://github.com/ketsuna-org/sovrabase.git
+cd sovrabase
+
+# 2. Créer votre fichier de configuration
+cp config.example.yaml config.yaml
+# Éditez config.yaml avec vos paramètres (notamment le JWT secret!)
+
+# 3. Démarrer avec Docker Compose
+docker compose up -d
+
+# 4. Vérifier que tout fonctionne
+curl http://localhost:8080/health
+```
+
+Ou utilisez le Makefile :
+
+```bash
+make start # Setup + build + run
+make docker-logs # Voir les logs
+make docker-stop # Arrêter
+```
+
+### Prérequis
+
+- Docker Engine 20.10+
+- Un fichier `config.yaml` configuré (voir [docs/config.md](docs/config.md))
+
+### Configuration requise
+
+Sovrabase nécessite **deux volumes montés** pour fonctionner correctement :
+
+#### 1. Fichier de configuration : `config.yaml`
+
+Montage : `./config.yaml:/config/config.yaml:ro`
+
+Ce fichier contient toute la configuration de Sovrabase :
+- Le type d'orchestrateur (Docker)
+- Les informations de connexion
+- Les paramètres de l'API et CORS
+- La configuration JWT
+- La base de données interne (SQLite, PostgreSQL, MySQL)
+
+**Exemple de `config.yaml` minimal :**
+
+```yaml
+api:
+ host: "0.0.0.0"
+ port: 8080
+ cors:
+ allowed_origins:
+ - "http://localhost:3000"
+
+jwt:
+ secret: "votre-secret-jwt-tres-securise"
+ expiration: "24h"
+
+orchestrator:
+ type: "docker"
+ docker_host: "unix:///var/run/docker.sock"
+
+database:
+ type: "sqlite"
+ connection_string: "/data/sovrabase.db"
+```
+
+#### 2. Socket Docker
+
+Montage : `/var/run/docker.sock:/var/run/docker.sock`
+
+Ce volume permet à Sovrabase de communiquer avec le daemon Docker de l'hôte pour :
+- Créer des conteneurs PostgreSQL pour chaque projet
+- Gérer le cycle de vie des bases de données
+- Lister et inspecter les conteneurs existants
+
+#### 3. Volume de données (si SQLite)
+
+Montage : `sovrabase-data:/data` (volume nommé Docker)
+
+Si vous utilisez SQLite comme base de données interne, ce volume persiste les données :
+- Survit à la suppression du conteneur
+- Permet les mises à jour sans perte de données
+- Stocke la base SQLite (`/data/sovrabase.db`)
+
+> **Note** : Si vous utilisez PostgreSQL ou MySQL comme base interne, ce volume n'est pas nécessaire.
+
+### Lancement avec Docker
+
+```bash
+# Créer un réseau Docker (optionnel mais recommandé)
+docker network create sovrabase-network
+
+# Créer un volume pour SQLite
+docker volume create sovrabase-data
+
+# Lancer Sovrabase
+docker run -d \
+ --name sovrabase \
+ --network sovrabase-network \
+ -p 8080:8080 \
+ -v $(pwd)/config.yaml:/config/config.yaml:ro \
+ -v /var/run/docker.sock:/var/run/docker.sock \
+ -v sovrabase-data:/data \
+ -e CONFIG_PATH=/config/config.yaml \
+ ghcr.io/ketsuna-org/sovrabase:latest
+```
+
+### Lancement avec Docker Compose
+
+Créez un fichier `docker-compose.yml` :
+
+```yaml
+version: '3.8'
+
+services:
+ sovrabase:
+ image: ghcr.io/ketsuna-org/sovrabase:latest
+ container_name: sovrabase
+ restart: unless-stopped
+ ports:
+ - "8080:8080"
+ volumes:
+ # Fichier de configuration (REQUIS)
+ - ./config.yaml:/config/config.yaml:ro
+ # Socket Docker pour l'orchestration (REQUIS)
+ - /var/run/docker.sock:/var/run/docker.sock
+ # Volume pour SQLite (si utilisé)
+ - sovrabase-data:/data
+ environment:
+ - CONFIG_PATH=/config/config.yaml
+ networks:
+ - sovrabase-network
+
+networks:
+ sovrabase-network:
+ driver: bridge
+
+volumes:
+ sovrabase-data:
+ driver: local
+```
+
+Puis lancez avec :
+
+```bash
+docker compose up -d
+```
+
+### ⚠️ Considérations de sécurité
+
+**Attention** : Monter le socket Docker (`/var/run/docker.sock`) donne au conteneur un accès privilégié au daemon Docker de l'hôte. Cela signifie que :
+
+- Le conteneur peut créer, modifier et supprimer d'autres conteneurs
+- Il a accès à tous les volumes et réseaux Docker
+- C'est équivalent à un accès root sur l'hôte
+
+**Recommandations** :
+
+1. **En production** : Utilisez un socket Docker avec des permissions restreintes ou un proxy Docker comme [docker-socket-proxy](https://github.com/Tecnativa/docker-socket-proxy)
+2. **Isolation réseau** : Utilisez des réseaux Docker dédiés
+3. **Firewall** : Limitez l'accès à l'API Sovrabase aux IPs autorisées
+4. **Monitoring** : Surveillez les actions Docker effectuées par Sovrabase
+
+### Build depuis les sources
+
+```bash
+# Cloner le repository
+git clone https://github.com/ketsuna-org/sovrabase.git
+cd sovrabase
+
+# Builder l'image Docker
+docker build -t sovrabase:local .
+
+# Lancer avec votre image locale
+docker run -d \
+ --name sovrabase \
+ -p 8080:8080 \
+ -v $(pwd)/config.yaml:/config/config.yaml:ro \
+ -v /var/run/docker.sock:/var/run/docker.sock \
+ sovrabase:local
+```
+
+### Vérification de l'installation
+
+Une fois Sovrabase lancé, vérifiez qu'il fonctionne :
+
+```bash
+# Health check
+curl http://localhost:8080/health
+
+# Devrait retourner : {"status":"ok"}
+```
+
+### Logs et debugging
+
+```bash
+# Voir les logs en temps réel
+docker logs -f sovrabase
+
+# Voir les dernières 100 lignes
+docker logs --tail 100 sovrabase
+
+# Inspecter le conteneur
+docker inspect sovrabase
+```
+
+---
+
+## �🚧 Statut du projet
**⚠️ En développement actif** — Sovrabase est actuellement en phase de conception et développement.
diff --git a/cmd/server/main.go b/cmd/server/main.go
index 91c1d75..870bd7c 100644
--- a/cmd/server/main.go
+++ b/cmd/server/main.go
@@ -3,6 +3,7 @@ package main
import (
"log"
"net/http"
+ "os"
mux "github.com/gorilla/mux"
"github.com/ketsuna-org/sovrabase/internal/config"
@@ -10,9 +11,15 @@ import (
)
func main() {
- cfg, err := config.LoadConfig("config.yaml")
+ // Get config path from environment variable or use default
+ configPath := os.Getenv("CONFIG_PATH")
+ if configPath == "" {
+ configPath = "config.yaml"
+ }
+
+ cfg, err := config.LoadConfig(configPath)
if err != nil {
- log.Fatalf("failed to load config: %v", err)
+ log.Fatalf("failed to load config from %s: %v", configPath, err)
}
// Setup HTTP Server
diff --git a/config.example.yaml b/config.example.yaml
new file mode 100644
index 0000000..a3a6dba
--- /dev/null
+++ b/config.example.yaml
@@ -0,0 +1,32 @@
+# Sovrabase Configuration Example
+# Copy this file to config.yaml and adjust the values
+
+# API Configuration
+api:
+ api_addr: "0.0.0.0:8080"
+ cors_allow:
+ - "http://localhost:3000"
+ - "https://example.com"
+ domain: "api.example.com"
+
+# Orchestrator Configuration
+orchestrator:
+ type: "docker"
+ docker_host: "unix:///var/run/docker.sock"
+ kube_api: "https://kubernetes.default.svc"
+ kube_token: "your-kubernetes-api-token"
+ namespace: "sovrabase-databases"
+
+# Internal Database Configuration
+internal_db:
+ manager: "sqlite"
+ uri: "/data/sovrabase.db"
+
+# Super User Configuration
+super_user:
+ username: "admin"
+ password: "CHANGE-THIS-TO-A-SECURE-PASSWORD"
+ email: "admin@example.com"
+
+# Region
+region: "eu-west-1"
diff --git a/config.yaml b/config.yaml
index 464f4dd..a5bef10 100644
--- a/config.yaml
+++ b/config.yaml
@@ -1,9 +1,5 @@
region: supabase
-rpc:
- rpc_secret: random_secret_12345
- rpc_addr: "[::]:8080"
-
api:
api_addr: "[::]:3000"
domain: api.example.com
@@ -30,3 +26,8 @@ orchestrator:
# kube_api: https://kubernetes.default.svc
# kube_token: your-kubernetes-api-token
# namespace: sovrabase-databases
+
+super_user:
+ username: "admin"
+ password: "CHANGE-THIS-TO-A-SECURE-PASSWORD"
+ email: "admin@example.com"
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..95c7ab6
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,21 @@
+version: '3.8'
+
+services:
+ sovrabase:
+ image: ghcr.io/ketsuna-org/sovrabase:latest
+ # Pour build local, décommentez :
+ # build:
+ # context: .
+ # dockerfile: Dockerfile
+ container_name: sovrabase
+ restart: unless-stopped
+ ports:
+ - "8080:8080"
+ volumes:
+ - ./config.yaml:/config.yaml:ro
+ - /var/run/docker.sock:/var/run/docker.sock
+ - sovrabase-data:/data
+
+volumes:
+ sovrabase-data:
+ driver: local
diff --git a/internal/config/config.go b/internal/config/config.go
index 4965a36..ce442a1 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -14,12 +14,6 @@ import (
_ "k8s.io/client-go/rest"
)
-// RPC holds RPC configuration
-type RPC struct {
- RPCSecret string `yaml:"rpc_secret"`
- RPCAddr string `yaml:"rpc_addr"`
-}
-
// API holds API configuration
type API struct {
APIAddr string `yaml:"api_addr"`
@@ -42,21 +36,20 @@ type Orchestrator struct {
Namespace string `yaml:"namespace"` // Kubernetes namespace for database deployments
}
-// Cluster holds cluster/distributed configuration
-type Cluster struct {
- NodeID string `yaml:"node_id"`
- IsRPCServer bool `yaml:"is_rpc_server"`
- RPCServers []string `yaml:"rpc_servers"`
+// SuperUser holds super user configuration
+type SuperUser struct {
+ Username string `yaml:"username"`
+ Password string `yaml:"password"`
+ Email string `yaml:"email"`
}
// Config holds the application configuration
type Config struct {
Region string
- RPC RPC
API API
InternalDB InternalDB
Orchestrator Orchestrator
- Cluster Cluster
+ SuperUser SuperUser
}
// LoadConfig loads configuration from a YAML file