# Installation d'une interface web Git sur chillka ## Objectif Installer GitLab pour gérer et visualiser les dépôts Git sur chillka, notamment pour le projet `config-files-keyvault`. ## Choix : GitLab - **Avantages** : Très complet (CI/CD, issues, merge requests, wiki, etc.), interface moderne - **Inconvénients** : Lourd (2-4GB RAM minimum), installation plus complexe - **Ressources** : 2-4GB RAM, 4GB+ espace disque ## Prérequis sur chillka - Accès SSH en tant que `toshiro` - Permissions sudo - **Minimum 4GB RAM disponible** - **Minimum 4GB espace disque libre** - Serveur web (Apache) - optionnel mais recommandé - Certificat SSL (Let's Encrypt) - pour HTTPS ## Options d'installation ### Option A : Installation Omnibus (Recommandé - Plus simple) L'installation Omnibus de GitLab est la méthode la plus simple et recommandée. Elle installe tout ce qui est nécessaire (PostgreSQL, Redis, etc.). ### Option B : Installation via Docker Pour une installation plus isolée et facile à maintenir. ## Installation Omnibus (Recommandé) ### Étape 1 : Prérequis système ```bash # Se connecter à chillka ssh toshiro@chillka # Mettre à jour le système sudo apt update && sudo apt upgrade -y # Installer les dépendances sudo apt install -y curl openssh-server ca-certificates tzdata perl ``` ### Étape 2 : Installation de GitLab ```bash # Ajouter le dépôt GitLab curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash # Installer GitLab CE (Community Edition) sudo EXTERNAL_URL="http://chillka" apt install gitlab-ce # OU avec un domaine personnalisé sudo EXTERNAL_URL="https://chillka.example.com" apt install gitlab-ce ``` **Note** : L'installation peut prendre 10-15 minutes. ### Étape 3 : Configuration initiale ```bash # Reconfigurer GitLab (si nécessaire) sudo gitlab-ctl reconfigure # Vérifier le statut sudo gitlab-ctl status ``` ### Étape 4 : Accès initial 1. Ouvrir `http://chillka` dans un navigateur 2. Vous serez redirigé pour définir le mot de passe root 3. Se connecter avec : - **Username** : `root` - **Password** : (celui que vous venez de définir) ### Étape 5 : Configuration du dépôt existant ```bash # Sur chillka, configurer GitLab pour utiliser le répertoire existant sudo nano /etc/gitlab/gitlab.rb ``` Ajouter/modifier : ```ruby # Chemin des dépôts Git git_data_dirs({ "default" => { "path" => "/var/data/git/repositories" } }) # OU si vous voulez que GitLab gère ses propres dépôts # git_data_dirs({"default" => {"path" => "/var/opt/gitlab/git-data"}}) ``` Puis reconfigurer : ```bash sudo gitlab-ctl reconfigure sudo gitlab-ctl restart ``` ### Étape 6 : Importer le dépôt existant 1. Se connecter à GitLab (http://chillka) 2. Créer un nouveau projet : `config-files-keyvault` 3. **OU** importer le dépôt existant : - Aller dans "New Project" > "Import project" - Choisir "Repository by URL" - URL : `file:///var/data/git/repositories/config-files-keyvault.git` ## Installation Docker (Alternative) ### Étape 1 : Prérequis ```bash # Installer Docker si pas déjà installé curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh # Installer Docker Compose sudo apt install docker-compose -y ``` ### Étape 2 : Créer docker-compose.yml Voir le fichier `docker-compose-gitlab.yml` dans ce dossier. ### Étape 3 : Démarrer GitLab ```bash cd ~/gitlab docker-compose up -d ``` **Note** : Le premier démarrage peut prendre 5-10 minutes. ### Étape 4 : Accès - Ouvrir `http://chillka:8929` (port configuré dans docker-compose) - Définir le mot de passe root ## Configuration Apache (Reverse Proxy) Pour accéder via un domaine et HTTPS : ### Étape 1 : Installer Apache et les modules nécessaires ```bash sudo apt install -y apache2 sudo a2enmod proxy sudo a2enmod proxy_http sudo a2enmod headers sudo a2enmod ssl sudo systemctl restart apache2 ``` ### Étape 2 : Configuration Apache ```bash sudo nano /etc/apache2/sites-available/gitlab.conf ``` Contenu : ```apache ServerName chillka.example.com # Remplacer par votre domaine # Redirection vers HTTPS (décommenter après configuration SSL) # Redirect permanent / https://chillka.example.com/ ProxyPreserveHost On ProxyRequests off Require all granted ProxyPass / http://127.0.0.1:80/ ProxyPassReverse / http://127.0.0.1:80/ # Headers pour GitLab RequestHeader set X-Forwarded-Proto "http" RequestHeader set X-Forwarded-Ssl "off" # Configuration HTTPS (décommenter après configuration SSL) # # ServerName chillka.example.com # # SSLEngine on # SSLCertificateFile /etc/letsencrypt/live/chillka.example.com/fullchain.pem # SSLCertificateKeyFile /etc/letsencrypt/live/chillka.example.com/privkey.pem # # ProxyPreserveHost On # ProxyRequests off # # # Require all granted # # # ProxyPass / http://127.0.0.1:80/ # ProxyPassReverse / http://127.0.0.1:80/ # # RequestHeader set X-Forwarded-Proto "https" # RequestHeader set X-Forwarded-Ssl "on" # ``` ### Étape 3 : Activer le site ```bash sudo a2ensite gitlab.conf sudo a2dissite 000-default.conf # Désactiver le site par défaut si nécessaire sudo apache2ctl configtest sudo systemctl reload apache2 ``` ### Étape 4 : Configurer SSL avec Let's Encrypt ```bash sudo apt install certbot python3-certbot-apache sudo certbot --apache -d chillka.example.com ``` Certbot configurera automatiquement Apache pour HTTPS. ## Intégration avec le dépôt existant ### Option 1 : Importer le dépôt dans GitLab 1. Se connecter à GitLab 2. Créer un nouveau projet 3. Importer depuis l'URL locale : `file:///var/data/git/repositories/config-files-keyvault.git` ### Option 2 : Lier le dépôt existant ```bash # Sur chillka, créer un lien symbolique sudo ln -s /var/data/git/repositories/config-files-keyvault.git \ /var/opt/gitlab/git-data/repositories/@hashed/.../config-files-keyvault.git ``` **Note** : Cette méthode est plus complexe. Il est recommandé d'importer le dépôt. ## Mise à jour du remote local Après avoir créé/importé le dépôt dans GitLab : ```bash # Sur votre machine Windows cd E:\Dev\System\config-files-keyvault # Avec HTTPS git remote set-url origin http://chillka/root/config-files-keyvault.git # OU avec SSH (recommandé) git remote set-url origin git@chillka:root/config-files-keyvault.git ``` ## Commandes utiles GitLab ```bash # Voir le statut de GitLab sudo gitlab-ctl status # Voir les logs sudo gitlab-ctl tail # Redémarrer GitLab sudo gitlab-ctl restart # Reconfigurer GitLab sudo gitlab-ctl reconfigure # Vérifier la configuration sudo gitlab-rake gitlab:check # Sauvegarder GitLab sudo gitlab-backup create ``` ## Configuration recommandée ### Réduire l'utilisation mémoire (si nécessaire) Éditer `/etc/gitlab/gitlab.rb` : ```ruby # Réduire les workers puma['worker_processes'] = 2 sidekiq['max_concurrency'] = 5 # Réduire la mémoire PostgreSQL postgresql['shared_buffers'] = "256MB" postgresql['max_connections'] = 50 ``` Puis : ```bash sudo gitlab-ctl reconfigure sudo gitlab-ctl restart ``` ## Accès - **Interface web** : `http://chillka` ou `https://chillka.example.com` - **SSH** : `git@chillka:root/config-files-keyvault.git` - **HTTPS** : `http://chillka/root/config-files-keyvault.git` ## Notes importantes - GitLab nécessite **minimum 2GB RAM** (4GB recommandé) - L'installation Omnibus installe PostgreSQL, Redis, et tous les services nécessaires - Les sauvegardes sont importantes : `sudo gitlab-backup create` - La première configuration peut prendre du temps - GitLab utilise beaucoup de ressources, surveillez l'utilisation ## Troubleshooting ### GitLab ne démarre pas ```bash # Vérifier les logs sudo gitlab-ctl tail # Vérifier les erreurs spécifiques sudo gitlab-ctl status ``` ### Problème de mémoire ```bash # Vérifier l'utilisation mémoire free -h # Réduire la configuration (voir section Configuration recommandée) ``` ### Problème avec les dépôts existants ```bash # Vérifier les permissions sudo chown -R git:git /var/data/git/repositories # Vérifier la configuration sudo gitlab-rake gitlab:check ```