Initial commit: Infrastructure Git CI/CD avec Gitea, Woodpecker, PostgreSQL, Consul et Registrator

This commit is contained in:
2025-12-23 20:11:09 +01:00
commit de02fb28ca
20 changed files with 2685 additions and 0 deletions

99
docs/01-architecture.md Normal file
View File

@ -0,0 +1,99 @@
# Architecture de l'infrastructure Git CI/CD
## Vue d'ensemble
Cette infrastructure fournit une solution complete de gestion de code source et d'integration continue.
```
+------------------+
| Utilisateurs |
+--------+---------+
|
+--------------+--------------+
| |
v v
+-------------------+ +-------------------+
| git.syoul.fr | | ci.syoul.fr |
| (Gitea :3300) | | (Woodpecker:9001)|
+--------+----------+ +--------+----------+
| |
| +---------------------+ |
+-->| Consul :8500 |<--+
| Service Discovery |
+----------+----------+
|
+----------+----------+
| Registrator |
| (auto-registration) |
+---------------------+
|
+-------------+-------------+
| |
+---------+---------+ +---------+---------+
| PostgreSQL | | Woodpecker |
| (gitea_db) | | Agent |
+-------------------+ +-------------------+
```
## Composants
### Services principaux
| Service | Port externe | Port interne | Description |
|---------|--------------|--------------|-------------|
| Gitea | 3300 | 3000 | Serveur Git auto-heberge |
| Gitea SSH | 2222 | 22 | Acces SSH pour Git |
| Woodpecker Server | 9001 | 8000 | Serveur CI/CD |
| Woodpecker Agent | - | 3000 | Agent d'execution des pipelines |
| PostgreSQL | - | 5432 | Base de donnees Gitea |
| Consul | 8500 | 8500 | Service discovery et UI |
| Consul DNS | 8600 | 8600 | Resolution DNS des services |
| Registrator | - | - | Enregistrement automatique |
### Reseau Docker
Tous les services utilisent le reseau Docker : `gitgit_syoul_fr_gitea_net`
- Sous-reseau : `172.18.0.0/16`
- Gateway : `172.18.0.1`
### Volumes persistants
| Volume | Service | Chemin dans le conteneur |
|--------|---------|--------------------------|
| `gitgit_syoul_fr_gitea_data` | Gitea | `/data` |
| `gitgit_syoul_fr_db_data` | PostgreSQL | `/var/lib/postgresql/data` |
| `woodpecker-data` | Woodpecker Server | `/var/lib/woodpecker` |
| `consul-data` | Consul | `/consul/data` |
## Flux de communication
### Authentification OAuth2 (Woodpecker <-> Gitea)
1. Utilisateur accede a `ci.syoul.fr`
2. Woodpecker redirige vers `git.syoul.fr/login/oauth/authorize`
3. Utilisateur s'authentifie sur Gitea
4. Gitea redirige vers `ci.syoul.fr/authorize` avec le code
5. Woodpecker echange le code contre un token via `gitea:3000`
### Communication interne (avec Consul)
1. Registrator detecte les nouveaux conteneurs
2. Registrator enregistre les services dans Consul
3. Les services peuvent se trouver via DNS Consul : `gitea.service.consul`
### Webhooks CI/CD
1. Commit sur Gitea
2. Gitea envoie un webhook a Woodpecker
3. Woodpecker Server planifie le build
4. Woodpecker Agent execute le pipeline
5. Resultats affiches dans Gitea et Woodpecker
## URLs d'acces
| Service | URL |
|---------|-----|
| Gitea | http://git.syoul.fr |
| Woodpecker | https://ci.syoul.fr |
| Consul UI | http://[serveur]:8500 |