<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://wikibr.binets.fr/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Daniela.cojocaru</id>
	<title>WikiBR - Contributions [fr]</title>
	<link rel="self" type="application/atom+xml" href="https://wikibr.binets.fr/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Daniela.cojocaru"/>
	<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/Sp%C3%A9cial:Contributions/Daniela.cojocaru"/>
	<updated>2026-09-15T10:40:44Z</updated>
	<subtitle>Contributions</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10982</id>
		<title>Mettre en place SSH pour Gitlab/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10982"/>
		<updated>2026-08-11T11:52:34Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « {{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &amp;#039;&amp;#039;&amp;#039;DO NOT SHARE THE PRIVATE KEY&amp;#039;&amp;#039;&amp;#039;. It&amp;#039;s the &amp;#039;&amp;#039;&amp;#039;public key&amp;#039;&amp;#039;&amp;#039; which should be added to Gitlab. We cannot stress enough this point. All the security counts on the fact that the private key stays secret.}} »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
The aim of this guide is to help you set up a computer to use [[GitLab|GitLab]] with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on [[SSH]] and the BR’s [[Astuces_ssh|advanced tips]].&lt;br /&gt;
&lt;br /&gt;
The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide.&lt;br /&gt;
&lt;br /&gt;
The setup is relatively simple. Follow carefully the following steps.&lt;br /&gt;
= Prérequis =&lt;br /&gt;
&lt;br /&gt;
Before you start, make sure you have [[Git|git]] installed on your computer. To check this:&lt;br /&gt;
&lt;br /&gt;
* open a cmd or PowerShell terminal (press the Windows key + R, then type &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;);&lt;br /&gt;
* type &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; and check that Git is installed; if it isn’t, [https://git-scm.com/downloads install Git here];&lt;br /&gt;
* then type &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; to check that SSH is installed; if it isn’t, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse install OpenSSH here].&lt;br /&gt;
&lt;br /&gt;
= Mise en place =&lt;br /&gt;
&lt;br /&gt;
== Étape 1 : Générer une clé SSH ==&lt;br /&gt;
&lt;br /&gt;
Open a terminal (cmd or powershell) and type the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh-keygen -t ed25519 -C &amp;quot;ordi portable vaneau&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Replace &amp;lt;code&amp;gt;ordi portable vaneau&amp;lt;/code&amp;gt; with a name of your choice. You can leave the other fields empty by pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; for each option.&lt;br /&gt;
&lt;br /&gt;
Please note that there is an option to change the key’s name (by default &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) and the save location. There is also another option to add a passphrase to the key, which is recommended if your hard drive is not encrypted.&lt;br /&gt;
&lt;br /&gt;
{{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &#039;&#039;&#039;DO NOT SHARE THE PRIVATE KEY&#039;&#039;&#039;. It&#039;s the &#039;&#039;&#039;public key&#039;&#039;&#039; which should be added to Gitlab. We cannot stress enough this point. All the security counts on the fact that the private key stays secret.}}&lt;br /&gt;
&lt;br /&gt;
== Étape 2 : Ajouter la clé SSH sur Gitlab ==&lt;br /&gt;
&lt;br /&gt;
# Connecte-toi sur Gitlab avec tes identifiants Sigma BR ;&lt;br /&gt;
# Clique sur ton avatar en haut à gauche, puis sur &amp;lt;code&amp;gt;Preferences&amp;lt;/code&amp;gt;, puis sur &amp;lt;code&amp;gt;SSH Keys&amp;lt;/code&amp;gt; (ou va directement sur [https://gitlab.binets.fr/-/user_settings/ssh_keys cette page]) ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add new key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# Copie le contenu du fichier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519.pub&amp;lt;/code&amp;gt; (ou un autre chemin si tu as choisi un autre emplacement) en remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows et colle-le dans le champ &amp;lt;code&amp;gt;Key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# (optionnel) Supprime la date d’expiration de la clé si tu veux qu’elle reste valide indéfiniment ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add key&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Étape 3 : Préparer SSH pour utiliser la clé ==&lt;br /&gt;
&lt;br /&gt;
# Ouvre le dossier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh&amp;lt;/code&amp;gt; sur VSCode (ou ton éditeur de texte préféré) ;&lt;br /&gt;
# Crée un fichier &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; (&#039;&#039;&#039;sans extension&#039;&#039;&#039;) ;&lt;br /&gt;
# Ajoute le contenu suivant :&lt;br /&gt;
&lt;br /&gt;
 Host gitlab.binets.fr&lt;br /&gt;
   User git&lt;br /&gt;
   IdentityFile C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519&lt;br /&gt;
&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows.&lt;br /&gt;
&lt;br /&gt;
== Étape 4 : Activer l&#039;agent SSH ==&lt;br /&gt;
&lt;br /&gt;
Taper &amp;lt;code&amp;gt;ssh-add -L&amp;lt;/code&amp;gt;&lt;br /&gt;
* Si ta clef ssh est affichée, tout va bien, tu peux passer à l&#039;étape suivante&lt;br /&gt;
* Sinon, suit ces étapes :&lt;br /&gt;
&lt;br /&gt;
=== Sur windows ===&lt;br /&gt;
&lt;br /&gt;
# Aller dans la recherche windows et lancer &amp;lt;code&amp;gt;Services&amp;lt;/code&amp;gt;&lt;br /&gt;
# Chercher OpenSSH Authentification Agent&lt;br /&gt;
# Double cliquer dessus et mettre : &amp;lt;code&amp;gt;Type de démarrage : Automatique&amp;lt;/code&amp;gt;&lt;br /&gt;
# Appuyer sur démarrer&lt;br /&gt;
# Dans un terminal, faire &amp;lt;code&amp;gt;ssh-add&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sur Linux/Mac ===&lt;br /&gt;
&lt;br /&gt;
Voilà une solution un peu nulle qu&#039;il faudra refaire à chaque fois que tu redémarre ton ordi. Lance un terminal et tape :&lt;br /&gt;
&lt;br /&gt;
 eval `ssh-agent`&lt;br /&gt;
 ssh-add&lt;br /&gt;
&lt;br /&gt;
N&#039;hésite pas à trouver une meilleure solution et à l&#039;écrire ici.&lt;br /&gt;
&lt;br /&gt;
== Étape 5 : Tester la connexion SSH ==&lt;br /&gt;
&lt;br /&gt;
Pour tester la connexion SSH, ouvre un terminal et tape la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh -T gitlab.binets.fr&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Tu devrais voir un message comme ça :&lt;br /&gt;
&lt;br /&gt;
 The authenticity of host &#039;gitlab.binets.fr (129.104.201.46)&#039; can&#039;t be established.&lt;br /&gt;
 ED25519 key fingerprint is SHA256:sn+wsip9OTBcwiY0ZplULWXNij3v3kdj/tP228i2+70.&lt;br /&gt;
 Are you sure you want to continue connecting (yes/no/[fingerprint])?&lt;br /&gt;
&lt;br /&gt;
Écrit &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; puis appuie sur &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Si tout s’est bien passé, tu devrais voir un message de bienvenue de Gitlab. Dans le cas contraire, vérifie que tu as bien suivi toutes les étapes précédentes. Si tu rencontres des difficultés, n’hésite pas à demander de l’aide au Binet Réseau en permanence ou sur PaniX.&lt;br /&gt;
&lt;br /&gt;
== Étape 6 : Configurer l’identité Git ==&lt;br /&gt;
&lt;br /&gt;
Pour finir, il faut configurer correctement ton identité sur Git. Dans ton terminal, tape les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;git config --global user.name &amp;quot;&amp;lt;Ton Nom&amp;gt;&amp;quot;&lt;br /&gt;
git config --global user.email &amp;quot;&amp;lt;ton.nom&amp;gt;@polytechnique.edu&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;Ton Nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom et &amp;lt;code&amp;gt;&amp;amp;lt;ton.nom&amp;amp;gt;@polytechnique.edu&amp;lt;/code&amp;gt; par les valeurs adéquates.&lt;br /&gt;
&lt;br /&gt;
Félicitations ! À partir de là, tu peux utiliser Gitlab avec une authentification SSH.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lorsque tu clones un dépôt, veille bien à choisir le lien SSH et non HTTPS.&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/9/en&amp;diff=10981</id>
		<title>Translations:Mettre en place SSH pour Gitlab/9/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/9/en&amp;diff=10981"/>
		<updated>2026-08-11T11:52:30Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « {{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &amp;#039;&amp;#039;&amp;#039;DO NOT SHARE THE PRIVATE KEY&amp;#039;&amp;#039;&amp;#039;. It&amp;#039;s the &amp;#039;&amp;#039;&amp;#039;public key&amp;#039;&amp;#039;&amp;#039; which should be added to Gitlab. We cannot stress enough this point. All the security counts on the fact that the private key stays secret.}} »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &#039;&#039;&#039;DO NOT SHARE THE PRIVATE KEY&#039;&#039;&#039;. It&#039;s the &#039;&#039;&#039;public key&#039;&#039;&#039; which should be added to Gitlab. We cannot stress enough this point. All the security counts on the fact that the private key stays secret.}}&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10980</id>
		<title>Mettre en place SSH pour Gitlab/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10980"/>
		<updated>2026-08-11T11:50:45Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « Please note that there is an option to change the key’s name (by default &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) and the save location. There is also another option to add a passphrase to the key, which is recommended if your hard drive is not encrypted. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
The aim of this guide is to help you set up a computer to use [[GitLab|GitLab]] with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on [[SSH]] and the BR’s [[Astuces_ssh|advanced tips]].&lt;br /&gt;
&lt;br /&gt;
The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide.&lt;br /&gt;
&lt;br /&gt;
The setup is relatively simple. Follow carefully the following steps.&lt;br /&gt;
= Prérequis =&lt;br /&gt;
&lt;br /&gt;
Before you start, make sure you have [[Git|git]] installed on your computer. To check this:&lt;br /&gt;
&lt;br /&gt;
* open a cmd or PowerShell terminal (press the Windows key + R, then type &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;);&lt;br /&gt;
* type &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; and check that Git is installed; if it isn’t, [https://git-scm.com/downloads install Git here];&lt;br /&gt;
* then type &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; to check that SSH is installed; if it isn’t, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse install OpenSSH here].&lt;br /&gt;
&lt;br /&gt;
= Mise en place =&lt;br /&gt;
&lt;br /&gt;
== Étape 1 : Générer une clé SSH ==&lt;br /&gt;
&lt;br /&gt;
Open a terminal (cmd or powershell) and type the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh-keygen -t ed25519 -C &amp;quot;ordi portable vaneau&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Replace &amp;lt;code&amp;gt;ordi portable vaneau&amp;lt;/code&amp;gt; with a name of your choice. You can leave the other fields empty by pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; for each option.&lt;br /&gt;
&lt;br /&gt;
Please note that there is an option to change the key’s name (by default &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) and the save location. There is also another option to add a passphrase to the key, which is recommended if your hard drive is not encrypted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
{{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &#039;&#039;&#039;IL NE FAUT EN AUCUN CAS PARTAGER LA CLÉ PRIVÉE&#039;&#039;&#039;. C’est la &#039;&#039;&#039;clé publique&#039;&#039;&#039; qui doit être ajoutée sur Gitlab. On n’insistera jamais assez sur ce point. Toute la sécurité repose sur le fait que la clé privée reste secrète.}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Étape 2 : Ajouter la clé SSH sur Gitlab ==&lt;br /&gt;
&lt;br /&gt;
# Connecte-toi sur Gitlab avec tes identifiants Sigma BR ;&lt;br /&gt;
# Clique sur ton avatar en haut à gauche, puis sur &amp;lt;code&amp;gt;Preferences&amp;lt;/code&amp;gt;, puis sur &amp;lt;code&amp;gt;SSH Keys&amp;lt;/code&amp;gt; (ou va directement sur [https://gitlab.binets.fr/-/user_settings/ssh_keys cette page]) ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add new key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# Copie le contenu du fichier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519.pub&amp;lt;/code&amp;gt; (ou un autre chemin si tu as choisi un autre emplacement) en remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows et colle-le dans le champ &amp;lt;code&amp;gt;Key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# (optionnel) Supprime la date d’expiration de la clé si tu veux qu’elle reste valide indéfiniment ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add key&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Étape 3 : Préparer SSH pour utiliser la clé ==&lt;br /&gt;
&lt;br /&gt;
# Ouvre le dossier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh&amp;lt;/code&amp;gt; sur VSCode (ou ton éditeur de texte préféré) ;&lt;br /&gt;
# Crée un fichier &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; (&#039;&#039;&#039;sans extension&#039;&#039;&#039;) ;&lt;br /&gt;
# Ajoute le contenu suivant :&lt;br /&gt;
&lt;br /&gt;
 Host gitlab.binets.fr&lt;br /&gt;
   User git&lt;br /&gt;
   IdentityFile C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519&lt;br /&gt;
&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows.&lt;br /&gt;
&lt;br /&gt;
== Étape 4 : Activer l&#039;agent SSH ==&lt;br /&gt;
&lt;br /&gt;
Taper &amp;lt;code&amp;gt;ssh-add -L&amp;lt;/code&amp;gt;&lt;br /&gt;
* Si ta clef ssh est affichée, tout va bien, tu peux passer à l&#039;étape suivante&lt;br /&gt;
* Sinon, suit ces étapes :&lt;br /&gt;
&lt;br /&gt;
=== Sur windows ===&lt;br /&gt;
&lt;br /&gt;
# Aller dans la recherche windows et lancer &amp;lt;code&amp;gt;Services&amp;lt;/code&amp;gt;&lt;br /&gt;
# Chercher OpenSSH Authentification Agent&lt;br /&gt;
# Double cliquer dessus et mettre : &amp;lt;code&amp;gt;Type de démarrage : Automatique&amp;lt;/code&amp;gt;&lt;br /&gt;
# Appuyer sur démarrer&lt;br /&gt;
# Dans un terminal, faire &amp;lt;code&amp;gt;ssh-add&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sur Linux/Mac ===&lt;br /&gt;
&lt;br /&gt;
Voilà une solution un peu nulle qu&#039;il faudra refaire à chaque fois que tu redémarre ton ordi. Lance un terminal et tape :&lt;br /&gt;
&lt;br /&gt;
 eval `ssh-agent`&lt;br /&gt;
 ssh-add&lt;br /&gt;
&lt;br /&gt;
N&#039;hésite pas à trouver une meilleure solution et à l&#039;écrire ici.&lt;br /&gt;
&lt;br /&gt;
== Étape 5 : Tester la connexion SSH ==&lt;br /&gt;
&lt;br /&gt;
Pour tester la connexion SSH, ouvre un terminal et tape la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh -T gitlab.binets.fr&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Tu devrais voir un message comme ça :&lt;br /&gt;
&lt;br /&gt;
 The authenticity of host &#039;gitlab.binets.fr (129.104.201.46)&#039; can&#039;t be established.&lt;br /&gt;
 ED25519 key fingerprint is SHA256:sn+wsip9OTBcwiY0ZplULWXNij3v3kdj/tP228i2+70.&lt;br /&gt;
 Are you sure you want to continue connecting (yes/no/[fingerprint])?&lt;br /&gt;
&lt;br /&gt;
Écrit &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; puis appuie sur &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Si tout s’est bien passé, tu devrais voir un message de bienvenue de Gitlab. Dans le cas contraire, vérifie que tu as bien suivi toutes les étapes précédentes. Si tu rencontres des difficultés, n’hésite pas à demander de l’aide au Binet Réseau en permanence ou sur PaniX.&lt;br /&gt;
&lt;br /&gt;
== Étape 6 : Configurer l’identité Git ==&lt;br /&gt;
&lt;br /&gt;
Pour finir, il faut configurer correctement ton identité sur Git. Dans ton terminal, tape les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;git config --global user.name &amp;quot;&amp;lt;Ton Nom&amp;gt;&amp;quot;&lt;br /&gt;
git config --global user.email &amp;quot;&amp;lt;ton.nom&amp;gt;@polytechnique.edu&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;Ton Nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom et &amp;lt;code&amp;gt;&amp;amp;lt;ton.nom&amp;amp;gt;@polytechnique.edu&amp;lt;/code&amp;gt; par les valeurs adéquates.&lt;br /&gt;
&lt;br /&gt;
Félicitations ! À partir de là, tu peux utiliser Gitlab avec une authentification SSH.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lorsque tu clones un dépôt, veille bien à choisir le lien SSH et non HTTPS.&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/8/en&amp;diff=10979</id>
		<title>Translations:Mettre en place SSH pour Gitlab/8/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/8/en&amp;diff=10979"/>
		<updated>2026-08-11T11:50:44Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « Please note that there is an option to change the key’s name (by default &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) and the save location. There is also another option to add a passphrase to the key, which is recommended if your hard drive is not encrypted. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Please note that there is an option to change the key’s name (by default &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) and the save location. There is also another option to add a passphrase to the key, which is recommended if your hard drive is not encrypted.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/7/en&amp;diff=10978</id>
		<title>Translations:Mettre en place SSH pour Gitlab/7/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/7/en&amp;diff=10978"/>
		<updated>2026-08-11T11:50:20Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh-keygen -t ed25519 -C &amp;quot;ordi portable vaneau&amp;quot;&amp;lt;/syntaxhighlight&amp;gt; Replace &amp;lt;code&amp;gt;ordi portable vaneau&amp;lt;/code&amp;gt; with a name of your choice. You can leave the other fields empty by pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; for each option. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh-keygen -t ed25519 -C &amp;quot;ordi portable vaneau&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Replace &amp;lt;code&amp;gt;ordi portable vaneau&amp;lt;/code&amp;gt; with a name of your choice. You can leave the other fields empty by pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; for each option.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10977</id>
		<title>Mettre en place SSH pour Gitlab/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10977"/>
		<updated>2026-08-11T11:49:18Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « Open a terminal (cmd or powershell) and type the following command: »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
The aim of this guide is to help you set up a computer to use [[GitLab|GitLab]] with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on [[SSH]] and the BR’s [[Astuces_ssh|advanced tips]].&lt;br /&gt;
&lt;br /&gt;
The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide.&lt;br /&gt;
&lt;br /&gt;
The setup is relatively simple. Follow carefully the following steps.&lt;br /&gt;
= Prérequis =&lt;br /&gt;
&lt;br /&gt;
Before you start, make sure you have [[Git|git]] installed on your computer. To check this:&lt;br /&gt;
&lt;br /&gt;
* open a cmd or PowerShell terminal (press the Windows key + R, then type &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;);&lt;br /&gt;
* type &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; and check that Git is installed; if it isn’t, [https://git-scm.com/downloads install Git here];&lt;br /&gt;
* then type &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; to check that SSH is installed; if it isn’t, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse install OpenSSH here].&lt;br /&gt;
&lt;br /&gt;
= Mise en place =&lt;br /&gt;
&lt;br /&gt;
== Étape 1 : Générer une clé SSH ==&lt;br /&gt;
&lt;br /&gt;
Open a terminal (cmd or powershell) and type the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh-keygen -t ed25519 -C &amp;quot;ordi portable vaneau&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;ordi portable vaneau&amp;lt;/code&amp;gt; par un nom de ton choix. Tu peux laisser les autres champs vides en appuyant simplement sur la touche &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt; pour chaque option.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
À noter qu&#039;il y a une option pour changer le nom de la clé (par défaut &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et l’emplacement de sauvegarde. Il y a aussi une autre option pour ajouter un mot de passe (&#039;&#039;passphrase&#039;&#039;) à la clé, qu&#039;il est recommandé de mettre si ton disque dur n&#039;est pas chiffré.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
{{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &#039;&#039;&#039;IL NE FAUT EN AUCUN CAS PARTAGER LA CLÉ PRIVÉE&#039;&#039;&#039;. C’est la &#039;&#039;&#039;clé publique&#039;&#039;&#039; qui doit être ajoutée sur Gitlab. On n’insistera jamais assez sur ce point. Toute la sécurité repose sur le fait que la clé privée reste secrète.}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Étape 2 : Ajouter la clé SSH sur Gitlab ==&lt;br /&gt;
&lt;br /&gt;
# Connecte-toi sur Gitlab avec tes identifiants Sigma BR ;&lt;br /&gt;
# Clique sur ton avatar en haut à gauche, puis sur &amp;lt;code&amp;gt;Preferences&amp;lt;/code&amp;gt;, puis sur &amp;lt;code&amp;gt;SSH Keys&amp;lt;/code&amp;gt; (ou va directement sur [https://gitlab.binets.fr/-/user_settings/ssh_keys cette page]) ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add new key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# Copie le contenu du fichier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519.pub&amp;lt;/code&amp;gt; (ou un autre chemin si tu as choisi un autre emplacement) en remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows et colle-le dans le champ &amp;lt;code&amp;gt;Key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# (optionnel) Supprime la date d’expiration de la clé si tu veux qu’elle reste valide indéfiniment ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add key&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Étape 3 : Préparer SSH pour utiliser la clé ==&lt;br /&gt;
&lt;br /&gt;
# Ouvre le dossier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh&amp;lt;/code&amp;gt; sur VSCode (ou ton éditeur de texte préféré) ;&lt;br /&gt;
# Crée un fichier &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; (&#039;&#039;&#039;sans extension&#039;&#039;&#039;) ;&lt;br /&gt;
# Ajoute le contenu suivant :&lt;br /&gt;
&lt;br /&gt;
 Host gitlab.binets.fr&lt;br /&gt;
   User git&lt;br /&gt;
   IdentityFile C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519&lt;br /&gt;
&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows.&lt;br /&gt;
&lt;br /&gt;
== Étape 4 : Activer l&#039;agent SSH ==&lt;br /&gt;
&lt;br /&gt;
Taper &amp;lt;code&amp;gt;ssh-add -L&amp;lt;/code&amp;gt;&lt;br /&gt;
* Si ta clef ssh est affichée, tout va bien, tu peux passer à l&#039;étape suivante&lt;br /&gt;
* Sinon, suit ces étapes :&lt;br /&gt;
&lt;br /&gt;
=== Sur windows ===&lt;br /&gt;
&lt;br /&gt;
# Aller dans la recherche windows et lancer &amp;lt;code&amp;gt;Services&amp;lt;/code&amp;gt;&lt;br /&gt;
# Chercher OpenSSH Authentification Agent&lt;br /&gt;
# Double cliquer dessus et mettre : &amp;lt;code&amp;gt;Type de démarrage : Automatique&amp;lt;/code&amp;gt;&lt;br /&gt;
# Appuyer sur démarrer&lt;br /&gt;
# Dans un terminal, faire &amp;lt;code&amp;gt;ssh-add&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sur Linux/Mac ===&lt;br /&gt;
&lt;br /&gt;
Voilà une solution un peu nulle qu&#039;il faudra refaire à chaque fois que tu redémarre ton ordi. Lance un terminal et tape :&lt;br /&gt;
&lt;br /&gt;
 eval `ssh-agent`&lt;br /&gt;
 ssh-add&lt;br /&gt;
&lt;br /&gt;
N&#039;hésite pas à trouver une meilleure solution et à l&#039;écrire ici.&lt;br /&gt;
&lt;br /&gt;
== Étape 5 : Tester la connexion SSH ==&lt;br /&gt;
&lt;br /&gt;
Pour tester la connexion SSH, ouvre un terminal et tape la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh -T gitlab.binets.fr&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Tu devrais voir un message comme ça :&lt;br /&gt;
&lt;br /&gt;
 The authenticity of host &#039;gitlab.binets.fr (129.104.201.46)&#039; can&#039;t be established.&lt;br /&gt;
 ED25519 key fingerprint is SHA256:sn+wsip9OTBcwiY0ZplULWXNij3v3kdj/tP228i2+70.&lt;br /&gt;
 Are you sure you want to continue connecting (yes/no/[fingerprint])?&lt;br /&gt;
&lt;br /&gt;
Écrit &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; puis appuie sur &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Si tout s’est bien passé, tu devrais voir un message de bienvenue de Gitlab. Dans le cas contraire, vérifie que tu as bien suivi toutes les étapes précédentes. Si tu rencontres des difficultés, n’hésite pas à demander de l’aide au Binet Réseau en permanence ou sur PaniX.&lt;br /&gt;
&lt;br /&gt;
== Étape 6 : Configurer l’identité Git ==&lt;br /&gt;
&lt;br /&gt;
Pour finir, il faut configurer correctement ton identité sur Git. Dans ton terminal, tape les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;git config --global user.name &amp;quot;&amp;lt;Ton Nom&amp;gt;&amp;quot;&lt;br /&gt;
git config --global user.email &amp;quot;&amp;lt;ton.nom&amp;gt;@polytechnique.edu&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;Ton Nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom et &amp;lt;code&amp;gt;&amp;amp;lt;ton.nom&amp;amp;gt;@polytechnique.edu&amp;lt;/code&amp;gt; par les valeurs adéquates.&lt;br /&gt;
&lt;br /&gt;
Félicitations ! À partir de là, tu peux utiliser Gitlab avec une authentification SSH.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lorsque tu clones un dépôt, veille bien à choisir le lien SSH et non HTTPS.&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/6/en&amp;diff=10976</id>
		<title>Translations:Mettre en place SSH pour Gitlab/6/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/6/en&amp;diff=10976"/>
		<updated>2026-08-11T11:49:15Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « Open a terminal (cmd or powershell) and type the following command: »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Open a terminal (cmd or powershell) and type the following command:&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10975</id>
		<title>Mettre en place SSH pour Gitlab/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10975"/>
		<updated>2026-08-11T11:48:56Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « * open a cmd or PowerShell terminal (press the Windows key + R, then type &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;); * type &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; and check that Git is installed; if it isn’t, [https://git-scm.com/downloads install Git here]; * then type &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; to check that SSH is installed; if it isn’t, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse install OpenSSH here]. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
The aim of this guide is to help you set up a computer to use [[GitLab|GitLab]] with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on [[SSH]] and the BR’s [[Astuces_ssh|advanced tips]].&lt;br /&gt;
&lt;br /&gt;
The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide.&lt;br /&gt;
&lt;br /&gt;
The setup is relatively simple. Follow carefully the following steps.&lt;br /&gt;
= Prérequis =&lt;br /&gt;
&lt;br /&gt;
Before you start, make sure you have [[Git|git]] installed on your computer. To check this:&lt;br /&gt;
&lt;br /&gt;
* open a cmd or PowerShell terminal (press the Windows key + R, then type &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;);&lt;br /&gt;
* type &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; and check that Git is installed; if it isn’t, [https://git-scm.com/downloads install Git here];&lt;br /&gt;
* then type &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; to check that SSH is installed; if it isn’t, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse install OpenSSH here].&lt;br /&gt;
&lt;br /&gt;
= Mise en place =&lt;br /&gt;
&lt;br /&gt;
== Étape 1 : Générer une clé SSH ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Ouvre un terminal (cmd ou powershell) et tape la commande suivante :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh-keygen -t ed25519 -C &amp;quot;ordi portable vaneau&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;ordi portable vaneau&amp;lt;/code&amp;gt; par un nom de ton choix. Tu peux laisser les autres champs vides en appuyant simplement sur la touche &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt; pour chaque option.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
À noter qu&#039;il y a une option pour changer le nom de la clé (par défaut &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et l’emplacement de sauvegarde. Il y a aussi une autre option pour ajouter un mot de passe (&#039;&#039;passphrase&#039;&#039;) à la clé, qu&#039;il est recommandé de mettre si ton disque dur n&#039;est pas chiffré.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
{{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &#039;&#039;&#039;IL NE FAUT EN AUCUN CAS PARTAGER LA CLÉ PRIVÉE&#039;&#039;&#039;. C’est la &#039;&#039;&#039;clé publique&#039;&#039;&#039; qui doit être ajoutée sur Gitlab. On n’insistera jamais assez sur ce point. Toute la sécurité repose sur le fait que la clé privée reste secrète.}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Étape 2 : Ajouter la clé SSH sur Gitlab ==&lt;br /&gt;
&lt;br /&gt;
# Connecte-toi sur Gitlab avec tes identifiants Sigma BR ;&lt;br /&gt;
# Clique sur ton avatar en haut à gauche, puis sur &amp;lt;code&amp;gt;Preferences&amp;lt;/code&amp;gt;, puis sur &amp;lt;code&amp;gt;SSH Keys&amp;lt;/code&amp;gt; (ou va directement sur [https://gitlab.binets.fr/-/user_settings/ssh_keys cette page]) ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add new key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# Copie le contenu du fichier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519.pub&amp;lt;/code&amp;gt; (ou un autre chemin si tu as choisi un autre emplacement) en remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows et colle-le dans le champ &amp;lt;code&amp;gt;Key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# (optionnel) Supprime la date d’expiration de la clé si tu veux qu’elle reste valide indéfiniment ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add key&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Étape 3 : Préparer SSH pour utiliser la clé ==&lt;br /&gt;
&lt;br /&gt;
# Ouvre le dossier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh&amp;lt;/code&amp;gt; sur VSCode (ou ton éditeur de texte préféré) ;&lt;br /&gt;
# Crée un fichier &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; (&#039;&#039;&#039;sans extension&#039;&#039;&#039;) ;&lt;br /&gt;
# Ajoute le contenu suivant :&lt;br /&gt;
&lt;br /&gt;
 Host gitlab.binets.fr&lt;br /&gt;
   User git&lt;br /&gt;
   IdentityFile C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519&lt;br /&gt;
&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows.&lt;br /&gt;
&lt;br /&gt;
== Étape 4 : Activer l&#039;agent SSH ==&lt;br /&gt;
&lt;br /&gt;
Taper &amp;lt;code&amp;gt;ssh-add -L&amp;lt;/code&amp;gt;&lt;br /&gt;
* Si ta clef ssh est affichée, tout va bien, tu peux passer à l&#039;étape suivante&lt;br /&gt;
* Sinon, suit ces étapes :&lt;br /&gt;
&lt;br /&gt;
=== Sur windows ===&lt;br /&gt;
&lt;br /&gt;
# Aller dans la recherche windows et lancer &amp;lt;code&amp;gt;Services&amp;lt;/code&amp;gt;&lt;br /&gt;
# Chercher OpenSSH Authentification Agent&lt;br /&gt;
# Double cliquer dessus et mettre : &amp;lt;code&amp;gt;Type de démarrage : Automatique&amp;lt;/code&amp;gt;&lt;br /&gt;
# Appuyer sur démarrer&lt;br /&gt;
# Dans un terminal, faire &amp;lt;code&amp;gt;ssh-add&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sur Linux/Mac ===&lt;br /&gt;
&lt;br /&gt;
Voilà une solution un peu nulle qu&#039;il faudra refaire à chaque fois que tu redémarre ton ordi. Lance un terminal et tape :&lt;br /&gt;
&lt;br /&gt;
 eval `ssh-agent`&lt;br /&gt;
 ssh-add&lt;br /&gt;
&lt;br /&gt;
N&#039;hésite pas à trouver une meilleure solution et à l&#039;écrire ici.&lt;br /&gt;
&lt;br /&gt;
== Étape 5 : Tester la connexion SSH ==&lt;br /&gt;
&lt;br /&gt;
Pour tester la connexion SSH, ouvre un terminal et tape la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh -T gitlab.binets.fr&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Tu devrais voir un message comme ça :&lt;br /&gt;
&lt;br /&gt;
 The authenticity of host &#039;gitlab.binets.fr (129.104.201.46)&#039; can&#039;t be established.&lt;br /&gt;
 ED25519 key fingerprint is SHA256:sn+wsip9OTBcwiY0ZplULWXNij3v3kdj/tP228i2+70.&lt;br /&gt;
 Are you sure you want to continue connecting (yes/no/[fingerprint])?&lt;br /&gt;
&lt;br /&gt;
Écrit &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; puis appuie sur &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Si tout s’est bien passé, tu devrais voir un message de bienvenue de Gitlab. Dans le cas contraire, vérifie que tu as bien suivi toutes les étapes précédentes. Si tu rencontres des difficultés, n’hésite pas à demander de l’aide au Binet Réseau en permanence ou sur PaniX.&lt;br /&gt;
&lt;br /&gt;
== Étape 6 : Configurer l’identité Git ==&lt;br /&gt;
&lt;br /&gt;
Pour finir, il faut configurer correctement ton identité sur Git. Dans ton terminal, tape les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;git config --global user.name &amp;quot;&amp;lt;Ton Nom&amp;gt;&amp;quot;&lt;br /&gt;
git config --global user.email &amp;quot;&amp;lt;ton.nom&amp;gt;@polytechnique.edu&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;Ton Nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom et &amp;lt;code&amp;gt;&amp;amp;lt;ton.nom&amp;amp;gt;@polytechnique.edu&amp;lt;/code&amp;gt; par les valeurs adéquates.&lt;br /&gt;
&lt;br /&gt;
Félicitations ! À partir de là, tu peux utiliser Gitlab avec une authentification SSH.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lorsque tu clones un dépôt, veille bien à choisir le lien SSH et non HTTPS.&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/5/en&amp;diff=10974</id>
		<title>Translations:Mettre en place SSH pour Gitlab/5/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/5/en&amp;diff=10974"/>
		<updated>2026-08-11T11:48:54Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « * open a cmd or PowerShell terminal (press the Windows key + R, then type &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;); * type &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; and check that Git is installed; if it isn’t, [https://git-scm.com/downloads install Git here]; * then type &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; to check that SSH is installed; if it isn’t, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse install OpenSSH here]. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* open a cmd or PowerShell terminal (press the Windows key + R, then type &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;);&lt;br /&gt;
* type &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; and check that Git is installed; if it isn’t, [https://git-scm.com/downloads install Git here];&lt;br /&gt;
* then type &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; to check that SSH is installed; if it isn’t, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse install OpenSSH here].&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10973</id>
		<title>Mettre en place SSH pour Gitlab/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10973"/>
		<updated>2026-08-11T11:47:54Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « Before you start, make sure you have git installed on your computer. To check this: »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
The aim of this guide is to help you set up a computer to use [[GitLab|GitLab]] with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on [[SSH]] and the BR’s [[Astuces_ssh|advanced tips]].&lt;br /&gt;
&lt;br /&gt;
The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide.&lt;br /&gt;
&lt;br /&gt;
The setup is relatively simple. Follow carefully the following steps.&lt;br /&gt;
= Prérequis =&lt;br /&gt;
&lt;br /&gt;
Before you start, make sure you have [[Git|git]] installed on your computer. To check this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* ouvrir un terminal cmd ou powershell (touche Windows + R, puis taper &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; ou &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;) ;&lt;br /&gt;
* taper &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; et vérifier que git est bien installé et, si ce n’est pas le cas, [https://git-scm.com/downloads installe git ici] ;&lt;br /&gt;
* taper ensuite &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; pour vérifier que ssh est installé et, si ce n’est pas le cas, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse installe OpenSSH ici].&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Mise en place =&lt;br /&gt;
&lt;br /&gt;
== Étape 1 : Générer une clé SSH ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Ouvre un terminal (cmd ou powershell) et tape la commande suivante :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh-keygen -t ed25519 -C &amp;quot;ordi portable vaneau&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;ordi portable vaneau&amp;lt;/code&amp;gt; par un nom de ton choix. Tu peux laisser les autres champs vides en appuyant simplement sur la touche &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt; pour chaque option.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
À noter qu&#039;il y a une option pour changer le nom de la clé (par défaut &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et l’emplacement de sauvegarde. Il y a aussi une autre option pour ajouter un mot de passe (&#039;&#039;passphrase&#039;&#039;) à la clé, qu&#039;il est recommandé de mettre si ton disque dur n&#039;est pas chiffré.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
{{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &#039;&#039;&#039;IL NE FAUT EN AUCUN CAS PARTAGER LA CLÉ PRIVÉE&#039;&#039;&#039;. C’est la &#039;&#039;&#039;clé publique&#039;&#039;&#039; qui doit être ajoutée sur Gitlab. On n’insistera jamais assez sur ce point. Toute la sécurité repose sur le fait que la clé privée reste secrète.}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Étape 2 : Ajouter la clé SSH sur Gitlab ==&lt;br /&gt;
&lt;br /&gt;
# Connecte-toi sur Gitlab avec tes identifiants Sigma BR ;&lt;br /&gt;
# Clique sur ton avatar en haut à gauche, puis sur &amp;lt;code&amp;gt;Preferences&amp;lt;/code&amp;gt;, puis sur &amp;lt;code&amp;gt;SSH Keys&amp;lt;/code&amp;gt; (ou va directement sur [https://gitlab.binets.fr/-/user_settings/ssh_keys cette page]) ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add new key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# Copie le contenu du fichier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519.pub&amp;lt;/code&amp;gt; (ou un autre chemin si tu as choisi un autre emplacement) en remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows et colle-le dans le champ &amp;lt;code&amp;gt;Key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# (optionnel) Supprime la date d’expiration de la clé si tu veux qu’elle reste valide indéfiniment ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add key&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Étape 3 : Préparer SSH pour utiliser la clé ==&lt;br /&gt;
&lt;br /&gt;
# Ouvre le dossier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh&amp;lt;/code&amp;gt; sur VSCode (ou ton éditeur de texte préféré) ;&lt;br /&gt;
# Crée un fichier &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; (&#039;&#039;&#039;sans extension&#039;&#039;&#039;) ;&lt;br /&gt;
# Ajoute le contenu suivant :&lt;br /&gt;
&lt;br /&gt;
 Host gitlab.binets.fr&lt;br /&gt;
   User git&lt;br /&gt;
   IdentityFile C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519&lt;br /&gt;
&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows.&lt;br /&gt;
&lt;br /&gt;
== Étape 4 : Activer l&#039;agent SSH ==&lt;br /&gt;
&lt;br /&gt;
Taper &amp;lt;code&amp;gt;ssh-add -L&amp;lt;/code&amp;gt;&lt;br /&gt;
* Si ta clef ssh est affichée, tout va bien, tu peux passer à l&#039;étape suivante&lt;br /&gt;
* Sinon, suit ces étapes :&lt;br /&gt;
&lt;br /&gt;
=== Sur windows ===&lt;br /&gt;
&lt;br /&gt;
# Aller dans la recherche windows et lancer &amp;lt;code&amp;gt;Services&amp;lt;/code&amp;gt;&lt;br /&gt;
# Chercher OpenSSH Authentification Agent&lt;br /&gt;
# Double cliquer dessus et mettre : &amp;lt;code&amp;gt;Type de démarrage : Automatique&amp;lt;/code&amp;gt;&lt;br /&gt;
# Appuyer sur démarrer&lt;br /&gt;
# Dans un terminal, faire &amp;lt;code&amp;gt;ssh-add&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sur Linux/Mac ===&lt;br /&gt;
&lt;br /&gt;
Voilà une solution un peu nulle qu&#039;il faudra refaire à chaque fois que tu redémarre ton ordi. Lance un terminal et tape :&lt;br /&gt;
&lt;br /&gt;
 eval `ssh-agent`&lt;br /&gt;
 ssh-add&lt;br /&gt;
&lt;br /&gt;
N&#039;hésite pas à trouver une meilleure solution et à l&#039;écrire ici.&lt;br /&gt;
&lt;br /&gt;
== Étape 5 : Tester la connexion SSH ==&lt;br /&gt;
&lt;br /&gt;
Pour tester la connexion SSH, ouvre un terminal et tape la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh -T gitlab.binets.fr&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Tu devrais voir un message comme ça :&lt;br /&gt;
&lt;br /&gt;
 The authenticity of host &#039;gitlab.binets.fr (129.104.201.46)&#039; can&#039;t be established.&lt;br /&gt;
 ED25519 key fingerprint is SHA256:sn+wsip9OTBcwiY0ZplULWXNij3v3kdj/tP228i2+70.&lt;br /&gt;
 Are you sure you want to continue connecting (yes/no/[fingerprint])?&lt;br /&gt;
&lt;br /&gt;
Écrit &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; puis appuie sur &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Si tout s’est bien passé, tu devrais voir un message de bienvenue de Gitlab. Dans le cas contraire, vérifie que tu as bien suivi toutes les étapes précédentes. Si tu rencontres des difficultés, n’hésite pas à demander de l’aide au Binet Réseau en permanence ou sur PaniX.&lt;br /&gt;
&lt;br /&gt;
== Étape 6 : Configurer l’identité Git ==&lt;br /&gt;
&lt;br /&gt;
Pour finir, il faut configurer correctement ton identité sur Git. Dans ton terminal, tape les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;git config --global user.name &amp;quot;&amp;lt;Ton Nom&amp;gt;&amp;quot;&lt;br /&gt;
git config --global user.email &amp;quot;&amp;lt;ton.nom&amp;gt;@polytechnique.edu&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;Ton Nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom et &amp;lt;code&amp;gt;&amp;amp;lt;ton.nom&amp;amp;gt;@polytechnique.edu&amp;lt;/code&amp;gt; par les valeurs adéquates.&lt;br /&gt;
&lt;br /&gt;
Félicitations ! À partir de là, tu peux utiliser Gitlab avec une authentification SSH.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lorsque tu clones un dépôt, veille bien à choisir le lien SSH et non HTTPS.&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/4/en&amp;diff=10972</id>
		<title>Translations:Mettre en place SSH pour Gitlab/4/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/4/en&amp;diff=10972"/>
		<updated>2026-08-11T11:47:49Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « Before you start, make sure you have git installed on your computer. To check this: »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Before you start, make sure you have [[Git|git]] installed on your computer. To check this:&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10971</id>
		<title>Mettre en place SSH pour Gitlab/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10971"/>
		<updated>2026-08-11T11:47:20Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « The setup is relatively simple. Follow carefully the following steps. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
The aim of this guide is to help you set up a computer to use [[GitLab|GitLab]] with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on [[SSH]] and the BR’s [[Astuces_ssh|advanced tips]].&lt;br /&gt;
&lt;br /&gt;
The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide.&lt;br /&gt;
&lt;br /&gt;
The setup is relatively simple. Follow carefully the following steps.&lt;br /&gt;
= Prérequis =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Avant de commencer, assure-toi d’avoir [[Git|git]] installé sur ta machine. Pour vérifier cela :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* ouvrir un terminal cmd ou powershell (touche Windows + R, puis taper &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; ou &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;) ;&lt;br /&gt;
* taper &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; et vérifier que git est bien installé et, si ce n’est pas le cas, [https://git-scm.com/downloads installe git ici] ;&lt;br /&gt;
* taper ensuite &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; pour vérifier que ssh est installé et, si ce n’est pas le cas, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse installe OpenSSH ici].&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Mise en place =&lt;br /&gt;
&lt;br /&gt;
== Étape 1 : Générer une clé SSH ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Ouvre un terminal (cmd ou powershell) et tape la commande suivante :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh-keygen -t ed25519 -C &amp;quot;ordi portable vaneau&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;ordi portable vaneau&amp;lt;/code&amp;gt; par un nom de ton choix. Tu peux laisser les autres champs vides en appuyant simplement sur la touche &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt; pour chaque option.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
À noter qu&#039;il y a une option pour changer le nom de la clé (par défaut &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et l’emplacement de sauvegarde. Il y a aussi une autre option pour ajouter un mot de passe (&#039;&#039;passphrase&#039;&#039;) à la clé, qu&#039;il est recommandé de mettre si ton disque dur n&#039;est pas chiffré.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
{{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &#039;&#039;&#039;IL NE FAUT EN AUCUN CAS PARTAGER LA CLÉ PRIVÉE&#039;&#039;&#039;. C’est la &#039;&#039;&#039;clé publique&#039;&#039;&#039; qui doit être ajoutée sur Gitlab. On n’insistera jamais assez sur ce point. Toute la sécurité repose sur le fait que la clé privée reste secrète.}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Étape 2 : Ajouter la clé SSH sur Gitlab ==&lt;br /&gt;
&lt;br /&gt;
# Connecte-toi sur Gitlab avec tes identifiants Sigma BR ;&lt;br /&gt;
# Clique sur ton avatar en haut à gauche, puis sur &amp;lt;code&amp;gt;Preferences&amp;lt;/code&amp;gt;, puis sur &amp;lt;code&amp;gt;SSH Keys&amp;lt;/code&amp;gt; (ou va directement sur [https://gitlab.binets.fr/-/user_settings/ssh_keys cette page]) ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add new key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# Copie le contenu du fichier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519.pub&amp;lt;/code&amp;gt; (ou un autre chemin si tu as choisi un autre emplacement) en remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows et colle-le dans le champ &amp;lt;code&amp;gt;Key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# (optionnel) Supprime la date d’expiration de la clé si tu veux qu’elle reste valide indéfiniment ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add key&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Étape 3 : Préparer SSH pour utiliser la clé ==&lt;br /&gt;
&lt;br /&gt;
# Ouvre le dossier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh&amp;lt;/code&amp;gt; sur VSCode (ou ton éditeur de texte préféré) ;&lt;br /&gt;
# Crée un fichier &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; (&#039;&#039;&#039;sans extension&#039;&#039;&#039;) ;&lt;br /&gt;
# Ajoute le contenu suivant :&lt;br /&gt;
&lt;br /&gt;
 Host gitlab.binets.fr&lt;br /&gt;
   User git&lt;br /&gt;
   IdentityFile C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519&lt;br /&gt;
&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows.&lt;br /&gt;
&lt;br /&gt;
== Étape 4 : Activer l&#039;agent SSH ==&lt;br /&gt;
&lt;br /&gt;
Taper &amp;lt;code&amp;gt;ssh-add -L&amp;lt;/code&amp;gt;&lt;br /&gt;
* Si ta clef ssh est affichée, tout va bien, tu peux passer à l&#039;étape suivante&lt;br /&gt;
* Sinon, suit ces étapes :&lt;br /&gt;
&lt;br /&gt;
=== Sur windows ===&lt;br /&gt;
&lt;br /&gt;
# Aller dans la recherche windows et lancer &amp;lt;code&amp;gt;Services&amp;lt;/code&amp;gt;&lt;br /&gt;
# Chercher OpenSSH Authentification Agent&lt;br /&gt;
# Double cliquer dessus et mettre : &amp;lt;code&amp;gt;Type de démarrage : Automatique&amp;lt;/code&amp;gt;&lt;br /&gt;
# Appuyer sur démarrer&lt;br /&gt;
# Dans un terminal, faire &amp;lt;code&amp;gt;ssh-add&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sur Linux/Mac ===&lt;br /&gt;
&lt;br /&gt;
Voilà une solution un peu nulle qu&#039;il faudra refaire à chaque fois que tu redémarre ton ordi. Lance un terminal et tape :&lt;br /&gt;
&lt;br /&gt;
 eval `ssh-agent`&lt;br /&gt;
 ssh-add&lt;br /&gt;
&lt;br /&gt;
N&#039;hésite pas à trouver une meilleure solution et à l&#039;écrire ici.&lt;br /&gt;
&lt;br /&gt;
== Étape 5 : Tester la connexion SSH ==&lt;br /&gt;
&lt;br /&gt;
Pour tester la connexion SSH, ouvre un terminal et tape la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh -T gitlab.binets.fr&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Tu devrais voir un message comme ça :&lt;br /&gt;
&lt;br /&gt;
 The authenticity of host &#039;gitlab.binets.fr (129.104.201.46)&#039; can&#039;t be established.&lt;br /&gt;
 ED25519 key fingerprint is SHA256:sn+wsip9OTBcwiY0ZplULWXNij3v3kdj/tP228i2+70.&lt;br /&gt;
 Are you sure you want to continue connecting (yes/no/[fingerprint])?&lt;br /&gt;
&lt;br /&gt;
Écrit &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; puis appuie sur &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Si tout s’est bien passé, tu devrais voir un message de bienvenue de Gitlab. Dans le cas contraire, vérifie que tu as bien suivi toutes les étapes précédentes. Si tu rencontres des difficultés, n’hésite pas à demander de l’aide au Binet Réseau en permanence ou sur PaniX.&lt;br /&gt;
&lt;br /&gt;
== Étape 6 : Configurer l’identité Git ==&lt;br /&gt;
&lt;br /&gt;
Pour finir, il faut configurer correctement ton identité sur Git. Dans ton terminal, tape les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;git config --global user.name &amp;quot;&amp;lt;Ton Nom&amp;gt;&amp;quot;&lt;br /&gt;
git config --global user.email &amp;quot;&amp;lt;ton.nom&amp;gt;@polytechnique.edu&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;Ton Nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom et &amp;lt;code&amp;gt;&amp;amp;lt;ton.nom&amp;amp;gt;@polytechnique.edu&amp;lt;/code&amp;gt; par les valeurs adéquates.&lt;br /&gt;
&lt;br /&gt;
Félicitations ! À partir de là, tu peux utiliser Gitlab avec une authentification SSH.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lorsque tu clones un dépôt, veille bien à choisir le lien SSH et non HTTPS.&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/3/en&amp;diff=10970</id>
		<title>Translations:Mettre en place SSH pour Gitlab/3/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/3/en&amp;diff=10970"/>
		<updated>2026-08-11T11:47:13Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « The setup is relatively simple. Follow carefully the following steps. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The setup is relatively simple. Follow carefully the following steps.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10969</id>
		<title>Mettre en place SSH pour Gitlab/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10969"/>
		<updated>2026-08-11T11:46:48Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
The aim of this guide is to help you set up a computer to use [[GitLab|GitLab]] with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on [[SSH]] and the BR’s [[Astuces_ssh|advanced tips]].&lt;br /&gt;
&lt;br /&gt;
The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
La mise en place est relativement simple. Suit scrupuleusement les étapes suivantes.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
= Prérequis =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Avant de commencer, assure-toi d’avoir [[Git|git]] installé sur ta machine. Pour vérifier cela :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* ouvrir un terminal cmd ou powershell (touche Windows + R, puis taper &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; ou &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;) ;&lt;br /&gt;
* taper &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; et vérifier que git est bien installé et, si ce n’est pas le cas, [https://git-scm.com/downloads installe git ici] ;&lt;br /&gt;
* taper ensuite &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; pour vérifier que ssh est installé et, si ce n’est pas le cas, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse installe OpenSSH ici].&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Mise en place =&lt;br /&gt;
&lt;br /&gt;
== Étape 1 : Générer une clé SSH ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Ouvre un terminal (cmd ou powershell) et tape la commande suivante :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh-keygen -t ed25519 -C &amp;quot;ordi portable vaneau&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;ordi portable vaneau&amp;lt;/code&amp;gt; par un nom de ton choix. Tu peux laisser les autres champs vides en appuyant simplement sur la touche &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt; pour chaque option.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
À noter qu&#039;il y a une option pour changer le nom de la clé (par défaut &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et l’emplacement de sauvegarde. Il y a aussi une autre option pour ajouter un mot de passe (&#039;&#039;passphrase&#039;&#039;) à la clé, qu&#039;il est recommandé de mettre si ton disque dur n&#039;est pas chiffré.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
{{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &#039;&#039;&#039;IL NE FAUT EN AUCUN CAS PARTAGER LA CLÉ PRIVÉE&#039;&#039;&#039;. C’est la &#039;&#039;&#039;clé publique&#039;&#039;&#039; qui doit être ajoutée sur Gitlab. On n’insistera jamais assez sur ce point. Toute la sécurité repose sur le fait que la clé privée reste secrète.}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Étape 2 : Ajouter la clé SSH sur Gitlab ==&lt;br /&gt;
&lt;br /&gt;
# Connecte-toi sur Gitlab avec tes identifiants Sigma BR ;&lt;br /&gt;
# Clique sur ton avatar en haut à gauche, puis sur &amp;lt;code&amp;gt;Preferences&amp;lt;/code&amp;gt;, puis sur &amp;lt;code&amp;gt;SSH Keys&amp;lt;/code&amp;gt; (ou va directement sur [https://gitlab.binets.fr/-/user_settings/ssh_keys cette page]) ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add new key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# Copie le contenu du fichier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519.pub&amp;lt;/code&amp;gt; (ou un autre chemin si tu as choisi un autre emplacement) en remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows et colle-le dans le champ &amp;lt;code&amp;gt;Key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# (optionnel) Supprime la date d’expiration de la clé si tu veux qu’elle reste valide indéfiniment ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add key&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Étape 3 : Préparer SSH pour utiliser la clé ==&lt;br /&gt;
&lt;br /&gt;
# Ouvre le dossier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh&amp;lt;/code&amp;gt; sur VSCode (ou ton éditeur de texte préféré) ;&lt;br /&gt;
# Crée un fichier &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; (&#039;&#039;&#039;sans extension&#039;&#039;&#039;) ;&lt;br /&gt;
# Ajoute le contenu suivant :&lt;br /&gt;
&lt;br /&gt;
 Host gitlab.binets.fr&lt;br /&gt;
   User git&lt;br /&gt;
   IdentityFile C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519&lt;br /&gt;
&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows.&lt;br /&gt;
&lt;br /&gt;
== Étape 4 : Activer l&#039;agent SSH ==&lt;br /&gt;
&lt;br /&gt;
Taper &amp;lt;code&amp;gt;ssh-add -L&amp;lt;/code&amp;gt;&lt;br /&gt;
* Si ta clef ssh est affichée, tout va bien, tu peux passer à l&#039;étape suivante&lt;br /&gt;
* Sinon, suit ces étapes :&lt;br /&gt;
&lt;br /&gt;
=== Sur windows ===&lt;br /&gt;
&lt;br /&gt;
# Aller dans la recherche windows et lancer &amp;lt;code&amp;gt;Services&amp;lt;/code&amp;gt;&lt;br /&gt;
# Chercher OpenSSH Authentification Agent&lt;br /&gt;
# Double cliquer dessus et mettre : &amp;lt;code&amp;gt;Type de démarrage : Automatique&amp;lt;/code&amp;gt;&lt;br /&gt;
# Appuyer sur démarrer&lt;br /&gt;
# Dans un terminal, faire &amp;lt;code&amp;gt;ssh-add&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sur Linux/Mac ===&lt;br /&gt;
&lt;br /&gt;
Voilà une solution un peu nulle qu&#039;il faudra refaire à chaque fois que tu redémarre ton ordi. Lance un terminal et tape :&lt;br /&gt;
&lt;br /&gt;
 eval `ssh-agent`&lt;br /&gt;
 ssh-add&lt;br /&gt;
&lt;br /&gt;
N&#039;hésite pas à trouver une meilleure solution et à l&#039;écrire ici.&lt;br /&gt;
&lt;br /&gt;
== Étape 5 : Tester la connexion SSH ==&lt;br /&gt;
&lt;br /&gt;
Pour tester la connexion SSH, ouvre un terminal et tape la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh -T gitlab.binets.fr&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Tu devrais voir un message comme ça :&lt;br /&gt;
&lt;br /&gt;
 The authenticity of host &#039;gitlab.binets.fr (129.104.201.46)&#039; can&#039;t be established.&lt;br /&gt;
 ED25519 key fingerprint is SHA256:sn+wsip9OTBcwiY0ZplULWXNij3v3kdj/tP228i2+70.&lt;br /&gt;
 Are you sure you want to continue connecting (yes/no/[fingerprint])?&lt;br /&gt;
&lt;br /&gt;
Écrit &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; puis appuie sur &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Si tout s’est bien passé, tu devrais voir un message de bienvenue de Gitlab. Dans le cas contraire, vérifie que tu as bien suivi toutes les étapes précédentes. Si tu rencontres des difficultés, n’hésite pas à demander de l’aide au Binet Réseau en permanence ou sur PaniX.&lt;br /&gt;
&lt;br /&gt;
== Étape 6 : Configurer l’identité Git ==&lt;br /&gt;
&lt;br /&gt;
Pour finir, il faut configurer correctement ton identité sur Git. Dans ton terminal, tape les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;git config --global user.name &amp;quot;&amp;lt;Ton Nom&amp;gt;&amp;quot;&lt;br /&gt;
git config --global user.email &amp;quot;&amp;lt;ton.nom&amp;gt;@polytechnique.edu&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;Ton Nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom et &amp;lt;code&amp;gt;&amp;amp;lt;ton.nom&amp;amp;gt;@polytechnique.edu&amp;lt;/code&amp;gt; par les valeurs adéquates.&lt;br /&gt;
&lt;br /&gt;
Félicitations ! À partir de là, tu peux utiliser Gitlab avec une authentification SSH.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lorsque tu clones un dépôt, veille bien à choisir le lien SSH et non HTTPS.&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/2/en&amp;diff=10968</id>
		<title>Translations:Mettre en place SSH pour Gitlab/2/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/2/en&amp;diff=10968"/>
		<updated>2026-08-11T11:46:43Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10967</id>
		<title>Mettre en place SSH pour Gitlab/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Mettre_en_place_SSH_pour_Gitlab/en&amp;diff=10967"/>
		<updated>2026-08-11T11:46:24Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « The aim of this guide is to help you set up a computer to use GitLab with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on SSH and the BR’s advanced tips. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
The aim of this guide is to help you set up a computer to use [[GitLab|GitLab]] with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on [[SSH]] and the BR’s [[Astuces_ssh|advanced tips]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
On décrit les étapes d’installation pour Windows 10 et 11. Pour Linux et macOS, se référer également au guide SSH principal.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
La mise en place est relativement simple. Suit scrupuleusement les étapes suivantes.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
= Prérequis =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Avant de commencer, assure-toi d’avoir [[Git|git]] installé sur ta machine. Pour vérifier cela :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* ouvrir un terminal cmd ou powershell (touche Windows + R, puis taper &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; ou &amp;lt;code&amp;gt;powershell&amp;lt;/code&amp;gt;) ;&lt;br /&gt;
* taper &amp;lt;code&amp;gt;git -v&amp;lt;/code&amp;gt; et vérifier que git est bien installé et, si ce n’est pas le cas, [https://git-scm.com/downloads installe git ici] ;&lt;br /&gt;
* taper ensuite &amp;lt;code&amp;gt;ssh -V&amp;lt;/code&amp;gt; pour vérifier que ssh est installé et, si ce n’est pas le cas, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse installe OpenSSH ici].&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Mise en place =&lt;br /&gt;
&lt;br /&gt;
== Étape 1 : Générer une clé SSH ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Ouvre un terminal (cmd ou powershell) et tape la commande suivante :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh-keygen -t ed25519 -C &amp;quot;ordi portable vaneau&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;ordi portable vaneau&amp;lt;/code&amp;gt; par un nom de ton choix. Tu peux laisser les autres champs vides en appuyant simplement sur la touche &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt; pour chaque option.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
À noter qu&#039;il y a une option pour changer le nom de la clé (par défaut &amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et l’emplacement de sauvegarde. Il y a aussi une autre option pour ajouter un mot de passe (&#039;&#039;passphrase&#039;&#039;) à la clé, qu&#039;il est recommandé de mettre si ton disque dur n&#039;est pas chiffré.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
{{Attention|Cette commande génère deux fichiers dans le dossier &amp;lt;code&amp;gt;C:\Users\&amp;lt;ton_nom&amp;gt;\.ssh&amp;lt;/code&amp;gt; : la clé privée (&amp;lt;code&amp;gt;id_ed25519&amp;lt;/code&amp;gt;) et la clé publique (&amp;lt;code&amp;gt;id_ed25519.pub&amp;lt;/code&amp;gt;). &#039;&#039;&#039;IL NE FAUT EN AUCUN CAS PARTAGER LA CLÉ PRIVÉE&#039;&#039;&#039;. C’est la &#039;&#039;&#039;clé publique&#039;&#039;&#039; qui doit être ajoutée sur Gitlab. On n’insistera jamais assez sur ce point. Toute la sécurité repose sur le fait que la clé privée reste secrète.}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Étape 2 : Ajouter la clé SSH sur Gitlab ==&lt;br /&gt;
&lt;br /&gt;
# Connecte-toi sur Gitlab avec tes identifiants Sigma BR ;&lt;br /&gt;
# Clique sur ton avatar en haut à gauche, puis sur &amp;lt;code&amp;gt;Preferences&amp;lt;/code&amp;gt;, puis sur &amp;lt;code&amp;gt;SSH Keys&amp;lt;/code&amp;gt; (ou va directement sur [https://gitlab.binets.fr/-/user_settings/ssh_keys cette page]) ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add new key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# Copie le contenu du fichier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519.pub&amp;lt;/code&amp;gt; (ou un autre chemin si tu as choisi un autre emplacement) en remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows et colle-le dans le champ &amp;lt;code&amp;gt;Key&amp;lt;/code&amp;gt; ;&lt;br /&gt;
# (optionnel) Supprime la date d’expiration de la clé si tu veux qu’elle reste valide indéfiniment ;&lt;br /&gt;
# Clique sur &amp;lt;code&amp;gt;Add key&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Étape 3 : Préparer SSH pour utiliser la clé ==&lt;br /&gt;
&lt;br /&gt;
# Ouvre le dossier &amp;lt;code&amp;gt;C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh&amp;lt;/code&amp;gt; sur VSCode (ou ton éditeur de texte préféré) ;&lt;br /&gt;
# Crée un fichier &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; (&#039;&#039;&#039;sans extension&#039;&#039;&#039;) ;&lt;br /&gt;
# Ajoute le contenu suivant :&lt;br /&gt;
&lt;br /&gt;
 Host gitlab.binets.fr&lt;br /&gt;
   User git&lt;br /&gt;
   IdentityFile C:\Users\&amp;amp;lt;ton_nom&amp;amp;gt;\.ssh\id_ed25519&lt;br /&gt;
&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;ton_nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom d’utilisateur Windows.&lt;br /&gt;
&lt;br /&gt;
== Étape 4 : Activer l&#039;agent SSH ==&lt;br /&gt;
&lt;br /&gt;
Taper &amp;lt;code&amp;gt;ssh-add -L&amp;lt;/code&amp;gt;&lt;br /&gt;
* Si ta clef ssh est affichée, tout va bien, tu peux passer à l&#039;étape suivante&lt;br /&gt;
* Sinon, suit ces étapes :&lt;br /&gt;
&lt;br /&gt;
=== Sur windows ===&lt;br /&gt;
&lt;br /&gt;
# Aller dans la recherche windows et lancer &amp;lt;code&amp;gt;Services&amp;lt;/code&amp;gt;&lt;br /&gt;
# Chercher OpenSSH Authentification Agent&lt;br /&gt;
# Double cliquer dessus et mettre : &amp;lt;code&amp;gt;Type de démarrage : Automatique&amp;lt;/code&amp;gt;&lt;br /&gt;
# Appuyer sur démarrer&lt;br /&gt;
# Dans un terminal, faire &amp;lt;code&amp;gt;ssh-add&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sur Linux/Mac ===&lt;br /&gt;
&lt;br /&gt;
Voilà une solution un peu nulle qu&#039;il faudra refaire à chaque fois que tu redémarre ton ordi. Lance un terminal et tape :&lt;br /&gt;
&lt;br /&gt;
 eval `ssh-agent`&lt;br /&gt;
 ssh-add&lt;br /&gt;
&lt;br /&gt;
N&#039;hésite pas à trouver une meilleure solution et à l&#039;écrire ici.&lt;br /&gt;
&lt;br /&gt;
== Étape 5 : Tester la connexion SSH ==&lt;br /&gt;
&lt;br /&gt;
Pour tester la connexion SSH, ouvre un terminal et tape la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ssh -T gitlab.binets.fr&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Tu devrais voir un message comme ça :&lt;br /&gt;
&lt;br /&gt;
 The authenticity of host &#039;gitlab.binets.fr (129.104.201.46)&#039; can&#039;t be established.&lt;br /&gt;
 ED25519 key fingerprint is SHA256:sn+wsip9OTBcwiY0ZplULWXNij3v3kdj/tP228i2+70.&lt;br /&gt;
 Are you sure you want to continue connecting (yes/no/[fingerprint])?&lt;br /&gt;
&lt;br /&gt;
Écrit &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; puis appuie sur &amp;lt;code&amp;gt;Entrée&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Si tout s’est bien passé, tu devrais voir un message de bienvenue de Gitlab. Dans le cas contraire, vérifie que tu as bien suivi toutes les étapes précédentes. Si tu rencontres des difficultés, n’hésite pas à demander de l’aide au Binet Réseau en permanence ou sur PaniX.&lt;br /&gt;
&lt;br /&gt;
== Étape 6 : Configurer l’identité Git ==&lt;br /&gt;
&lt;br /&gt;
Pour finir, il faut configurer correctement ton identité sur Git. Dans ton terminal, tape les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;git config --global user.name &amp;quot;&amp;lt;Ton Nom&amp;gt;&amp;quot;&lt;br /&gt;
git config --global user.email &amp;quot;&amp;lt;ton.nom&amp;gt;@polytechnique.edu&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
En remplaçant &amp;lt;code&amp;gt;&amp;amp;lt;Ton Nom&amp;amp;gt;&amp;lt;/code&amp;gt; par ton nom et &amp;lt;code&amp;gt;&amp;amp;lt;ton.nom&amp;amp;gt;@polytechnique.edu&amp;lt;/code&amp;gt; par les valeurs adéquates.&lt;br /&gt;
&lt;br /&gt;
Félicitations ! À partir de là, tu peux utiliser Gitlab avec une authentification SSH.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lorsque tu clones un dépôt, veille bien à choisir le lien SSH et non HTTPS.&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/1/en&amp;diff=10966</id>
		<title>Translations:Mettre en place SSH pour Gitlab/1/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/1/en&amp;diff=10966"/>
		<updated>2026-08-11T11:46:23Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « The aim of this guide is to help you set up a computer to use GitLab with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on SSH and the BR’s advanced tips. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The aim of this guide is to help you set up a computer to use [[GitLab|GitLab]] with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on [[SSH]] and the BR’s [[Astuces_ssh|advanced tips]].&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/Page_display_title/en&amp;diff=10965</id>
		<title>Translations:Mettre en place SSH pour Gitlab/Page display title/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Mettre_en_place_SSH_pour_Gitlab/Page_display_title/en&amp;diff=10965"/>
		<updated>2026-08-11T11:45:28Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « Configuring SSH for Gitlab »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Configuring SSH for Gitlab&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10958</id>
		<title>Tuto pour le déploiement des sites avec Docker/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10958"/>
		<updated>2026-08-05T13:41:08Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « Now, you need to make &amp;#039;&amp;#039;your&amp;#039;&amp;#039; app work in the docker container. For this, you need: »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;At the end of this tutorial you will be able to deploy your website (or service) on the servers of the BR! This allows you to benefit from a free, high-performance and robust infrastructure!&lt;br /&gt;
&lt;br /&gt;
Note: this tutorial may be a bit tricky, so please don’t hesitate to get in touch with a BRman to get help.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Comment_déployer_des_conteneurs_Docker_sur_l&amp;amp;#039;infrastructure_du_BR&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= How to deploy Docker containers on the infrastructure of the BR =&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This tutorial will walk you through :&lt;br /&gt;
* How to convert your website to a Docker service&lt;br /&gt;
* How to build it automatically on Gitlab-CI&lt;br /&gt;
* How to deploy it automatically on our servers&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Basics of git (videos [https://git-scm.com/video/what-is-version-control here] or the beginning of [https://git-scm.com/book/en/v2 this awesome online book]) ;&lt;br /&gt;
* Basics of containers (see a really good explanation [https://www.docker.com/resources/what-container here]) and of docker-compose (see the getting-started [https://docs.docker.com/compose/gettingstarted/ here]) ;&lt;br /&gt;
* Basics of web (see an [https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works introduction] on MDN) ;&lt;br /&gt;
* Basics of gitlab-ci (reading the [https://docs.gitlab.com/ee/ci/ getting-started] is recommended) ;&lt;br /&gt;
&lt;br /&gt;
== Existing architecture ==&lt;br /&gt;
&lt;br /&gt;
A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Interne:&lt;br /&gt;
&lt;br /&gt;
* [https://docs.docker.com/compose/ docker-compose] to deploy the correct environment for your containers ;&lt;br /&gt;
* [https://docs.traefik.io/v1.7/ traefik] as a reverse proxy to serve your site behind your endpoint, it is configured [https://gitlab.binets.fr/br/docker-default-services here] ;&lt;br /&gt;
* nginx to serve your site to the outside world (as all the binets sites).&lt;br /&gt;
&lt;br /&gt;
== How to convert your website to a Docker service ==&lt;br /&gt;
&lt;br /&gt;
The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile]&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;Docker container&#039;&#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&#039;ll need to install &#039;&#039;Docker&#039;&#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer].&lt;br /&gt;
&lt;br /&gt;
We assume your project is hosted on the [https://gitlab.binets.fr BR&#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it.&lt;br /&gt;
&lt;br /&gt;
* Dockerfile&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
FROM hello-world&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* docker-compose.yaml&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
# this is a docker-compose meant for local testing of the deployment image.&lt;br /&gt;
# for the real deployment, go to the docker-services BR gitlab project&lt;br /&gt;
&lt;br /&gt;
version: &amp;quot;3&amp;quot;&lt;br /&gt;
services:&lt;br /&gt;
  app:&lt;br /&gt;
    build:&lt;br /&gt;
      context: ..&lt;br /&gt;
      dockerfile: deployment/Dockerfile&lt;br /&gt;
#    ports:&lt;br /&gt;
#      - &amp;quot;8000:8000&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then open a terminal in this directory and type &amp;lt;code&amp;gt;docker compose up --build&amp;lt;/code&amp;gt;. If everything went well, you see a nice message from Docker telling you everything is working!&lt;br /&gt;
&lt;br /&gt;
Now, you need to make &#039;&#039;your&#039;&#039; app work in the docker container. For this, you need:&lt;br /&gt;
&lt;br /&gt;
* To update the Dockerfile to install everything you need. The following works for a basic (Django) python app :&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
FROM python:3&lt;br /&gt;
&lt;br /&gt;
# copies all the code inside the container&lt;br /&gt;
COPY . /my_super_project&lt;br /&gt;
&lt;br /&gt;
WORKDIR /my_super_project&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
CMD python3 manage.py runserver&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To update the docker-compose file to expose the port you need (uncomment the corresponding line in the dockerfile).&lt;br /&gt;
&lt;br /&gt;
=== How to handle persistant data ===&lt;br /&gt;
&lt;br /&gt;
If you app uses an external database or need to not lose some files accross resets, you should use &#039;&#039;docker volumes&#039;&#039; with or without a &#039;&#039;postgres&#039;&#039; image. The [https://gitlab.binets.fr/br/docker-services/-/blob/master/docker-compose.site-jtx.yml?ref_type=heads jtx-docker-compose] might help you understand what you need.&lt;br /&gt;
&lt;br /&gt;
=== How to handle secrets  ===&lt;br /&gt;
&lt;br /&gt;
Often your app has some secrets in a file (such as &#039;&#039;.env&#039;&#039;) that is not in Git. DO NOT put it in git (or all your secrets will be stolen !). Later we are going to see how to securely make them available for the automatic gitlab build.&lt;br /&gt;
&lt;br /&gt;
== Automatic build ==&lt;br /&gt;
&lt;br /&gt;
We will you &#039;&#039;gitlab continuous integration&#039;&#039; to build your docker image directly on the BR&#039;s servers. Write the following into a file name &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; at the root of your repository :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
variables:&lt;br /&gt;
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_PIPELINE_IID&lt;br /&gt;
  PROJECT: mySuperProject&lt;br /&gt;
&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only: # put here the git branches you want the job to run on :&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039; # disables TLS in docker-in-docker (not needed)&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you commit this file to Gitlab, you should see a new job appear (or look under Build/jobs). Your image should build correctly (if not, it means something is not available to gitlab that is when you build on your computer. Read the job logs and try to fix it !)&lt;br /&gt;
&lt;br /&gt;
=== Checking the image ===&lt;br /&gt;
&lt;br /&gt;
This step is optional, but it is the easiest way to debug your image ! You can run it locally like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
docker login registry.binets.fr&lt;br /&gt;
docker run --rm registry.binets.fr/&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;:&amp;lt;image&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;image&amp;lt;/code&amp;gt; is the number of the image (available in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Deploy -&amp;gt; Container registry&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;&amp;lt;/code&amp;gt; is the same as in your project Gitlab URL.&lt;br /&gt;
&lt;br /&gt;
Typically, your app won&#039;t start because you forgot a secret file (see below how to manage that !).&lt;br /&gt;
&lt;br /&gt;
== Automatic deployment ==&lt;br /&gt;
&lt;br /&gt;
We will now add a second CI job to your repository to deploy your image. It will trigger &#039;&#039;another&#039;&#039; CI pipeline of [https://gitlab.binets.fr/br/docker-services br/docker-services]. This pipeline has the rights to deploy on &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt;, and does so using a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file. To trigger it, add the following to your &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  only:&lt;br /&gt;
    - stable&lt;br /&gt;
  image: debian:latest&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --fail-with-body --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=$PROJECT --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure the variable &amp;lt;code&amp;gt;PROJECT&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; is correct : our pipeline will deploy the file named &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order to create the correct &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt; file, you will need to create a Merge Request on [https://gitlab.binets.fr/br/docker-services br/docker-services], or send a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file to a BRman. The [https://gitlab.binets.fr/br/docker-services br/docker-services] is full of examples and a basic one is explained below :&lt;br /&gt;
&lt;br /&gt;
=== Extra parameters and secrets ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way is still visible to the BR and everyone that has maintainer access to you repository ! If you need help setting up, don&#039;t hesitate to ask for help from the BR !&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also pass any parameter needed in the compose file by adding arguments to the cURL call like so : &amp;lt;code&amp;gt;--form variables[MY_SUPER_VARIABLE]=&amp;quot;elle vaut 42!&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pass secret environnements variables, store them in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Variables&amp;lt;/code&amp;gt; and make sure they are &amp;quot;protected&amp;quot; and &amp;quot;masked&amp;quot;. Pass them like so &amp;lt;code&amp;gt;--form variables[MY_PASSWORD]=$PASSWORD_STORED_IN_GITLAB&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Secret files ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way too is visible to the BR and everyone that has &#039;&#039;ANY&#039;&#039; access to you repository (because they can get the docker image) ! So only do this for a private registry or make sure your setting &amp;lt;code&amp;gt;Settings -&amp;gt; General -&amp;gt; Visibility, project features, permissions&amp;lt;/code&amp;gt; only allows for registry access for members&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Another way to store secrets in your Gitlab repo is &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Secure-files&amp;lt;/code&amp;gt;. You can upload any (small) secret file here and it will not be exposed ! You can downlod it at buildtime like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &amp;quot;&amp;quot;&lt;br /&gt;
    # !!! where to download our secure .env file &lt;br /&gt;
    SECURE_FILES_DOWNLOAD_PATH: &amp;quot;.&amp;quot;&lt;br /&gt;
  script:&lt;br /&gt;
    # !!! download secure .env file&lt;br /&gt;
    - apk add --no-cache curl bash&lt;br /&gt;
    - curl --silent &amp;quot;https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer&amp;quot; | bash&lt;br /&gt;
    # build docker image&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
    - echo &amp;quot;=&amp;gt; pushed $IMAGE_TAG&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Private repository ===&lt;br /&gt;
&lt;br /&gt;
Keeping your repository private can be beneficial for security or privacy. But it require an extra step for the BR to access the docker image. We wille pass a [https://docs.gitlab.com/ee/user/project/deploy_tokens/#gitlab-deploy-token CI deploy token] as cURL parameter.&lt;br /&gt;
&lt;br /&gt;
* Go to your &amp;lt;code&amp;gt;Settings -&amp;gt; Repository -&amp;gt; Deploy token&amp;lt;/code&amp;gt; and create a token name exactly &amp;lt;code&amp;gt;gitlab-deploy-token&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Add the following parameters to the cURL call in your CI deploy job : &amp;lt;code&amp;gt; --form variables[OPTIONAL_PRIVATE_CI_REGISTRY]=$CI_REGISTRY --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_USER]=$CI_DEPLOY_USER --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_PASSWORD]=$CI_DEPLOY_PASSWORD &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
You want to deploy the QDJ site with docker, and bind it to the server name &amp;lt;code&amp;gt;qdj.binets.fr&amp;lt;/code&amp;gt;. Your site is running on flask and uses a postgresql database.&lt;br /&gt;
&lt;br /&gt;
=== Pre-existant configuration ===&lt;br /&gt;
&lt;br /&gt;
You have a little &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# Base image: python3&lt;br /&gt;
FROM python:3&lt;br /&gt;
WORKDIR /usr/src/app&lt;br /&gt;
&lt;br /&gt;
# Install dependacies&lt;br /&gt;
COPY requirements.txt ./&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
&lt;br /&gt;
# Copy application files&lt;br /&gt;
COPY . .&lt;br /&gt;
&lt;br /&gt;
EXPOSE 5000/tcp&lt;br /&gt;
&lt;br /&gt;
# the command runs the migrations and then launches gunicorn to serve the app&lt;br /&gt;
CMD python -m flask db upgrade &amp;amp;amp;&amp;amp;amp; gunicorn -b :5000 qdj:app&amp;lt;/pre&amp;gt;&lt;br /&gt;
You have the following &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
  db:&lt;br /&gt;
    # Use a small postgres image, as we don&#039;t need anything on this container&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: somepassword&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    # store the data on a persistent file&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
    restart: always&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    # Use the image from Dockerfile&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:somepassword@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    # Tells to docker to start app after db (otherwise flask crashes)&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    # Always restart on crash&lt;br /&gt;
    restart: always&lt;br /&gt;
    &lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Production &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We will adapt your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file in order to bind your site to the hostname :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First let&#039;s connect your &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; container to the global network. We won&#039;t bind the &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; container to the global network to protect it from intruders. [[File:https://cloud.binets.fr/s/QTgY55AapFDTyyW/preview|Network graph in endalcher]] We will add network configuration to the &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to enable the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add at the bottom of the file:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to connect &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; to the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add to the &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; configuration:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  - web&lt;br /&gt;
  - default&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Then we can add labels to tell &amp;lt;code&amp;gt;traefik&amp;lt;/code&amp;gt; to match the hostname to a packet going to &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;labels:&lt;br /&gt;
    - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.port=5000&amp;quot;&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This gives us the following &amp;lt;code&amp;gt;docker-compose.qdj.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
&lt;br /&gt;
  db:&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    restart: always&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: qdjpw&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:qdjpw@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    restart: always&lt;br /&gt;
    networks:&lt;br /&gt;
      - web&lt;br /&gt;
      - default&lt;br /&gt;
    labels:&lt;br /&gt;
      - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.port=5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&lt;br /&gt;
&lt;br /&gt;
networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&lt;br /&gt;
This file goes into the [https://gitlab.binets.fr/br/docker-services br/docker-services] repository, it will be used by the triggered pipeline to create your containers.&lt;br /&gt;
&lt;br /&gt;
=== Triggering pipelines with Gitlab CI ===&lt;br /&gt;
&lt;br /&gt;
In this pipeline, we will need to add 2 jobs:&lt;br /&gt;
&lt;br /&gt;
* one to build the docker image using the &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;&lt;br /&gt;
* one to trigger the [https://gitlab.binets.fr/br/docker-services br/docker-services] pipeline to create the containers.&lt;br /&gt;
&lt;br /&gt;
To build the docker image, we will use the template do so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - master&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039;&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&amp;lt;/source&amp;gt;&lt;br /&gt;
The second job is rather tricky. We will use &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; to trigger the pipeline, using [https://docs.gitlab.com/ce/ci/triggers/README.html Gitlab Pipeline API]. This call is secured by a trigger token, which should be saved into your project variables as &amp;lt;code&amp;gt;$TRIGGER_TOKEN&amp;lt;/code&amp;gt;. This is what the job looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=qdj --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&amp;lt;/source&amp;gt;&lt;br /&gt;
Pay attention to this syntax because debugging this api call takes a lot of time...&lt;br /&gt;
&lt;br /&gt;
If you want to add variables that will be used in your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;, add other arguments to &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; like &amp;lt;code&amp;gt;--form variables[WELCOME_MESSAGE]=&amp;amp;quot;Hello World!&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can see an example of a CI using this in the [https://gitlab.binets.fr/br/qdj br/qdj] repo.&lt;br /&gt;
&lt;br /&gt;
Note: for BR project, you can use the &amp;lt;code&amp;gt;trigger&amp;lt;/code&amp;gt; syntax in the API call since you don&#039;t need autorisation.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
* In 2017, the BR16 set up a [https://kubernetes.io/ Kubernetes] cluster. They managed to set up a workflow to deploy seamlessly from gitlab on that cluster. However, the configuration was hard to maintain and the BR17 was not able to keep it going.&lt;br /&gt;
* In 2018, the BR17 (Oliver Facklam + Hadrien Renaud) set up a small docker service on a computer from the Salle Informatiques&lt;br /&gt;
&lt;br /&gt;
= Developping a site for BR docker deployement =&lt;br /&gt;
&lt;br /&gt;
Docker allows for most technologies to be abstracted into a container and thus most - if not all - sites can be deployed in docker. However, here is a bit of advice to make deployement less painful :&lt;br /&gt;
&lt;br /&gt;
* Before using a particular external service (something that should run in a seperate container), check that a well supported docker image exists and with a BRman that there are no other constraints (for example, using a MinIO will go through a seperate dedicated server that already exists rather than a container).&lt;br /&gt;
* Use a postgres database to get access to an admin website for your server.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker&amp;diff=10957</id>
		<title>Tuto pour le déploiement des sites avec Docker</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker&amp;diff=10957"/>
		<updated>2026-08-05T12:44:01Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
A la fin de ce tuto, vous pourrez déployer votre site (ou service) sur les serveurs du BR ! Ceci permet de profiter d&#039;une infrastructure gratuite, performante et robuste !&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
Note : ce tutoriel peut être délicat, n&#039;hésitez pas à contacter un BRman pour obtenir de l&#039;aide.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
= Comment déployer des conteneurs Docker sur l&#039;infrastructure du BR = &amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Overview == &amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
This tutorial will walk you through :&lt;br /&gt;
* How to convert your website to a Docker service&lt;br /&gt;
* How to build it automatically on Gitlab-CI&lt;br /&gt;
* How to deploy it automatically on our servers&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Requirements == &amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* Basics of git (videos [https://git-scm.com/video/what-is-version-control here] or the beginning of [https://git-scm.com/book/en/v2 this awesome online book]) ;&lt;br /&gt;
* Basics of containers (see a really good explanation [https://www.docker.com/resources/what-container here]) and of docker-compose (see the getting-started [https://docs.docker.com/compose/gettingstarted/ here]) ;&lt;br /&gt;
* Basics of web (see an [https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works introduction] on MDN) ;&lt;br /&gt;
* Basics of gitlab-ci (reading the [https://docs.gitlab.com/ee/ci/ getting-started] is recommended) ;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Existing architecture == &amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Internet:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* [https://docs.docker.com/compose/ docker-compose] to deploy the correct environment for your containers ;&lt;br /&gt;
* [https://docs.traefik.io/v1.7/ traefik] as a reverse proxy to serve your site behind your endpoint, it is configured [https://gitlab.binets.fr/br/docker-default-services here] ;&lt;br /&gt;
* nginx to serve your site to the outside world (as all the binets sites).&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== How to convert your website to a Docker service == &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
A &#039;&#039;Docker container&#039;&#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&#039;ll need to install &#039;&#039;Docker&#039;&#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
We assume your project is hosted on the [https://gitlab.binets.fr BR&#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Dockerfile&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
FROM hello-world&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* docker-compose.yaml&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
# this is a docker-compose meant for local testing of the deployment image.&lt;br /&gt;
# for the real deployment, go to the docker-services BR gitlab project&lt;br /&gt;
&lt;br /&gt;
version: &amp;quot;3&amp;quot;&lt;br /&gt;
services:&lt;br /&gt;
  app:&lt;br /&gt;
    build:&lt;br /&gt;
      context: ..&lt;br /&gt;
      dockerfile: deployment/Dockerfile&lt;br /&gt;
#    ports:&lt;br /&gt;
#      - &amp;quot;8000:8000&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
Then open a terminal in this directory and type &amp;lt;code&amp;gt;docker compose up --build&amp;lt;/code&amp;gt;. If everything went well, you see a nice message from Docker telling you everything is working !&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
Now, you need to make &#039;&#039;your&#039;&#039; app work in the docker container. For this, you need:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
* To update the Dockerfile to install everything you need. The following works for a basic (Django) python app :&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
FROM python:3&lt;br /&gt;
&lt;br /&gt;
# copies all the code inside the container&lt;br /&gt;
COPY . /my_super_project&lt;br /&gt;
&lt;br /&gt;
WORKDIR /my_super_project&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
CMD python3 manage.py runserver&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To update the docker-compose file to expose the port you need (uncomment the corresponding line in the dockerfile).&lt;br /&gt;
&lt;br /&gt;
=== How to handle persistant data ===&lt;br /&gt;
&lt;br /&gt;
If you app uses an external database or need to not lose some files accross resets, you should use &#039;&#039;docker volumes&#039;&#039; with or without a &#039;&#039;postgres&#039;&#039; image. The [https://gitlab.binets.fr/br/docker-services/-/blob/master/docker-compose.site-jtx.yml?ref_type=heads jtx-docker-compose] might help you understand what you need.&lt;br /&gt;
&lt;br /&gt;
=== How to handle secrets  ===&lt;br /&gt;
&lt;br /&gt;
Often your app has some secrets in a file (such as &#039;&#039;.env&#039;&#039;) that is not in Git. DO NOT put it in git (or all your secrets will be stolen !). Later we are going to see how to securely make them available for the automatic gitlab build.&lt;br /&gt;
&lt;br /&gt;
== Automatic build ==&lt;br /&gt;
&lt;br /&gt;
We will you &#039;&#039;gitlab continuous integration&#039;&#039; to build your docker image directly on the BR&#039;s servers. Write the following into a file name &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; at the root of your repository :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
variables:&lt;br /&gt;
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_PIPELINE_IID&lt;br /&gt;
  PROJECT: mySuperProject&lt;br /&gt;
&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only: # put here the git branches you want the job to run on :&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039; # disables TLS in docker-in-docker (not needed)&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you commit this file to Gitlab, you should see a new job appear (or look under Build/jobs). Your image should build correctly (if not, it means something is not available to gitlab that is when you build on your computer. Read the job logs and try to fix it !)&lt;br /&gt;
&lt;br /&gt;
=== Checking the image ===&lt;br /&gt;
&lt;br /&gt;
This step is optional, but it is the easiest way to debug your image ! You can run it locally like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
docker login registry.binets.fr&lt;br /&gt;
docker run --rm registry.binets.fr/&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;:&amp;lt;image&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;image&amp;lt;/code&amp;gt; is the number of the image (available in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Deploy -&amp;gt; Container registry&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;&amp;lt;/code&amp;gt; is the same as in your project Gitlab URL.&lt;br /&gt;
&lt;br /&gt;
Typically, your app won&#039;t start because you forgot a secret file (see below how to manage that !).&lt;br /&gt;
&lt;br /&gt;
== Automatic deployment ==&lt;br /&gt;
&lt;br /&gt;
We will now add a second CI job to your repository to deploy your image. It will trigger &#039;&#039;another&#039;&#039; CI pipeline of [https://gitlab.binets.fr/br/docker-services br/docker-services]. This pipeline has the rights to deploy on &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt;, and does so using a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file. To trigger it, add the following to your &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  only:&lt;br /&gt;
    - stable&lt;br /&gt;
  image: debian:latest&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --fail-with-body --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=$PROJECT --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure the variable &amp;lt;code&amp;gt;PROJECT&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; is correct : our pipeline will deploy the file named &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order to create the correct &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt; file, you will need to create a Merge Request on [https://gitlab.binets.fr/br/docker-services br/docker-services], or send a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file to a BRman. The [https://gitlab.binets.fr/br/docker-services br/docker-services] is full of examples and a basic one is explained below :&lt;br /&gt;
&lt;br /&gt;
=== Extra parameters and secrets ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way is still visible to the BR and everyone that has maintainer access to you repository ! If you need help setting up, don&#039;t hesitate to ask for help from the BR !&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also pass any parameter needed in the compose file by adding arguments to the cURL call like so : &amp;lt;code&amp;gt;--form variables[MY_SUPER_VARIABLE]=&amp;quot;elle vaut 42!&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pass secret environnements variables, store them in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Variables&amp;lt;/code&amp;gt; and make sure they are &amp;quot;protected&amp;quot; and &amp;quot;masked&amp;quot;. Pass them like so &amp;lt;code&amp;gt;--form variables[MY_PASSWORD]=$PASSWORD_STORED_IN_GITLAB&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Secret files ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way too is visible to the BR and everyone that has &#039;&#039;ANY&#039;&#039; access to you repository (because they can get the docker image) ! So only do this for a private registry or make sure your setting &amp;lt;code&amp;gt;Settings -&amp;gt; General -&amp;gt; Visibility, project features, permissions&amp;lt;/code&amp;gt; only allows for registry access for members&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Another way to store secrets in your Gitlab repo is &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Secure-files&amp;lt;/code&amp;gt;. You can upload any (small) secret file here and it will not be exposed ! You can downlod it at buildtime like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &amp;quot;&amp;quot;&lt;br /&gt;
    # !!! where to download our secure .env file &lt;br /&gt;
    SECURE_FILES_DOWNLOAD_PATH: &amp;quot;.&amp;quot;&lt;br /&gt;
  script:&lt;br /&gt;
    # !!! download secure .env file&lt;br /&gt;
    - apk add --no-cache curl bash&lt;br /&gt;
    - curl --silent &amp;quot;https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer&amp;quot; | bash&lt;br /&gt;
    # build docker image&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
    - echo &amp;quot;=&amp;gt; pushed $IMAGE_TAG&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Private repository ===&lt;br /&gt;
&lt;br /&gt;
Keeping your repository private can be beneficial for security or privacy. But it require an extra step for the BR to access the docker image. We wille pass a [https://docs.gitlab.com/ee/user/project/deploy_tokens/#gitlab-deploy-token CI deploy token] as cURL parameter.&lt;br /&gt;
&lt;br /&gt;
* Go to your &amp;lt;code&amp;gt;Settings -&amp;gt; Repository -&amp;gt; Deploy token&amp;lt;/code&amp;gt; and create a token name exactly &amp;lt;code&amp;gt;gitlab-deploy-token&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Add the following parameters to the cURL call in your CI deploy job : &amp;lt;code&amp;gt; --form variables[OPTIONAL_PRIVATE_CI_REGISTRY]=$CI_REGISTRY --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_USER]=$CI_DEPLOY_USER --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_PASSWORD]=$CI_DEPLOY_PASSWORD &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
You want to deploy the QDJ site with docker, and bind it to the server name &amp;lt;code&amp;gt;qdj.binets.fr&amp;lt;/code&amp;gt;. Your site is running on flask and uses a postgresql database.&lt;br /&gt;
&lt;br /&gt;
=== Pre-existant configuration ===&lt;br /&gt;
&lt;br /&gt;
You have a little &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# Base image: python3&lt;br /&gt;
FROM python:3&lt;br /&gt;
WORKDIR /usr/src/app&lt;br /&gt;
&lt;br /&gt;
# Install dependacies&lt;br /&gt;
COPY requirements.txt ./&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
&lt;br /&gt;
# Copy application files&lt;br /&gt;
COPY . .&lt;br /&gt;
&lt;br /&gt;
EXPOSE 5000/tcp&lt;br /&gt;
&lt;br /&gt;
# the command runs the migrations and then launches gunicorn to serve the app&lt;br /&gt;
CMD python -m flask db upgrade &amp;amp;amp;&amp;amp;amp; gunicorn -b :5000 qdj:app&amp;lt;/pre&amp;gt;&lt;br /&gt;
You have the following &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
  db:&lt;br /&gt;
    # Use a small postgres image, as we don&#039;t need anything on this container&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: somepassword&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    # store the data on a persistent file&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
    restart: always&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    # Use the image from Dockerfile&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:somepassword@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    # Tells to docker to start app after db (otherwise flask crashes)&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    # Always restart on crash&lt;br /&gt;
    restart: always&lt;br /&gt;
    &lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Production &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We will adapt your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file in order to bind your site to the hostname :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First let&#039;s connect your &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; container to the global network. We won&#039;t bind the &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; container to the global network to protect it from intruders. [[File:https://cloud.binets.fr/s/QTgY55AapFDTyyW/preview|Network graph in endalcher]] We will add network configuration to the &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to enable the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add at the bottom of the file:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to connect &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; to the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add to the &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; configuration:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  - web&lt;br /&gt;
  - default&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Then we can add labels to tell &amp;lt;code&amp;gt;traefik&amp;lt;/code&amp;gt; to match the hostname to a packet going to &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;labels:&lt;br /&gt;
    - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.port=5000&amp;quot;&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This gives us the following &amp;lt;code&amp;gt;docker-compose.qdj.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
&lt;br /&gt;
  db:&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    restart: always&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: qdjpw&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:qdjpw@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    restart: always&lt;br /&gt;
    networks:&lt;br /&gt;
      - web&lt;br /&gt;
      - default&lt;br /&gt;
    labels:&lt;br /&gt;
      - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.port=5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&lt;br /&gt;
&lt;br /&gt;
networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&lt;br /&gt;
This file goes into the [https://gitlab.binets.fr/br/docker-services br/docker-services] repository, it will be used by the triggered pipeline to create your containers.&lt;br /&gt;
&lt;br /&gt;
=== Triggering pipelines with Gitlab CI ===&lt;br /&gt;
&lt;br /&gt;
In this pipeline, we will need to add 2 jobs:&lt;br /&gt;
&lt;br /&gt;
* one to build the docker image using the &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;&lt;br /&gt;
* one to trigger the [https://gitlab.binets.fr/br/docker-services br/docker-services] pipeline to create the containers.&lt;br /&gt;
&lt;br /&gt;
To build the docker image, we will use the template do so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - master&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039;&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&amp;lt;/source&amp;gt;&lt;br /&gt;
The second job is rather tricky. We will use &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; to trigger the pipeline, using [https://docs.gitlab.com/ce/ci/triggers/README.html Gitlab Pipeline API]. This call is secured by a trigger token, which should be saved into your project variables as &amp;lt;code&amp;gt;$TRIGGER_TOKEN&amp;lt;/code&amp;gt;. This is what the job looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=qdj --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&amp;lt;/source&amp;gt;&lt;br /&gt;
Pay attention to this syntax because debugging this api call takes a lot of time...&lt;br /&gt;
&lt;br /&gt;
If you want to add variables that will be used in your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;, add other arguments to &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; like &amp;lt;code&amp;gt;--form variables[WELCOME_MESSAGE]=&amp;amp;quot;Hello World!&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can see an example of a CI using this in the [https://gitlab.binets.fr/br/qdj br/qdj] repo.&lt;br /&gt;
&lt;br /&gt;
Note: for BR project, you can use the &amp;lt;code&amp;gt;trigger&amp;lt;/code&amp;gt; syntax in the API call since you don&#039;t need autorisation.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
* In 2017, the BR16 set up a [https://kubernetes.io/ Kubernetes] cluster. They managed to set up a workflow to deploy seamlessly from gitlab on that cluster. However, the configuration was hard to maintain and the BR17 was not able to keep it going.&lt;br /&gt;
* In 2018, the BR17 (Oliver Facklam + Hadrien Renaud) set up a small docker service on a computer from the Salle Informatiques&lt;br /&gt;
&lt;br /&gt;
= Developping a site for BR docker deployement =&lt;br /&gt;
&lt;br /&gt;
Docker allows for most technologies to be abstracted into a container and thus most - if not all - sites can be deployed in docker. However, here is a bit of advice to make deployement less painful :&lt;br /&gt;
&lt;br /&gt;
* Before using a particular external service (something that should run in a seperate container), check that a well supported docker image exists and with a BRman that there are no other constraints (for example, using a MinIO will go through a seperate dedicated server that already exists rather than a container).&lt;br /&gt;
* Use a postgres database to get access to an admin website for your server.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/17/en&amp;diff=10956</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/17/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/17/en&amp;diff=10956"/>
		<updated>2026-08-05T12:41:11Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « * To update the Dockerfile to install everything you need. The following works for a basic (Django) python app : »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* To update the Dockerfile to install everything you need. The following works for a basic (Django) python app :&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/16/en&amp;diff=10955</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/16/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/16/en&amp;diff=10955"/>
		<updated>2026-08-05T12:41:04Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « Now, you need to make &amp;#039;&amp;#039;your&amp;#039;&amp;#039; app work in the docker container. For this, you need: »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Now, you need to make &#039;&#039;your&#039;&#039; app work in the docker container. For this, you need:&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/15/en&amp;diff=10954</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/15/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/15/en&amp;diff=10954"/>
		<updated>2026-08-05T12:40:59Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « Then open a terminal in this directory and type &amp;lt;code&amp;gt;docker compose up --build&amp;lt;/code&amp;gt;. If everything went well, you see a nice message from Docker telling you everything is working! »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Then open a terminal in this directory and type &amp;lt;code&amp;gt;docker compose up --build&amp;lt;/code&amp;gt;. If everything went well, you see a nice message from Docker telling you everything is working!&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10953</id>
		<title>Tuto pour le déploiement des sites avec Docker/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10953"/>
		<updated>2026-08-05T12:40:56Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « We assume your project is hosted on the [https://gitlab.binets.fr BR&amp;#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;At the end of this tutorial you will be able to deploy your website (or service) on the servers of the BR! This allows you to benefit from a free, high-performance and robust infrastructure!&lt;br /&gt;
&lt;br /&gt;
Note: this tutorial may be a bit tricky, so please don’t hesitate to get in touch with a BRman to get help.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Comment_déployer_des_conteneurs_Docker_sur_l&amp;amp;#039;infrastructure_du_BR&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= How to deploy Docker containers on the infrastructure of the BR =&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This tutorial will walk you through :&lt;br /&gt;
* How to convert your website to a Docker service&lt;br /&gt;
* How to build it automatically on Gitlab-CI&lt;br /&gt;
* How to deploy it automatically on our servers&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Basics of git (videos [https://git-scm.com/video/what-is-version-control here] or the beginning of [https://git-scm.com/book/en/v2 this awesome online book]) ;&lt;br /&gt;
* Basics of containers (see a really good explanation [https://www.docker.com/resources/what-container here]) and of docker-compose (see the getting-started [https://docs.docker.com/compose/gettingstarted/ here]) ;&lt;br /&gt;
* Basics of web (see an [https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works introduction] on MDN) ;&lt;br /&gt;
* Basics of gitlab-ci (reading the [https://docs.gitlab.com/ee/ci/ getting-started] is recommended) ;&lt;br /&gt;
&lt;br /&gt;
== Existing architecture ==&lt;br /&gt;
&lt;br /&gt;
A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Interne:&lt;br /&gt;
&lt;br /&gt;
* [https://docs.docker.com/compose/ docker-compose] to deploy the correct environment for your containers ;&lt;br /&gt;
* [https://docs.traefik.io/v1.7/ traefik] as a reverse proxy to serve your site behind your endpoint, it is configured [https://gitlab.binets.fr/br/docker-default-services here] ;&lt;br /&gt;
* nginx to serve your site to the outside world (as all the binets sites).&lt;br /&gt;
&lt;br /&gt;
== How to convert your website to a Docker service ==&lt;br /&gt;
&lt;br /&gt;
The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile]&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;Docker container&#039;&#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&#039;ll need to install &#039;&#039;Docker&#039;&#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer].&lt;br /&gt;
&lt;br /&gt;
We assume your project is hosted on the [https://gitlab.binets.fr BR&#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it.&lt;br /&gt;
&lt;br /&gt;
* Dockerfile&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
FROM hello-world&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* docker-compose.yaml&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
# this is a docker-compose meant for local testing of the deployment image.&lt;br /&gt;
# for the real deployment, go to the docker-services BR gitlab project&lt;br /&gt;
&lt;br /&gt;
version: &amp;quot;3&amp;quot;&lt;br /&gt;
services:&lt;br /&gt;
  app:&lt;br /&gt;
    build:&lt;br /&gt;
      context: ..&lt;br /&gt;
      dockerfile: deployment/Dockerfile&lt;br /&gt;
#    ports:&lt;br /&gt;
#      - &amp;quot;8000:8000&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Then open a terminal in this directory and type &amp;lt;code&amp;gt;docker compose up --build&amp;lt;/code&amp;gt;. If everything went well, you see a nice message from Docker telling you everything is working !&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Now, you need to make &#039;&#039;your&#039;&#039; app work in the docker container. For this, you need:&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* To update the Dockerfile to install everything you need. The following works for a basic (Django) python app :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
FROM python:3&lt;br /&gt;
&lt;br /&gt;
# copies all the code inside the container&lt;br /&gt;
COPY . /my_super_project&lt;br /&gt;
&lt;br /&gt;
WORKDIR /my_super_project&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
CMD python3 manage.py runserver&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To update the docker-compose file to expose the port you need (uncomment the corresponding line in the dockerfile).&lt;br /&gt;
&lt;br /&gt;
=== How to handle persistant data ===&lt;br /&gt;
&lt;br /&gt;
If you app uses an external database or need to not lose some files accross resets, you should use &#039;&#039;docker volumes&#039;&#039; with or without a &#039;&#039;postgres&#039;&#039; image. The [https://gitlab.binets.fr/br/docker-services/-/blob/master/docker-compose.site-jtx.yml?ref_type=heads jtx-docker-compose] might help you understand what you need.&lt;br /&gt;
&lt;br /&gt;
=== How to handle secrets  ===&lt;br /&gt;
&lt;br /&gt;
Often your app has some secrets in a file (such as &#039;&#039;.env&#039;&#039;) that is not in Git. DO NOT put it in git (or all your secrets will be stolen !). Later we are going to see how to securely make them available for the automatic gitlab build.&lt;br /&gt;
&lt;br /&gt;
== Automatic build ==&lt;br /&gt;
&lt;br /&gt;
We will you &#039;&#039;gitlab continuous integration&#039;&#039; to build your docker image directly on the BR&#039;s servers. Write the following into a file name &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; at the root of your repository :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
variables:&lt;br /&gt;
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_PIPELINE_IID&lt;br /&gt;
  PROJECT: mySuperProject&lt;br /&gt;
&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only: # put here the git branches you want the job to run on :&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039; # disables TLS in docker-in-docker (not needed)&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you commit this file to Gitlab, you should see a new job appear (or look under Build/jobs). Your image should build correctly (if not, it means something is not available to gitlab that is when you build on your computer. Read the job logs and try to fix it !)&lt;br /&gt;
&lt;br /&gt;
=== Checking the image ===&lt;br /&gt;
&lt;br /&gt;
This step is optional, but it is the easiest way to debug your image ! You can run it locally like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
docker login registry.binets.fr&lt;br /&gt;
docker run --rm registry.binets.fr/&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;:&amp;lt;image&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;image&amp;lt;/code&amp;gt; is the number of the image (available in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Deploy -&amp;gt; Container registry&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;&amp;lt;/code&amp;gt; is the same as in your project Gitlab URL.&lt;br /&gt;
&lt;br /&gt;
Typically, your app won&#039;t start because you forgot a secret file (see below how to manage that !).&lt;br /&gt;
&lt;br /&gt;
== Automatic deployment ==&lt;br /&gt;
&lt;br /&gt;
We will now add a second CI job to your repository to deploy your image. It will trigger &#039;&#039;another&#039;&#039; CI pipeline of [https://gitlab.binets.fr/br/docker-services br/docker-services]. This pipeline has the rights to deploy on &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt;, and does so using a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file. To trigger it, add the following to your &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  only:&lt;br /&gt;
    - stable&lt;br /&gt;
  image: debian:latest&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --fail-with-body --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=$PROJECT --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure the variable &amp;lt;code&amp;gt;PROJECT&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; is correct : our pipeline will deploy the file named &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order to create the correct &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt; file, you will need to create a Merge Request on [https://gitlab.binets.fr/br/docker-services br/docker-services], or send a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file to a BRman. The [https://gitlab.binets.fr/br/docker-services br/docker-services] is full of examples and a basic one is explained below :&lt;br /&gt;
&lt;br /&gt;
=== Extra parameters and secrets ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way is still visible to the BR and everyone that has maintainer access to you repository ! If you need help setting up, don&#039;t hesitate to ask for help from the BR !&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also pass any parameter needed in the compose file by adding arguments to the cURL call like so : &amp;lt;code&amp;gt;--form variables[MY_SUPER_VARIABLE]=&amp;quot;elle vaut 42!&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pass secret environnements variables, store them in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Variables&amp;lt;/code&amp;gt; and make sure they are &amp;quot;protected&amp;quot; and &amp;quot;masked&amp;quot;. Pass them like so &amp;lt;code&amp;gt;--form variables[MY_PASSWORD]=$PASSWORD_STORED_IN_GITLAB&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Secret files ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way too is visible to the BR and everyone that has &#039;&#039;ANY&#039;&#039; access to you repository (because they can get the docker image) ! So only do this for a private registry or make sure your setting &amp;lt;code&amp;gt;Settings -&amp;gt; General -&amp;gt; Visibility, project features, permissions&amp;lt;/code&amp;gt; only allows for registry access for members&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Another way to store secrets in your Gitlab repo is &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Secure-files&amp;lt;/code&amp;gt;. You can upload any (small) secret file here and it will not be exposed ! You can downlod it at buildtime like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &amp;quot;&amp;quot;&lt;br /&gt;
    # !!! where to download our secure .env file &lt;br /&gt;
    SECURE_FILES_DOWNLOAD_PATH: &amp;quot;.&amp;quot;&lt;br /&gt;
  script:&lt;br /&gt;
    # !!! download secure .env file&lt;br /&gt;
    - apk add --no-cache curl bash&lt;br /&gt;
    - curl --silent &amp;quot;https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer&amp;quot; | bash&lt;br /&gt;
    # build docker image&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
    - echo &amp;quot;=&amp;gt; pushed $IMAGE_TAG&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Private repository ===&lt;br /&gt;
&lt;br /&gt;
Keeping your repository private can be beneficial for security or privacy. But it require an extra step for the BR to access the docker image. We wille pass a [https://docs.gitlab.com/ee/user/project/deploy_tokens/#gitlab-deploy-token CI deploy token] as cURL parameter.&lt;br /&gt;
&lt;br /&gt;
* Go to your &amp;lt;code&amp;gt;Settings -&amp;gt; Repository -&amp;gt; Deploy token&amp;lt;/code&amp;gt; and create a token name exactly &amp;lt;code&amp;gt;gitlab-deploy-token&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Add the following parameters to the cURL call in your CI deploy job : &amp;lt;code&amp;gt; --form variables[OPTIONAL_PRIVATE_CI_REGISTRY]=$CI_REGISTRY --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_USER]=$CI_DEPLOY_USER --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_PASSWORD]=$CI_DEPLOY_PASSWORD &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
You want to deploy the QDJ site with docker, and bind it to the server name &amp;lt;code&amp;gt;qdj.binets.fr&amp;lt;/code&amp;gt;. Your site is running on flask and uses a postgresql database.&lt;br /&gt;
&lt;br /&gt;
=== Pre-existant configuration ===&lt;br /&gt;
&lt;br /&gt;
You have a little &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# Base image: python3&lt;br /&gt;
FROM python:3&lt;br /&gt;
WORKDIR /usr/src/app&lt;br /&gt;
&lt;br /&gt;
# Install dependacies&lt;br /&gt;
COPY requirements.txt ./&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
&lt;br /&gt;
# Copy application files&lt;br /&gt;
COPY . .&lt;br /&gt;
&lt;br /&gt;
EXPOSE 5000/tcp&lt;br /&gt;
&lt;br /&gt;
# the command runs the migrations and then launches gunicorn to serve the app&lt;br /&gt;
CMD python -m flask db upgrade &amp;amp;amp;&amp;amp;amp; gunicorn -b :5000 qdj:app&amp;lt;/pre&amp;gt;&lt;br /&gt;
You have the following &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
  db:&lt;br /&gt;
    # Use a small postgres image, as we don&#039;t need anything on this container&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: somepassword&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    # store the data on a persistent file&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
    restart: always&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    # Use the image from Dockerfile&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:somepassword@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    # Tells to docker to start app after db (otherwise flask crashes)&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    # Always restart on crash&lt;br /&gt;
    restart: always&lt;br /&gt;
    &lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Production &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We will adapt your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file in order to bind your site to the hostname :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First let&#039;s connect your &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; container to the global network. We won&#039;t bind the &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; container to the global network to protect it from intruders. [[File:https://cloud.binets.fr/s/QTgY55AapFDTyyW/preview|Network graph in endalcher]] We will add network configuration to the &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to enable the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add at the bottom of the file:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to connect &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; to the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add to the &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; configuration:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  - web&lt;br /&gt;
  - default&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Then we can add labels to tell &amp;lt;code&amp;gt;traefik&amp;lt;/code&amp;gt; to match the hostname to a packet going to &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;labels:&lt;br /&gt;
    - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.port=5000&amp;quot;&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This gives us the following &amp;lt;code&amp;gt;docker-compose.qdj.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
&lt;br /&gt;
  db:&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    restart: always&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: qdjpw&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:qdjpw@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    restart: always&lt;br /&gt;
    networks:&lt;br /&gt;
      - web&lt;br /&gt;
      - default&lt;br /&gt;
    labels:&lt;br /&gt;
      - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.port=5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&lt;br /&gt;
&lt;br /&gt;
networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&lt;br /&gt;
This file goes into the [https://gitlab.binets.fr/br/docker-services br/docker-services] repository, it will be used by the triggered pipeline to create your containers.&lt;br /&gt;
&lt;br /&gt;
=== Triggering pipelines with Gitlab CI ===&lt;br /&gt;
&lt;br /&gt;
In this pipeline, we will need to add 2 jobs:&lt;br /&gt;
&lt;br /&gt;
* one to build the docker image using the &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;&lt;br /&gt;
* one to trigger the [https://gitlab.binets.fr/br/docker-services br/docker-services] pipeline to create the containers.&lt;br /&gt;
&lt;br /&gt;
To build the docker image, we will use the template do so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - master&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039;&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&amp;lt;/source&amp;gt;&lt;br /&gt;
The second job is rather tricky. We will use &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; to trigger the pipeline, using [https://docs.gitlab.com/ce/ci/triggers/README.html Gitlab Pipeline API]. This call is secured by a trigger token, which should be saved into your project variables as &amp;lt;code&amp;gt;$TRIGGER_TOKEN&amp;lt;/code&amp;gt;. This is what the job looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=qdj --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&amp;lt;/source&amp;gt;&lt;br /&gt;
Pay attention to this syntax because debugging this api call takes a lot of time...&lt;br /&gt;
&lt;br /&gt;
If you want to add variables that will be used in your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;, add other arguments to &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; like &amp;lt;code&amp;gt;--form variables[WELCOME_MESSAGE]=&amp;amp;quot;Hello World!&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can see an example of a CI using this in the [https://gitlab.binets.fr/br/qdj br/qdj] repo.&lt;br /&gt;
&lt;br /&gt;
Note: for BR project, you can use the &amp;lt;code&amp;gt;trigger&amp;lt;/code&amp;gt; syntax in the API call since you don&#039;t need autorisation.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
* In 2017, the BR16 set up a [https://kubernetes.io/ Kubernetes] cluster. They managed to set up a workflow to deploy seamlessly from gitlab on that cluster. However, the configuration was hard to maintain and the BR17 was not able to keep it going.&lt;br /&gt;
* In 2018, the BR17 (Oliver Facklam + Hadrien Renaud) set up a small docker service on a computer from the Salle Informatiques&lt;br /&gt;
&lt;br /&gt;
= Developping a site for BR docker deployement =&lt;br /&gt;
&lt;br /&gt;
Docker allows for most technologies to be abstracted into a container and thus most - if not all - sites can be deployed in docker. However, here is a bit of advice to make deployement less painful :&lt;br /&gt;
&lt;br /&gt;
* Before using a particular external service (something that should run in a seperate container), check that a well supported docker image exists and with a BRman that there are no other constraints (for example, using a MinIO will go through a seperate dedicated server that already exists rather than a container).&lt;br /&gt;
* Use a postgres database to get access to an admin website for your server.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/14/en&amp;diff=10952</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/14/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/14/en&amp;diff=10952"/>
		<updated>2026-08-05T12:40:53Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « We assume your project is hosted on the [https://gitlab.binets.fr BR&amp;#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We assume your project is hosted on the [https://gitlab.binets.fr BR&#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10951</id>
		<title>Tuto pour le déploiement des sites avec Docker/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10951"/>
		<updated>2026-08-05T12:40:52Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « A &amp;#039;&amp;#039;Docker container&amp;#039;&amp;#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&amp;#039;ll need to install &amp;#039;&amp;#039;Docker&amp;#039;&amp;#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer]. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;At the end of this tutorial you will be able to deploy your website (or service) on the servers of the BR! This allows you to benefit from a free, high-performance and robust infrastructure!&lt;br /&gt;
&lt;br /&gt;
Note: this tutorial may be a bit tricky, so please don’t hesitate to get in touch with a BRman to get help.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Comment_déployer_des_conteneurs_Docker_sur_l&amp;amp;#039;infrastructure_du_BR&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= How to deploy Docker containers on the infrastructure of the BR =&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This tutorial will walk you through :&lt;br /&gt;
* How to convert your website to a Docker service&lt;br /&gt;
* How to build it automatically on Gitlab-CI&lt;br /&gt;
* How to deploy it automatically on our servers&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Basics of git (videos [https://git-scm.com/video/what-is-version-control here] or the beginning of [https://git-scm.com/book/en/v2 this awesome online book]) ;&lt;br /&gt;
* Basics of containers (see a really good explanation [https://www.docker.com/resources/what-container here]) and of docker-compose (see the getting-started [https://docs.docker.com/compose/gettingstarted/ here]) ;&lt;br /&gt;
* Basics of web (see an [https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works introduction] on MDN) ;&lt;br /&gt;
* Basics of gitlab-ci (reading the [https://docs.gitlab.com/ee/ci/ getting-started] is recommended) ;&lt;br /&gt;
&lt;br /&gt;
== Existing architecture ==&lt;br /&gt;
&lt;br /&gt;
A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Interne:&lt;br /&gt;
&lt;br /&gt;
* [https://docs.docker.com/compose/ docker-compose] to deploy the correct environment for your containers ;&lt;br /&gt;
* [https://docs.traefik.io/v1.7/ traefik] as a reverse proxy to serve your site behind your endpoint, it is configured [https://gitlab.binets.fr/br/docker-default-services here] ;&lt;br /&gt;
* nginx to serve your site to the outside world (as all the binets sites).&lt;br /&gt;
&lt;br /&gt;
== How to convert your website to a Docker service ==&lt;br /&gt;
&lt;br /&gt;
The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile]&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;Docker container&#039;&#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&#039;ll need to install &#039;&#039;Docker&#039;&#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
We assume your project is hosted on the [https://gitlab.binets.fr BR&#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Dockerfile&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
FROM hello-world&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* docker-compose.yaml&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
# this is a docker-compose meant for local testing of the deployment image.&lt;br /&gt;
# for the real deployment, go to the docker-services BR gitlab project&lt;br /&gt;
&lt;br /&gt;
version: &amp;quot;3&amp;quot;&lt;br /&gt;
services:&lt;br /&gt;
  app:&lt;br /&gt;
    build:&lt;br /&gt;
      context: ..&lt;br /&gt;
      dockerfile: deployment/Dockerfile&lt;br /&gt;
#    ports:&lt;br /&gt;
#      - &amp;quot;8000:8000&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Then open a terminal in this directory and type &amp;lt;code&amp;gt;docker compose up --build&amp;lt;/code&amp;gt;. If everything went well, you see a nice message from Docker telling you everything is working !&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Now, you need to make &#039;&#039;your&#039;&#039; app work in the docker container. For this, you need:&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* To update the Dockerfile to install everything you need. The following works for a basic (Django) python app :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
FROM python:3&lt;br /&gt;
&lt;br /&gt;
# copies all the code inside the container&lt;br /&gt;
COPY . /my_super_project&lt;br /&gt;
&lt;br /&gt;
WORKDIR /my_super_project&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
CMD python3 manage.py runserver&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To update the docker-compose file to expose the port you need (uncomment the corresponding line in the dockerfile).&lt;br /&gt;
&lt;br /&gt;
=== How to handle persistant data ===&lt;br /&gt;
&lt;br /&gt;
If you app uses an external database or need to not lose some files accross resets, you should use &#039;&#039;docker volumes&#039;&#039; with or without a &#039;&#039;postgres&#039;&#039; image. The [https://gitlab.binets.fr/br/docker-services/-/blob/master/docker-compose.site-jtx.yml?ref_type=heads jtx-docker-compose] might help you understand what you need.&lt;br /&gt;
&lt;br /&gt;
=== How to handle secrets  ===&lt;br /&gt;
&lt;br /&gt;
Often your app has some secrets in a file (such as &#039;&#039;.env&#039;&#039;) that is not in Git. DO NOT put it in git (or all your secrets will be stolen !). Later we are going to see how to securely make them available for the automatic gitlab build.&lt;br /&gt;
&lt;br /&gt;
== Automatic build ==&lt;br /&gt;
&lt;br /&gt;
We will you &#039;&#039;gitlab continuous integration&#039;&#039; to build your docker image directly on the BR&#039;s servers. Write the following into a file name &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; at the root of your repository :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
variables:&lt;br /&gt;
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_PIPELINE_IID&lt;br /&gt;
  PROJECT: mySuperProject&lt;br /&gt;
&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only: # put here the git branches you want the job to run on :&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039; # disables TLS in docker-in-docker (not needed)&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you commit this file to Gitlab, you should see a new job appear (or look under Build/jobs). Your image should build correctly (if not, it means something is not available to gitlab that is when you build on your computer. Read the job logs and try to fix it !)&lt;br /&gt;
&lt;br /&gt;
=== Checking the image ===&lt;br /&gt;
&lt;br /&gt;
This step is optional, but it is the easiest way to debug your image ! You can run it locally like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
docker login registry.binets.fr&lt;br /&gt;
docker run --rm registry.binets.fr/&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;:&amp;lt;image&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;image&amp;lt;/code&amp;gt; is the number of the image (available in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Deploy -&amp;gt; Container registry&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;&amp;lt;/code&amp;gt; is the same as in your project Gitlab URL.&lt;br /&gt;
&lt;br /&gt;
Typically, your app won&#039;t start because you forgot a secret file (see below how to manage that !).&lt;br /&gt;
&lt;br /&gt;
== Automatic deployment ==&lt;br /&gt;
&lt;br /&gt;
We will now add a second CI job to your repository to deploy your image. It will trigger &#039;&#039;another&#039;&#039; CI pipeline of [https://gitlab.binets.fr/br/docker-services br/docker-services]. This pipeline has the rights to deploy on &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt;, and does so using a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file. To trigger it, add the following to your &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  only:&lt;br /&gt;
    - stable&lt;br /&gt;
  image: debian:latest&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --fail-with-body --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=$PROJECT --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure the variable &amp;lt;code&amp;gt;PROJECT&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; is correct : our pipeline will deploy the file named &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order to create the correct &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt; file, you will need to create a Merge Request on [https://gitlab.binets.fr/br/docker-services br/docker-services], or send a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file to a BRman. The [https://gitlab.binets.fr/br/docker-services br/docker-services] is full of examples and a basic one is explained below :&lt;br /&gt;
&lt;br /&gt;
=== Extra parameters and secrets ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way is still visible to the BR and everyone that has maintainer access to you repository ! If you need help setting up, don&#039;t hesitate to ask for help from the BR !&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also pass any parameter needed in the compose file by adding arguments to the cURL call like so : &amp;lt;code&amp;gt;--form variables[MY_SUPER_VARIABLE]=&amp;quot;elle vaut 42!&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pass secret environnements variables, store them in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Variables&amp;lt;/code&amp;gt; and make sure they are &amp;quot;protected&amp;quot; and &amp;quot;masked&amp;quot;. Pass them like so &amp;lt;code&amp;gt;--form variables[MY_PASSWORD]=$PASSWORD_STORED_IN_GITLAB&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Secret files ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way too is visible to the BR and everyone that has &#039;&#039;ANY&#039;&#039; access to you repository (because they can get the docker image) ! So only do this for a private registry or make sure your setting &amp;lt;code&amp;gt;Settings -&amp;gt; General -&amp;gt; Visibility, project features, permissions&amp;lt;/code&amp;gt; only allows for registry access for members&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Another way to store secrets in your Gitlab repo is &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Secure-files&amp;lt;/code&amp;gt;. You can upload any (small) secret file here and it will not be exposed ! You can downlod it at buildtime like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &amp;quot;&amp;quot;&lt;br /&gt;
    # !!! where to download our secure .env file &lt;br /&gt;
    SECURE_FILES_DOWNLOAD_PATH: &amp;quot;.&amp;quot;&lt;br /&gt;
  script:&lt;br /&gt;
    # !!! download secure .env file&lt;br /&gt;
    - apk add --no-cache curl bash&lt;br /&gt;
    - curl --silent &amp;quot;https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer&amp;quot; | bash&lt;br /&gt;
    # build docker image&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
    - echo &amp;quot;=&amp;gt; pushed $IMAGE_TAG&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Private repository ===&lt;br /&gt;
&lt;br /&gt;
Keeping your repository private can be beneficial for security or privacy. But it require an extra step for the BR to access the docker image. We wille pass a [https://docs.gitlab.com/ee/user/project/deploy_tokens/#gitlab-deploy-token CI deploy token] as cURL parameter.&lt;br /&gt;
&lt;br /&gt;
* Go to your &amp;lt;code&amp;gt;Settings -&amp;gt; Repository -&amp;gt; Deploy token&amp;lt;/code&amp;gt; and create a token name exactly &amp;lt;code&amp;gt;gitlab-deploy-token&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Add the following parameters to the cURL call in your CI deploy job : &amp;lt;code&amp;gt; --form variables[OPTIONAL_PRIVATE_CI_REGISTRY]=$CI_REGISTRY --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_USER]=$CI_DEPLOY_USER --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_PASSWORD]=$CI_DEPLOY_PASSWORD &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
You want to deploy the QDJ site with docker, and bind it to the server name &amp;lt;code&amp;gt;qdj.binets.fr&amp;lt;/code&amp;gt;. Your site is running on flask and uses a postgresql database.&lt;br /&gt;
&lt;br /&gt;
=== Pre-existant configuration ===&lt;br /&gt;
&lt;br /&gt;
You have a little &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# Base image: python3&lt;br /&gt;
FROM python:3&lt;br /&gt;
WORKDIR /usr/src/app&lt;br /&gt;
&lt;br /&gt;
# Install dependacies&lt;br /&gt;
COPY requirements.txt ./&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
&lt;br /&gt;
# Copy application files&lt;br /&gt;
COPY . .&lt;br /&gt;
&lt;br /&gt;
EXPOSE 5000/tcp&lt;br /&gt;
&lt;br /&gt;
# the command runs the migrations and then launches gunicorn to serve the app&lt;br /&gt;
CMD python -m flask db upgrade &amp;amp;amp;&amp;amp;amp; gunicorn -b :5000 qdj:app&amp;lt;/pre&amp;gt;&lt;br /&gt;
You have the following &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
  db:&lt;br /&gt;
    # Use a small postgres image, as we don&#039;t need anything on this container&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: somepassword&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    # store the data on a persistent file&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
    restart: always&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    # Use the image from Dockerfile&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:somepassword@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    # Tells to docker to start app after db (otherwise flask crashes)&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    # Always restart on crash&lt;br /&gt;
    restart: always&lt;br /&gt;
    &lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Production &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We will adapt your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file in order to bind your site to the hostname :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First let&#039;s connect your &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; container to the global network. We won&#039;t bind the &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; container to the global network to protect it from intruders. [[File:https://cloud.binets.fr/s/QTgY55AapFDTyyW/preview|Network graph in endalcher]] We will add network configuration to the &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to enable the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add at the bottom of the file:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to connect &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; to the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add to the &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; configuration:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  - web&lt;br /&gt;
  - default&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Then we can add labels to tell &amp;lt;code&amp;gt;traefik&amp;lt;/code&amp;gt; to match the hostname to a packet going to &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;labels:&lt;br /&gt;
    - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.port=5000&amp;quot;&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This gives us the following &amp;lt;code&amp;gt;docker-compose.qdj.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
&lt;br /&gt;
  db:&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    restart: always&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: qdjpw&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:qdjpw@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    restart: always&lt;br /&gt;
    networks:&lt;br /&gt;
      - web&lt;br /&gt;
      - default&lt;br /&gt;
    labels:&lt;br /&gt;
      - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.port=5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&lt;br /&gt;
&lt;br /&gt;
networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&lt;br /&gt;
This file goes into the [https://gitlab.binets.fr/br/docker-services br/docker-services] repository, it will be used by the triggered pipeline to create your containers.&lt;br /&gt;
&lt;br /&gt;
=== Triggering pipelines with Gitlab CI ===&lt;br /&gt;
&lt;br /&gt;
In this pipeline, we will need to add 2 jobs:&lt;br /&gt;
&lt;br /&gt;
* one to build the docker image using the &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;&lt;br /&gt;
* one to trigger the [https://gitlab.binets.fr/br/docker-services br/docker-services] pipeline to create the containers.&lt;br /&gt;
&lt;br /&gt;
To build the docker image, we will use the template do so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - master&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039;&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&amp;lt;/source&amp;gt;&lt;br /&gt;
The second job is rather tricky. We will use &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; to trigger the pipeline, using [https://docs.gitlab.com/ce/ci/triggers/README.html Gitlab Pipeline API]. This call is secured by a trigger token, which should be saved into your project variables as &amp;lt;code&amp;gt;$TRIGGER_TOKEN&amp;lt;/code&amp;gt;. This is what the job looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=qdj --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&amp;lt;/source&amp;gt;&lt;br /&gt;
Pay attention to this syntax because debugging this api call takes a lot of time...&lt;br /&gt;
&lt;br /&gt;
If you want to add variables that will be used in your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;, add other arguments to &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; like &amp;lt;code&amp;gt;--form variables[WELCOME_MESSAGE]=&amp;amp;quot;Hello World!&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can see an example of a CI using this in the [https://gitlab.binets.fr/br/qdj br/qdj] repo.&lt;br /&gt;
&lt;br /&gt;
Note: for BR project, you can use the &amp;lt;code&amp;gt;trigger&amp;lt;/code&amp;gt; syntax in the API call since you don&#039;t need autorisation.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
* In 2017, the BR16 set up a [https://kubernetes.io/ Kubernetes] cluster. They managed to set up a workflow to deploy seamlessly from gitlab on that cluster. However, the configuration was hard to maintain and the BR17 was not able to keep it going.&lt;br /&gt;
* In 2018, the BR17 (Oliver Facklam + Hadrien Renaud) set up a small docker service on a computer from the Salle Informatiques&lt;br /&gt;
&lt;br /&gt;
= Developping a site for BR docker deployement =&lt;br /&gt;
&lt;br /&gt;
Docker allows for most technologies to be abstracted into a container and thus most - if not all - sites can be deployed in docker. However, here is a bit of advice to make deployement less painful :&lt;br /&gt;
&lt;br /&gt;
* Before using a particular external service (something that should run in a seperate container), check that a well supported docker image exists and with a BRman that there are no other constraints (for example, using a MinIO will go through a seperate dedicated server that already exists rather than a container).&lt;br /&gt;
* Use a postgres database to get access to an admin website for your server.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/13/en&amp;diff=10950</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/13/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/13/en&amp;diff=10950"/>
		<updated>2026-08-05T12:40:48Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « A &amp;#039;&amp;#039;Docker container&amp;#039;&amp;#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&amp;#039;ll need to install &amp;#039;&amp;#039;Docker&amp;#039;&amp;#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer]. »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &#039;&#039;Docker container&#039;&#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&#039;ll need to install &#039;&#039;Docker&#039;&#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer].&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10949</id>
		<title>Tuto pour le déploiement des sites avec Docker/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10949"/>
		<updated>2026-08-05T12:40:45Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile] »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;At the end of this tutorial you will be able to deploy your website (or service) on the servers of the BR! This allows you to benefit from a free, high-performance and robust infrastructure!&lt;br /&gt;
&lt;br /&gt;
Note: this tutorial may be a bit tricky, so please don’t hesitate to get in touch with a BRman to get help.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Comment_déployer_des_conteneurs_Docker_sur_l&amp;amp;#039;infrastructure_du_BR&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= How to deploy Docker containers on the infrastructure of the BR =&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This tutorial will walk you through :&lt;br /&gt;
* How to convert your website to a Docker service&lt;br /&gt;
* How to build it automatically on Gitlab-CI&lt;br /&gt;
* How to deploy it automatically on our servers&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Basics of git (videos [https://git-scm.com/video/what-is-version-control here] or the beginning of [https://git-scm.com/book/en/v2 this awesome online book]) ;&lt;br /&gt;
* Basics of containers (see a really good explanation [https://www.docker.com/resources/what-container here]) and of docker-compose (see the getting-started [https://docs.docker.com/compose/gettingstarted/ here]) ;&lt;br /&gt;
* Basics of web (see an [https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works introduction] on MDN) ;&lt;br /&gt;
* Basics of gitlab-ci (reading the [https://docs.gitlab.com/ee/ci/ getting-started] is recommended) ;&lt;br /&gt;
&lt;br /&gt;
== Existing architecture ==&lt;br /&gt;
&lt;br /&gt;
A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Interne:&lt;br /&gt;
&lt;br /&gt;
* [https://docs.docker.com/compose/ docker-compose] to deploy the correct environment for your containers ;&lt;br /&gt;
* [https://docs.traefik.io/v1.7/ traefik] as a reverse proxy to serve your site behind your endpoint, it is configured [https://gitlab.binets.fr/br/docker-default-services here] ;&lt;br /&gt;
* nginx to serve your site to the outside world (as all the binets sites).&lt;br /&gt;
&lt;br /&gt;
== How to convert your website to a Docker service ==&lt;br /&gt;
&lt;br /&gt;
The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
A &#039;&#039;Docker container&#039;&#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&#039;ll need to install &#039;&#039;Docker&#039;&#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer].&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
We assume your project is hosted on the [https://gitlab.binets.fr BR&#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Dockerfile&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
FROM hello-world&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* docker-compose.yaml&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
# this is a docker-compose meant for local testing of the deployment image.&lt;br /&gt;
# for the real deployment, go to the docker-services BR gitlab project&lt;br /&gt;
&lt;br /&gt;
version: &amp;quot;3&amp;quot;&lt;br /&gt;
services:&lt;br /&gt;
  app:&lt;br /&gt;
    build:&lt;br /&gt;
      context: ..&lt;br /&gt;
      dockerfile: deployment/Dockerfile&lt;br /&gt;
#    ports:&lt;br /&gt;
#      - &amp;quot;8000:8000&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Then open a terminal in this directory and type &amp;lt;code&amp;gt;docker compose up --build&amp;lt;/code&amp;gt;. If everything went well, you see a nice message from Docker telling you everything is working !&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Now, you need to make &#039;&#039;your&#039;&#039; app work in the docker container. For this, you need:&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* To update the Dockerfile to install everything you need. The following works for a basic (Django) python app :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
FROM python:3&lt;br /&gt;
&lt;br /&gt;
# copies all the code inside the container&lt;br /&gt;
COPY . /my_super_project&lt;br /&gt;
&lt;br /&gt;
WORKDIR /my_super_project&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
CMD python3 manage.py runserver&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To update the docker-compose file to expose the port you need (uncomment the corresponding line in the dockerfile).&lt;br /&gt;
&lt;br /&gt;
=== How to handle persistant data ===&lt;br /&gt;
&lt;br /&gt;
If you app uses an external database or need to not lose some files accross resets, you should use &#039;&#039;docker volumes&#039;&#039; with or without a &#039;&#039;postgres&#039;&#039; image. The [https://gitlab.binets.fr/br/docker-services/-/blob/master/docker-compose.site-jtx.yml?ref_type=heads jtx-docker-compose] might help you understand what you need.&lt;br /&gt;
&lt;br /&gt;
=== How to handle secrets  ===&lt;br /&gt;
&lt;br /&gt;
Often your app has some secrets in a file (such as &#039;&#039;.env&#039;&#039;) that is not in Git. DO NOT put it in git (or all your secrets will be stolen !). Later we are going to see how to securely make them available for the automatic gitlab build.&lt;br /&gt;
&lt;br /&gt;
== Automatic build ==&lt;br /&gt;
&lt;br /&gt;
We will you &#039;&#039;gitlab continuous integration&#039;&#039; to build your docker image directly on the BR&#039;s servers. Write the following into a file name &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; at the root of your repository :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
variables:&lt;br /&gt;
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_PIPELINE_IID&lt;br /&gt;
  PROJECT: mySuperProject&lt;br /&gt;
&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only: # put here the git branches you want the job to run on :&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039; # disables TLS in docker-in-docker (not needed)&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you commit this file to Gitlab, you should see a new job appear (or look under Build/jobs). Your image should build correctly (if not, it means something is not available to gitlab that is when you build on your computer. Read the job logs and try to fix it !)&lt;br /&gt;
&lt;br /&gt;
=== Checking the image ===&lt;br /&gt;
&lt;br /&gt;
This step is optional, but it is the easiest way to debug your image ! You can run it locally like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
docker login registry.binets.fr&lt;br /&gt;
docker run --rm registry.binets.fr/&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;:&amp;lt;image&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;image&amp;lt;/code&amp;gt; is the number of the image (available in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Deploy -&amp;gt; Container registry&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;&amp;lt;/code&amp;gt; is the same as in your project Gitlab URL.&lt;br /&gt;
&lt;br /&gt;
Typically, your app won&#039;t start because you forgot a secret file (see below how to manage that !).&lt;br /&gt;
&lt;br /&gt;
== Automatic deployment ==&lt;br /&gt;
&lt;br /&gt;
We will now add a second CI job to your repository to deploy your image. It will trigger &#039;&#039;another&#039;&#039; CI pipeline of [https://gitlab.binets.fr/br/docker-services br/docker-services]. This pipeline has the rights to deploy on &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt;, and does so using a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file. To trigger it, add the following to your &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  only:&lt;br /&gt;
    - stable&lt;br /&gt;
  image: debian:latest&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --fail-with-body --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=$PROJECT --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure the variable &amp;lt;code&amp;gt;PROJECT&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; is correct : our pipeline will deploy the file named &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order to create the correct &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt; file, you will need to create a Merge Request on [https://gitlab.binets.fr/br/docker-services br/docker-services], or send a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file to a BRman. The [https://gitlab.binets.fr/br/docker-services br/docker-services] is full of examples and a basic one is explained below :&lt;br /&gt;
&lt;br /&gt;
=== Extra parameters and secrets ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way is still visible to the BR and everyone that has maintainer access to you repository ! If you need help setting up, don&#039;t hesitate to ask for help from the BR !&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also pass any parameter needed in the compose file by adding arguments to the cURL call like so : &amp;lt;code&amp;gt;--form variables[MY_SUPER_VARIABLE]=&amp;quot;elle vaut 42!&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pass secret environnements variables, store them in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Variables&amp;lt;/code&amp;gt; and make sure they are &amp;quot;protected&amp;quot; and &amp;quot;masked&amp;quot;. Pass them like so &amp;lt;code&amp;gt;--form variables[MY_PASSWORD]=$PASSWORD_STORED_IN_GITLAB&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Secret files ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way too is visible to the BR and everyone that has &#039;&#039;ANY&#039;&#039; access to you repository (because they can get the docker image) ! So only do this for a private registry or make sure your setting &amp;lt;code&amp;gt;Settings -&amp;gt; General -&amp;gt; Visibility, project features, permissions&amp;lt;/code&amp;gt; only allows for registry access for members&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Another way to store secrets in your Gitlab repo is &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Secure-files&amp;lt;/code&amp;gt;. You can upload any (small) secret file here and it will not be exposed ! You can downlod it at buildtime like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &amp;quot;&amp;quot;&lt;br /&gt;
    # !!! where to download our secure .env file &lt;br /&gt;
    SECURE_FILES_DOWNLOAD_PATH: &amp;quot;.&amp;quot;&lt;br /&gt;
  script:&lt;br /&gt;
    # !!! download secure .env file&lt;br /&gt;
    - apk add --no-cache curl bash&lt;br /&gt;
    - curl --silent &amp;quot;https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer&amp;quot; | bash&lt;br /&gt;
    # build docker image&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
    - echo &amp;quot;=&amp;gt; pushed $IMAGE_TAG&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Private repository ===&lt;br /&gt;
&lt;br /&gt;
Keeping your repository private can be beneficial for security or privacy. But it require an extra step for the BR to access the docker image. We wille pass a [https://docs.gitlab.com/ee/user/project/deploy_tokens/#gitlab-deploy-token CI deploy token] as cURL parameter.&lt;br /&gt;
&lt;br /&gt;
* Go to your &amp;lt;code&amp;gt;Settings -&amp;gt; Repository -&amp;gt; Deploy token&amp;lt;/code&amp;gt; and create a token name exactly &amp;lt;code&amp;gt;gitlab-deploy-token&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Add the following parameters to the cURL call in your CI deploy job : &amp;lt;code&amp;gt; --form variables[OPTIONAL_PRIVATE_CI_REGISTRY]=$CI_REGISTRY --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_USER]=$CI_DEPLOY_USER --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_PASSWORD]=$CI_DEPLOY_PASSWORD &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
You want to deploy the QDJ site with docker, and bind it to the server name &amp;lt;code&amp;gt;qdj.binets.fr&amp;lt;/code&amp;gt;. Your site is running on flask and uses a postgresql database.&lt;br /&gt;
&lt;br /&gt;
=== Pre-existant configuration ===&lt;br /&gt;
&lt;br /&gt;
You have a little &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# Base image: python3&lt;br /&gt;
FROM python:3&lt;br /&gt;
WORKDIR /usr/src/app&lt;br /&gt;
&lt;br /&gt;
# Install dependacies&lt;br /&gt;
COPY requirements.txt ./&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
&lt;br /&gt;
# Copy application files&lt;br /&gt;
COPY . .&lt;br /&gt;
&lt;br /&gt;
EXPOSE 5000/tcp&lt;br /&gt;
&lt;br /&gt;
# the command runs the migrations and then launches gunicorn to serve the app&lt;br /&gt;
CMD python -m flask db upgrade &amp;amp;amp;&amp;amp;amp; gunicorn -b :5000 qdj:app&amp;lt;/pre&amp;gt;&lt;br /&gt;
You have the following &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
  db:&lt;br /&gt;
    # Use a small postgres image, as we don&#039;t need anything on this container&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: somepassword&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    # store the data on a persistent file&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
    restart: always&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    # Use the image from Dockerfile&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:somepassword@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    # Tells to docker to start app after db (otherwise flask crashes)&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    # Always restart on crash&lt;br /&gt;
    restart: always&lt;br /&gt;
    &lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Production &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We will adapt your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file in order to bind your site to the hostname :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First let&#039;s connect your &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; container to the global network. We won&#039;t bind the &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; container to the global network to protect it from intruders. [[File:https://cloud.binets.fr/s/QTgY55AapFDTyyW/preview|Network graph in endalcher]] We will add network configuration to the &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to enable the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add at the bottom of the file:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to connect &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; to the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add to the &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; configuration:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  - web&lt;br /&gt;
  - default&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Then we can add labels to tell &amp;lt;code&amp;gt;traefik&amp;lt;/code&amp;gt; to match the hostname to a packet going to &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;labels:&lt;br /&gt;
    - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.port=5000&amp;quot;&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This gives us the following &amp;lt;code&amp;gt;docker-compose.qdj.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
&lt;br /&gt;
  db:&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    restart: always&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: qdjpw&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:qdjpw@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    restart: always&lt;br /&gt;
    networks:&lt;br /&gt;
      - web&lt;br /&gt;
      - default&lt;br /&gt;
    labels:&lt;br /&gt;
      - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.port=5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&lt;br /&gt;
&lt;br /&gt;
networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&lt;br /&gt;
This file goes into the [https://gitlab.binets.fr/br/docker-services br/docker-services] repository, it will be used by the triggered pipeline to create your containers.&lt;br /&gt;
&lt;br /&gt;
=== Triggering pipelines with Gitlab CI ===&lt;br /&gt;
&lt;br /&gt;
In this pipeline, we will need to add 2 jobs:&lt;br /&gt;
&lt;br /&gt;
* one to build the docker image using the &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;&lt;br /&gt;
* one to trigger the [https://gitlab.binets.fr/br/docker-services br/docker-services] pipeline to create the containers.&lt;br /&gt;
&lt;br /&gt;
To build the docker image, we will use the template do so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - master&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039;&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&amp;lt;/source&amp;gt;&lt;br /&gt;
The second job is rather tricky. We will use &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; to trigger the pipeline, using [https://docs.gitlab.com/ce/ci/triggers/README.html Gitlab Pipeline API]. This call is secured by a trigger token, which should be saved into your project variables as &amp;lt;code&amp;gt;$TRIGGER_TOKEN&amp;lt;/code&amp;gt;. This is what the job looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=qdj --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&amp;lt;/source&amp;gt;&lt;br /&gt;
Pay attention to this syntax because debugging this api call takes a lot of time...&lt;br /&gt;
&lt;br /&gt;
If you want to add variables that will be used in your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;, add other arguments to &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; like &amp;lt;code&amp;gt;--form variables[WELCOME_MESSAGE]=&amp;amp;quot;Hello World!&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can see an example of a CI using this in the [https://gitlab.binets.fr/br/qdj br/qdj] repo.&lt;br /&gt;
&lt;br /&gt;
Note: for BR project, you can use the &amp;lt;code&amp;gt;trigger&amp;lt;/code&amp;gt; syntax in the API call since you don&#039;t need autorisation.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
* In 2017, the BR16 set up a [https://kubernetes.io/ Kubernetes] cluster. They managed to set up a workflow to deploy seamlessly from gitlab on that cluster. However, the configuration was hard to maintain and the BR17 was not able to keep it going.&lt;br /&gt;
* In 2018, the BR17 (Oliver Facklam + Hadrien Renaud) set up a small docker service on a computer from the Salle Informatiques&lt;br /&gt;
&lt;br /&gt;
= Developping a site for BR docker deployement =&lt;br /&gt;
&lt;br /&gt;
Docker allows for most technologies to be abstracted into a container and thus most - if not all - sites can be deployed in docker. However, here is a bit of advice to make deployement less painful :&lt;br /&gt;
&lt;br /&gt;
* Before using a particular external service (something that should run in a seperate container), check that a well supported docker image exists and with a BRman that there are no other constraints (for example, using a MinIO will go through a seperate dedicated server that already exists rather than a container).&lt;br /&gt;
* Use a postgres database to get access to an admin website for your server.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/12/en&amp;diff=10948</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/12/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/12/en&amp;diff=10948"/>
		<updated>2026-08-05T12:40:44Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile] »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile]&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10947</id>
		<title>Tuto pour le déploiement des sites avec Docker/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10947"/>
		<updated>2026-08-05T12:40:39Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « == How to convert your website to a Docker service == »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;At the end of this tutorial you will be able to deploy your website (or service) on the servers of the BR! This allows you to benefit from a free, high-performance and robust infrastructure!&lt;br /&gt;
&lt;br /&gt;
Note: this tutorial may be a bit tricky, so please don’t hesitate to get in touch with a BRman to get help.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Comment_déployer_des_conteneurs_Docker_sur_l&amp;amp;#039;infrastructure_du_BR&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= How to deploy Docker containers on the infrastructure of the BR =&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This tutorial will walk you through :&lt;br /&gt;
* How to convert your website to a Docker service&lt;br /&gt;
* How to build it automatically on Gitlab-CI&lt;br /&gt;
* How to deploy it automatically on our servers&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Basics of git (videos [https://git-scm.com/video/what-is-version-control here] or the beginning of [https://git-scm.com/book/en/v2 this awesome online book]) ;&lt;br /&gt;
* Basics of containers (see a really good explanation [https://www.docker.com/resources/what-container here]) and of docker-compose (see the getting-started [https://docs.docker.com/compose/gettingstarted/ here]) ;&lt;br /&gt;
* Basics of web (see an [https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works introduction] on MDN) ;&lt;br /&gt;
* Basics of gitlab-ci (reading the [https://docs.gitlab.com/ee/ci/ getting-started] is recommended) ;&lt;br /&gt;
&lt;br /&gt;
== Existing architecture ==&lt;br /&gt;
&lt;br /&gt;
A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Interne:&lt;br /&gt;
&lt;br /&gt;
* [https://docs.docker.com/compose/ docker-compose] to deploy the correct environment for your containers ;&lt;br /&gt;
* [https://docs.traefik.io/v1.7/ traefik] as a reverse proxy to serve your site behind your endpoint, it is configured [https://gitlab.binets.fr/br/docker-default-services here] ;&lt;br /&gt;
* nginx to serve your site to the outside world (as all the binets sites).&lt;br /&gt;
&lt;br /&gt;
== How to convert your website to a Docker service ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
A &#039;&#039;Docker container&#039;&#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&#039;ll need to install &#039;&#039;Docker&#039;&#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer].&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
We assume your project is hosted on the [https://gitlab.binets.fr BR&#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Dockerfile&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
FROM hello-world&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* docker-compose.yaml&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
# this is a docker-compose meant for local testing of the deployment image.&lt;br /&gt;
# for the real deployment, go to the docker-services BR gitlab project&lt;br /&gt;
&lt;br /&gt;
version: &amp;quot;3&amp;quot;&lt;br /&gt;
services:&lt;br /&gt;
  app:&lt;br /&gt;
    build:&lt;br /&gt;
      context: ..&lt;br /&gt;
      dockerfile: deployment/Dockerfile&lt;br /&gt;
#    ports:&lt;br /&gt;
#      - &amp;quot;8000:8000&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Then open a terminal in this directory and type &amp;lt;code&amp;gt;docker compose up --build&amp;lt;/code&amp;gt;. If everything went well, you see a nice message from Docker telling you everything is working !&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Now, you need to make &#039;&#039;your&#039;&#039; app work in the docker container. For this, you need:&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* To update the Dockerfile to install everything you need. The following works for a basic (Django) python app :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
FROM python:3&lt;br /&gt;
&lt;br /&gt;
# copies all the code inside the container&lt;br /&gt;
COPY . /my_super_project&lt;br /&gt;
&lt;br /&gt;
WORKDIR /my_super_project&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
CMD python3 manage.py runserver&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To update the docker-compose file to expose the port you need (uncomment the corresponding line in the dockerfile).&lt;br /&gt;
&lt;br /&gt;
=== How to handle persistant data ===&lt;br /&gt;
&lt;br /&gt;
If you app uses an external database or need to not lose some files accross resets, you should use &#039;&#039;docker volumes&#039;&#039; with or without a &#039;&#039;postgres&#039;&#039; image. The [https://gitlab.binets.fr/br/docker-services/-/blob/master/docker-compose.site-jtx.yml?ref_type=heads jtx-docker-compose] might help you understand what you need.&lt;br /&gt;
&lt;br /&gt;
=== How to handle secrets  ===&lt;br /&gt;
&lt;br /&gt;
Often your app has some secrets in a file (such as &#039;&#039;.env&#039;&#039;) that is not in Git. DO NOT put it in git (or all your secrets will be stolen !). Later we are going to see how to securely make them available for the automatic gitlab build.&lt;br /&gt;
&lt;br /&gt;
== Automatic build ==&lt;br /&gt;
&lt;br /&gt;
We will you &#039;&#039;gitlab continuous integration&#039;&#039; to build your docker image directly on the BR&#039;s servers. Write the following into a file name &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; at the root of your repository :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
variables:&lt;br /&gt;
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_PIPELINE_IID&lt;br /&gt;
  PROJECT: mySuperProject&lt;br /&gt;
&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only: # put here the git branches you want the job to run on :&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039; # disables TLS in docker-in-docker (not needed)&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you commit this file to Gitlab, you should see a new job appear (or look under Build/jobs). Your image should build correctly (if not, it means something is not available to gitlab that is when you build on your computer. Read the job logs and try to fix it !)&lt;br /&gt;
&lt;br /&gt;
=== Checking the image ===&lt;br /&gt;
&lt;br /&gt;
This step is optional, but it is the easiest way to debug your image ! You can run it locally like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
docker login registry.binets.fr&lt;br /&gt;
docker run --rm registry.binets.fr/&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;:&amp;lt;image&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;image&amp;lt;/code&amp;gt; is the number of the image (available in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Deploy -&amp;gt; Container registry&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;&amp;lt;/code&amp;gt; is the same as in your project Gitlab URL.&lt;br /&gt;
&lt;br /&gt;
Typically, your app won&#039;t start because you forgot a secret file (see below how to manage that !).&lt;br /&gt;
&lt;br /&gt;
== Automatic deployment ==&lt;br /&gt;
&lt;br /&gt;
We will now add a second CI job to your repository to deploy your image. It will trigger &#039;&#039;another&#039;&#039; CI pipeline of [https://gitlab.binets.fr/br/docker-services br/docker-services]. This pipeline has the rights to deploy on &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt;, and does so using a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file. To trigger it, add the following to your &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  only:&lt;br /&gt;
    - stable&lt;br /&gt;
  image: debian:latest&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --fail-with-body --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=$PROJECT --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure the variable &amp;lt;code&amp;gt;PROJECT&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; is correct : our pipeline will deploy the file named &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order to create the correct &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt; file, you will need to create a Merge Request on [https://gitlab.binets.fr/br/docker-services br/docker-services], or send a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file to a BRman. The [https://gitlab.binets.fr/br/docker-services br/docker-services] is full of examples and a basic one is explained below :&lt;br /&gt;
&lt;br /&gt;
=== Extra parameters and secrets ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way is still visible to the BR and everyone that has maintainer access to you repository ! If you need help setting up, don&#039;t hesitate to ask for help from the BR !&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also pass any parameter needed in the compose file by adding arguments to the cURL call like so : &amp;lt;code&amp;gt;--form variables[MY_SUPER_VARIABLE]=&amp;quot;elle vaut 42!&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pass secret environnements variables, store them in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Variables&amp;lt;/code&amp;gt; and make sure they are &amp;quot;protected&amp;quot; and &amp;quot;masked&amp;quot;. Pass them like so &amp;lt;code&amp;gt;--form variables[MY_PASSWORD]=$PASSWORD_STORED_IN_GITLAB&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Secret files ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way too is visible to the BR and everyone that has &#039;&#039;ANY&#039;&#039; access to you repository (because they can get the docker image) ! So only do this for a private registry or make sure your setting &amp;lt;code&amp;gt;Settings -&amp;gt; General -&amp;gt; Visibility, project features, permissions&amp;lt;/code&amp;gt; only allows for registry access for members&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Another way to store secrets in your Gitlab repo is &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Secure-files&amp;lt;/code&amp;gt;. You can upload any (small) secret file here and it will not be exposed ! You can downlod it at buildtime like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &amp;quot;&amp;quot;&lt;br /&gt;
    # !!! where to download our secure .env file &lt;br /&gt;
    SECURE_FILES_DOWNLOAD_PATH: &amp;quot;.&amp;quot;&lt;br /&gt;
  script:&lt;br /&gt;
    # !!! download secure .env file&lt;br /&gt;
    - apk add --no-cache curl bash&lt;br /&gt;
    - curl --silent &amp;quot;https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer&amp;quot; | bash&lt;br /&gt;
    # build docker image&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
    - echo &amp;quot;=&amp;gt; pushed $IMAGE_TAG&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Private repository ===&lt;br /&gt;
&lt;br /&gt;
Keeping your repository private can be beneficial for security or privacy. But it require an extra step for the BR to access the docker image. We wille pass a [https://docs.gitlab.com/ee/user/project/deploy_tokens/#gitlab-deploy-token CI deploy token] as cURL parameter.&lt;br /&gt;
&lt;br /&gt;
* Go to your &amp;lt;code&amp;gt;Settings -&amp;gt; Repository -&amp;gt; Deploy token&amp;lt;/code&amp;gt; and create a token name exactly &amp;lt;code&amp;gt;gitlab-deploy-token&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Add the following parameters to the cURL call in your CI deploy job : &amp;lt;code&amp;gt; --form variables[OPTIONAL_PRIVATE_CI_REGISTRY]=$CI_REGISTRY --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_USER]=$CI_DEPLOY_USER --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_PASSWORD]=$CI_DEPLOY_PASSWORD &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
You want to deploy the QDJ site with docker, and bind it to the server name &amp;lt;code&amp;gt;qdj.binets.fr&amp;lt;/code&amp;gt;. Your site is running on flask and uses a postgresql database.&lt;br /&gt;
&lt;br /&gt;
=== Pre-existant configuration ===&lt;br /&gt;
&lt;br /&gt;
You have a little &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# Base image: python3&lt;br /&gt;
FROM python:3&lt;br /&gt;
WORKDIR /usr/src/app&lt;br /&gt;
&lt;br /&gt;
# Install dependacies&lt;br /&gt;
COPY requirements.txt ./&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
&lt;br /&gt;
# Copy application files&lt;br /&gt;
COPY . .&lt;br /&gt;
&lt;br /&gt;
EXPOSE 5000/tcp&lt;br /&gt;
&lt;br /&gt;
# the command runs the migrations and then launches gunicorn to serve the app&lt;br /&gt;
CMD python -m flask db upgrade &amp;amp;amp;&amp;amp;amp; gunicorn -b :5000 qdj:app&amp;lt;/pre&amp;gt;&lt;br /&gt;
You have the following &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
  db:&lt;br /&gt;
    # Use a small postgres image, as we don&#039;t need anything on this container&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: somepassword&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    # store the data on a persistent file&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
    restart: always&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    # Use the image from Dockerfile&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:somepassword@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    # Tells to docker to start app after db (otherwise flask crashes)&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    # Always restart on crash&lt;br /&gt;
    restart: always&lt;br /&gt;
    &lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Production &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We will adapt your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file in order to bind your site to the hostname :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First let&#039;s connect your &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; container to the global network. We won&#039;t bind the &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; container to the global network to protect it from intruders. [[File:https://cloud.binets.fr/s/QTgY55AapFDTyyW/preview|Network graph in endalcher]] We will add network configuration to the &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to enable the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add at the bottom of the file:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to connect &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; to the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add to the &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; configuration:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  - web&lt;br /&gt;
  - default&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Then we can add labels to tell &amp;lt;code&amp;gt;traefik&amp;lt;/code&amp;gt; to match the hostname to a packet going to &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;labels:&lt;br /&gt;
    - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.port=5000&amp;quot;&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This gives us the following &amp;lt;code&amp;gt;docker-compose.qdj.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
&lt;br /&gt;
  db:&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    restart: always&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: qdjpw&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:qdjpw@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    restart: always&lt;br /&gt;
    networks:&lt;br /&gt;
      - web&lt;br /&gt;
      - default&lt;br /&gt;
    labels:&lt;br /&gt;
      - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.port=5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&lt;br /&gt;
&lt;br /&gt;
networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&lt;br /&gt;
This file goes into the [https://gitlab.binets.fr/br/docker-services br/docker-services] repository, it will be used by the triggered pipeline to create your containers.&lt;br /&gt;
&lt;br /&gt;
=== Triggering pipelines with Gitlab CI ===&lt;br /&gt;
&lt;br /&gt;
In this pipeline, we will need to add 2 jobs:&lt;br /&gt;
&lt;br /&gt;
* one to build the docker image using the &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;&lt;br /&gt;
* one to trigger the [https://gitlab.binets.fr/br/docker-services br/docker-services] pipeline to create the containers.&lt;br /&gt;
&lt;br /&gt;
To build the docker image, we will use the template do so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - master&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039;&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&amp;lt;/source&amp;gt;&lt;br /&gt;
The second job is rather tricky. We will use &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; to trigger the pipeline, using [https://docs.gitlab.com/ce/ci/triggers/README.html Gitlab Pipeline API]. This call is secured by a trigger token, which should be saved into your project variables as &amp;lt;code&amp;gt;$TRIGGER_TOKEN&amp;lt;/code&amp;gt;. This is what the job looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=qdj --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&amp;lt;/source&amp;gt;&lt;br /&gt;
Pay attention to this syntax because debugging this api call takes a lot of time...&lt;br /&gt;
&lt;br /&gt;
If you want to add variables that will be used in your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;, add other arguments to &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; like &amp;lt;code&amp;gt;--form variables[WELCOME_MESSAGE]=&amp;amp;quot;Hello World!&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can see an example of a CI using this in the [https://gitlab.binets.fr/br/qdj br/qdj] repo.&lt;br /&gt;
&lt;br /&gt;
Note: for BR project, you can use the &amp;lt;code&amp;gt;trigger&amp;lt;/code&amp;gt; syntax in the API call since you don&#039;t need autorisation.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
* In 2017, the BR16 set up a [https://kubernetes.io/ Kubernetes] cluster. They managed to set up a workflow to deploy seamlessly from gitlab on that cluster. However, the configuration was hard to maintain and the BR17 was not able to keep it going.&lt;br /&gt;
* In 2018, the BR17 (Oliver Facklam + Hadrien Renaud) set up a small docker service on a computer from the Salle Informatiques&lt;br /&gt;
&lt;br /&gt;
= Developping a site for BR docker deployement =&lt;br /&gt;
&lt;br /&gt;
Docker allows for most technologies to be abstracted into a container and thus most - if not all - sites can be deployed in docker. However, here is a bit of advice to make deployement less painful :&lt;br /&gt;
&lt;br /&gt;
* Before using a particular external service (something that should run in a seperate container), check that a well supported docker image exists and with a BRman that there are no other constraints (for example, using a MinIO will go through a seperate dedicated server that already exists rather than a container).&lt;br /&gt;
* Use a postgres database to get access to an admin website for your server.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/11/en&amp;diff=10946</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/11/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/11/en&amp;diff=10946"/>
		<updated>2026-08-05T12:40:37Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « == How to convert your website to a Docker service == »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== How to convert your website to a Docker service ==&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/10/en&amp;diff=10945</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/10/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/10/en&amp;diff=10945"/>
		<updated>2026-08-05T12:40:30Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « * [https://docs.docker.com/compose/ docker-compose] to deploy the correct environment for your containers ; * [https://docs.traefik.io/v1.7/ traefik] as a reverse proxy to serve your site behind your endpoint, it is configured [https://gitlab.binets.fr/br/docker-default-services here] ; * nginx to serve your site to the outside world (as all the binets sites). »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [https://docs.docker.com/compose/ docker-compose] to deploy the correct environment for your containers ;&lt;br /&gt;
* [https://docs.traefik.io/v1.7/ traefik] as a reverse proxy to serve your site behind your endpoint, it is configured [https://gitlab.binets.fr/br/docker-default-services here] ;&lt;br /&gt;
* nginx to serve your site to the outside world (as all the binets sites).&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10944</id>
		<title>Tuto pour le déploiement des sites avec Docker/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10944"/>
		<updated>2026-08-05T12:40:20Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Interne: »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;At the end of this tutorial you will be able to deploy your website (or service) on the servers of the BR! This allows you to benefit from a free, high-performance and robust infrastructure!&lt;br /&gt;
&lt;br /&gt;
Note: this tutorial may be a bit tricky, so please don’t hesitate to get in touch with a BRman to get help.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Comment_déployer_des_conteneurs_Docker_sur_l&amp;amp;#039;infrastructure_du_BR&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= How to deploy Docker containers on the infrastructure of the BR =&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This tutorial will walk you through :&lt;br /&gt;
* How to convert your website to a Docker service&lt;br /&gt;
* How to build it automatically on Gitlab-CI&lt;br /&gt;
* How to deploy it automatically on our servers&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Basics of git (videos [https://git-scm.com/video/what-is-version-control here] or the beginning of [https://git-scm.com/book/en/v2 this awesome online book]) ;&lt;br /&gt;
* Basics of containers (see a really good explanation [https://www.docker.com/resources/what-container here]) and of docker-compose (see the getting-started [https://docs.docker.com/compose/gettingstarted/ here]) ;&lt;br /&gt;
* Basics of web (see an [https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works introduction] on MDN) ;&lt;br /&gt;
* Basics of gitlab-ci (reading the [https://docs.gitlab.com/ee/ci/ getting-started] is recommended) ;&lt;br /&gt;
&lt;br /&gt;
== Existing architecture ==&lt;br /&gt;
&lt;br /&gt;
A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Interne:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* [https://docs.docker.com/compose/ docker-compose] to deploy the correct environment for your containers ;&lt;br /&gt;
* [https://docs.traefik.io/v1.7/ traefik] as a reverse proxy to serve your site behind your endpoint, it is configured [https://gitlab.binets.fr/br/docker-default-services here] ;&lt;br /&gt;
* nginx to serve your site to the outside world (as all the binets sites).&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
== How to convert your website to a Docker service ==&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
A &#039;&#039;Docker container&#039;&#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&#039;ll need to install &#039;&#039;Docker&#039;&#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer].&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
We assume your project is hosted on the [https://gitlab.binets.fr BR&#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Dockerfile&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
FROM hello-world&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* docker-compose.yaml&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
# this is a docker-compose meant for local testing of the deployment image.&lt;br /&gt;
# for the real deployment, go to the docker-services BR gitlab project&lt;br /&gt;
&lt;br /&gt;
version: &amp;quot;3&amp;quot;&lt;br /&gt;
services:&lt;br /&gt;
  app:&lt;br /&gt;
    build:&lt;br /&gt;
      context: ..&lt;br /&gt;
      dockerfile: deployment/Dockerfile&lt;br /&gt;
#    ports:&lt;br /&gt;
#      - &amp;quot;8000:8000&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Then open a terminal in this directory and type &amp;lt;code&amp;gt;docker compose up --build&amp;lt;/code&amp;gt;. If everything went well, you see a nice message from Docker telling you everything is working !&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Now, you need to make &#039;&#039;your&#039;&#039; app work in the docker container. For this, you need:&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* To update the Dockerfile to install everything you need. The following works for a basic (Django) python app :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
FROM python:3&lt;br /&gt;
&lt;br /&gt;
# copies all the code inside the container&lt;br /&gt;
COPY . /my_super_project&lt;br /&gt;
&lt;br /&gt;
WORKDIR /my_super_project&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
CMD python3 manage.py runserver&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To update the docker-compose file to expose the port you need (uncomment the corresponding line in the dockerfile).&lt;br /&gt;
&lt;br /&gt;
=== How to handle persistant data ===&lt;br /&gt;
&lt;br /&gt;
If you app uses an external database or need to not lose some files accross resets, you should use &#039;&#039;docker volumes&#039;&#039; with or without a &#039;&#039;postgres&#039;&#039; image. The [https://gitlab.binets.fr/br/docker-services/-/blob/master/docker-compose.site-jtx.yml?ref_type=heads jtx-docker-compose] might help you understand what you need.&lt;br /&gt;
&lt;br /&gt;
=== How to handle secrets  ===&lt;br /&gt;
&lt;br /&gt;
Often your app has some secrets in a file (such as &#039;&#039;.env&#039;&#039;) that is not in Git. DO NOT put it in git (or all your secrets will be stolen !). Later we are going to see how to securely make them available for the automatic gitlab build.&lt;br /&gt;
&lt;br /&gt;
== Automatic build ==&lt;br /&gt;
&lt;br /&gt;
We will you &#039;&#039;gitlab continuous integration&#039;&#039; to build your docker image directly on the BR&#039;s servers. Write the following into a file name &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; at the root of your repository :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
variables:&lt;br /&gt;
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_PIPELINE_IID&lt;br /&gt;
  PROJECT: mySuperProject&lt;br /&gt;
&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only: # put here the git branches you want the job to run on :&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039; # disables TLS in docker-in-docker (not needed)&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you commit this file to Gitlab, you should see a new job appear (or look under Build/jobs). Your image should build correctly (if not, it means something is not available to gitlab that is when you build on your computer. Read the job logs and try to fix it !)&lt;br /&gt;
&lt;br /&gt;
=== Checking the image ===&lt;br /&gt;
&lt;br /&gt;
This step is optional, but it is the easiest way to debug your image ! You can run it locally like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
docker login registry.binets.fr&lt;br /&gt;
docker run --rm registry.binets.fr/&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;:&amp;lt;image&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;image&amp;lt;/code&amp;gt; is the number of the image (available in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Deploy -&amp;gt; Container registry&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;&amp;lt;/code&amp;gt; is the same as in your project Gitlab URL.&lt;br /&gt;
&lt;br /&gt;
Typically, your app won&#039;t start because you forgot a secret file (see below how to manage that !).&lt;br /&gt;
&lt;br /&gt;
== Automatic deployment ==&lt;br /&gt;
&lt;br /&gt;
We will now add a second CI job to your repository to deploy your image. It will trigger &#039;&#039;another&#039;&#039; CI pipeline of [https://gitlab.binets.fr/br/docker-services br/docker-services]. This pipeline has the rights to deploy on &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt;, and does so using a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file. To trigger it, add the following to your &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  only:&lt;br /&gt;
    - stable&lt;br /&gt;
  image: debian:latest&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --fail-with-body --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=$PROJECT --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure the variable &amp;lt;code&amp;gt;PROJECT&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; is correct : our pipeline will deploy the file named &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order to create the correct &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt; file, you will need to create a Merge Request on [https://gitlab.binets.fr/br/docker-services br/docker-services], or send a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file to a BRman. The [https://gitlab.binets.fr/br/docker-services br/docker-services] is full of examples and a basic one is explained below :&lt;br /&gt;
&lt;br /&gt;
=== Extra parameters and secrets ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way is still visible to the BR and everyone that has maintainer access to you repository ! If you need help setting up, don&#039;t hesitate to ask for help from the BR !&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also pass any parameter needed in the compose file by adding arguments to the cURL call like so : &amp;lt;code&amp;gt;--form variables[MY_SUPER_VARIABLE]=&amp;quot;elle vaut 42!&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pass secret environnements variables, store them in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Variables&amp;lt;/code&amp;gt; and make sure they are &amp;quot;protected&amp;quot; and &amp;quot;masked&amp;quot;. Pass them like so &amp;lt;code&amp;gt;--form variables[MY_PASSWORD]=$PASSWORD_STORED_IN_GITLAB&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Secret files ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way too is visible to the BR and everyone that has &#039;&#039;ANY&#039;&#039; access to you repository (because they can get the docker image) ! So only do this for a private registry or make sure your setting &amp;lt;code&amp;gt;Settings -&amp;gt; General -&amp;gt; Visibility, project features, permissions&amp;lt;/code&amp;gt; only allows for registry access for members&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Another way to store secrets in your Gitlab repo is &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Secure-files&amp;lt;/code&amp;gt;. You can upload any (small) secret file here and it will not be exposed ! You can downlod it at buildtime like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &amp;quot;&amp;quot;&lt;br /&gt;
    # !!! where to download our secure .env file &lt;br /&gt;
    SECURE_FILES_DOWNLOAD_PATH: &amp;quot;.&amp;quot;&lt;br /&gt;
  script:&lt;br /&gt;
    # !!! download secure .env file&lt;br /&gt;
    - apk add --no-cache curl bash&lt;br /&gt;
    - curl --silent &amp;quot;https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer&amp;quot; | bash&lt;br /&gt;
    # build docker image&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
    - echo &amp;quot;=&amp;gt; pushed $IMAGE_TAG&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Private repository ===&lt;br /&gt;
&lt;br /&gt;
Keeping your repository private can be beneficial for security or privacy. But it require an extra step for the BR to access the docker image. We wille pass a [https://docs.gitlab.com/ee/user/project/deploy_tokens/#gitlab-deploy-token CI deploy token] as cURL parameter.&lt;br /&gt;
&lt;br /&gt;
* Go to your &amp;lt;code&amp;gt;Settings -&amp;gt; Repository -&amp;gt; Deploy token&amp;lt;/code&amp;gt; and create a token name exactly &amp;lt;code&amp;gt;gitlab-deploy-token&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Add the following parameters to the cURL call in your CI deploy job : &amp;lt;code&amp;gt; --form variables[OPTIONAL_PRIVATE_CI_REGISTRY]=$CI_REGISTRY --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_USER]=$CI_DEPLOY_USER --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_PASSWORD]=$CI_DEPLOY_PASSWORD &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
You want to deploy the QDJ site with docker, and bind it to the server name &amp;lt;code&amp;gt;qdj.binets.fr&amp;lt;/code&amp;gt;. Your site is running on flask and uses a postgresql database.&lt;br /&gt;
&lt;br /&gt;
=== Pre-existant configuration ===&lt;br /&gt;
&lt;br /&gt;
You have a little &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# Base image: python3&lt;br /&gt;
FROM python:3&lt;br /&gt;
WORKDIR /usr/src/app&lt;br /&gt;
&lt;br /&gt;
# Install dependacies&lt;br /&gt;
COPY requirements.txt ./&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
&lt;br /&gt;
# Copy application files&lt;br /&gt;
COPY . .&lt;br /&gt;
&lt;br /&gt;
EXPOSE 5000/tcp&lt;br /&gt;
&lt;br /&gt;
# the command runs the migrations and then launches gunicorn to serve the app&lt;br /&gt;
CMD python -m flask db upgrade &amp;amp;amp;&amp;amp;amp; gunicorn -b :5000 qdj:app&amp;lt;/pre&amp;gt;&lt;br /&gt;
You have the following &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
  db:&lt;br /&gt;
    # Use a small postgres image, as we don&#039;t need anything on this container&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: somepassword&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    # store the data on a persistent file&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
    restart: always&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    # Use the image from Dockerfile&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:somepassword@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    # Tells to docker to start app after db (otherwise flask crashes)&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    # Always restart on crash&lt;br /&gt;
    restart: always&lt;br /&gt;
    &lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Production &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We will adapt your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file in order to bind your site to the hostname :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First let&#039;s connect your &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; container to the global network. We won&#039;t bind the &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; container to the global network to protect it from intruders. [[File:https://cloud.binets.fr/s/QTgY55AapFDTyyW/preview|Network graph in endalcher]] We will add network configuration to the &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to enable the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add at the bottom of the file:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to connect &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; to the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add to the &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; configuration:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  - web&lt;br /&gt;
  - default&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Then we can add labels to tell &amp;lt;code&amp;gt;traefik&amp;lt;/code&amp;gt; to match the hostname to a packet going to &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;labels:&lt;br /&gt;
    - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.port=5000&amp;quot;&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This gives us the following &amp;lt;code&amp;gt;docker-compose.qdj.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
&lt;br /&gt;
  db:&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    restart: always&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: qdjpw&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:qdjpw@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    restart: always&lt;br /&gt;
    networks:&lt;br /&gt;
      - web&lt;br /&gt;
      - default&lt;br /&gt;
    labels:&lt;br /&gt;
      - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.port=5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&lt;br /&gt;
&lt;br /&gt;
networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&lt;br /&gt;
This file goes into the [https://gitlab.binets.fr/br/docker-services br/docker-services] repository, it will be used by the triggered pipeline to create your containers.&lt;br /&gt;
&lt;br /&gt;
=== Triggering pipelines with Gitlab CI ===&lt;br /&gt;
&lt;br /&gt;
In this pipeline, we will need to add 2 jobs:&lt;br /&gt;
&lt;br /&gt;
* one to build the docker image using the &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;&lt;br /&gt;
* one to trigger the [https://gitlab.binets.fr/br/docker-services br/docker-services] pipeline to create the containers.&lt;br /&gt;
&lt;br /&gt;
To build the docker image, we will use the template do so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - master&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039;&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&amp;lt;/source&amp;gt;&lt;br /&gt;
The second job is rather tricky. We will use &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; to trigger the pipeline, using [https://docs.gitlab.com/ce/ci/triggers/README.html Gitlab Pipeline API]. This call is secured by a trigger token, which should be saved into your project variables as &amp;lt;code&amp;gt;$TRIGGER_TOKEN&amp;lt;/code&amp;gt;. This is what the job looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=qdj --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&amp;lt;/source&amp;gt;&lt;br /&gt;
Pay attention to this syntax because debugging this api call takes a lot of time...&lt;br /&gt;
&lt;br /&gt;
If you want to add variables that will be used in your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;, add other arguments to &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; like &amp;lt;code&amp;gt;--form variables[WELCOME_MESSAGE]=&amp;amp;quot;Hello World!&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can see an example of a CI using this in the [https://gitlab.binets.fr/br/qdj br/qdj] repo.&lt;br /&gt;
&lt;br /&gt;
Note: for BR project, you can use the &amp;lt;code&amp;gt;trigger&amp;lt;/code&amp;gt; syntax in the API call since you don&#039;t need autorisation.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
* In 2017, the BR16 set up a [https://kubernetes.io/ Kubernetes] cluster. They managed to set up a workflow to deploy seamlessly from gitlab on that cluster. However, the configuration was hard to maintain and the BR17 was not able to keep it going.&lt;br /&gt;
* In 2018, the BR17 (Oliver Facklam + Hadrien Renaud) set up a small docker service on a computer from the Salle Informatiques&lt;br /&gt;
&lt;br /&gt;
= Developping a site for BR docker deployement =&lt;br /&gt;
&lt;br /&gt;
Docker allows for most technologies to be abstracted into a container and thus most - if not all - sites can be deployed in docker. However, here is a bit of advice to make deployement less painful :&lt;br /&gt;
&lt;br /&gt;
* Before using a particular external service (something that should run in a seperate container), check that a well supported docker image exists and with a BRman that there are no other constraints (for example, using a MinIO will go through a seperate dedicated server that already exists rather than a container).&lt;br /&gt;
* Use a postgres database to get access to an admin website for your server.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/9/en&amp;diff=10943</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/9/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/9/en&amp;diff=10943"/>
		<updated>2026-08-05T12:40:20Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Interne: »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Interne:&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/8/en&amp;diff=10942</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/8/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/8/en&amp;diff=10942"/>
		<updated>2026-08-05T12:40:13Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « == Existing architecture == »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Existing architecture ==&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/7/en&amp;diff=10941</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/7/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/7/en&amp;diff=10941"/>
		<updated>2026-08-05T12:40:07Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « * Basics of git (videos [https://git-scm.com/video/what-is-version-control here] or the beginning of [https://git-scm.com/book/en/v2 this awesome online book]) ; * Basics of containers (see a really good explanation [https://www.docker.com/resources/what-container here]) and of docker-compose (see the getting-started [https://docs.docker.com/compose/gettingstarted/ here]) ; * Basics of web (see an [https://developer.mozilla.org/en-US/docs/Learn/Getting_started_wi... »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Basics of git (videos [https://git-scm.com/video/what-is-version-control here] or the beginning of [https://git-scm.com/book/en/v2 this awesome online book]) ;&lt;br /&gt;
* Basics of containers (see a really good explanation [https://www.docker.com/resources/what-container here]) and of docker-compose (see the getting-started [https://docs.docker.com/compose/gettingstarted/ here]) ;&lt;br /&gt;
* Basics of web (see an [https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works introduction] on MDN) ;&lt;br /&gt;
* Basics of gitlab-ci (reading the [https://docs.gitlab.com/ee/ci/ getting-started] is recommended) ;&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/6/en&amp;diff=10940</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/6/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/6/en&amp;diff=10940"/>
		<updated>2026-08-05T12:40:01Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « == Requirements == »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/5/en&amp;diff=10939</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/5/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/5/en&amp;diff=10939"/>
		<updated>2026-08-05T12:39:56Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « This tutorial will walk you through : * How to convert your website to a Docker service * How to build it automatically on Gitlab-CI * How to deploy it automatically on our servers »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial will walk you through :&lt;br /&gt;
* How to convert your website to a Docker service&lt;br /&gt;
* How to build it automatically on Gitlab-CI&lt;br /&gt;
* How to deploy it automatically on our servers&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10938</id>
		<title>Tuto pour le déploiement des sites avec Docker/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/en&amp;diff=10938"/>
		<updated>2026-08-05T12:39:50Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « == Overview == »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;At the end of this tutorial you will be able to deploy your website (or service) on the servers of the BR! This allows you to benefit from a free, high-performance and robust infrastructure!&lt;br /&gt;
&lt;br /&gt;
Note: this tutorial may be a bit tricky, so please don’t hesitate to get in touch with a BRman to get help.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Comment_déployer_des_conteneurs_Docker_sur_l&amp;amp;#039;infrastructure_du_BR&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= How to deploy Docker containers on the infrastructure of the BR =&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
This tutorial will walk you through :&lt;br /&gt;
* How to convert your website to a Docker service&lt;br /&gt;
* How to build it automatically on Gitlab-CI&lt;br /&gt;
* How to deploy it automatically on our servers&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* Basics of git (videos [https://git-scm.com/video/what-is-version-control here] or the beginning of [https://git-scm.com/book/en/v2 this awesome online book]) ;&lt;br /&gt;
* Basics of containers (see a really good explanation [https://www.docker.com/resources/what-container here]) and of docker-compose (see the getting-started [https://docs.docker.com/compose/gettingstarted/ here]) ;&lt;br /&gt;
* Basics of web (see an [https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works introduction] on MDN) ;&lt;br /&gt;
* Basics of gitlab-ci (reading the [https://docs.gitlab.com/ee/ci/ getting-started] is recommended) ;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
== Existing architecture ==&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
A physical server called &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt; deploys and runs your container. It uses the following services to connect your service to the Internet:&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* [https://docs.docker.com/compose/ docker-compose] to deploy the correct environment for your containers ;&lt;br /&gt;
* [https://docs.traefik.io/v1.7/ traefik] as a reverse proxy to serve your site behind your endpoint, it is configured [https://gitlab.binets.fr/br/docker-default-services here] ;&lt;br /&gt;
* nginx to serve your site to the outside world (as all the binets sites).&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
== How to convert your website to a Docker service ==&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
The exact procedure will be dependant on your project. An example can be found here : [https://gitlab.binets.fr/br/qdj/-/blob/master/deployment/Dockerfile?ref_type=heads qdj-Dockerfile]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
A &#039;&#039;Docker container&#039;&#039; is an isolated machine on which you can run your website. In this step, we will help you convert you app to be Docker-ready. This basically means installing everything your app needs inside a linux computer. You&#039;ll need to install &#039;&#039;Docker&#039;&#039; on your computer first [https://docs.docker.com/desktop/install/windows-install/ windows-installer].&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
We assume your project is hosted on the [https://gitlab.binets.fr BR&#039;s gitlab instance]. Create a &amp;lt;code&amp;gt;deployment&amp;lt;/code&amp;gt; directory at the root of your repository and create a file &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; (with no extension) and a file &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; in it.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Dockerfile&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
FROM hello-world&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* docker-compose.yaml&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
# this is a docker-compose meant for local testing of the deployment image.&lt;br /&gt;
# for the real deployment, go to the docker-services BR gitlab project&lt;br /&gt;
&lt;br /&gt;
version: &amp;quot;3&amp;quot;&lt;br /&gt;
services:&lt;br /&gt;
  app:&lt;br /&gt;
    build:&lt;br /&gt;
      context: ..&lt;br /&gt;
      dockerfile: deployment/Dockerfile&lt;br /&gt;
#    ports:&lt;br /&gt;
#      - &amp;quot;8000:8000&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Then open a terminal in this directory and type &amp;lt;code&amp;gt;docker compose up --build&amp;lt;/code&amp;gt;. If everything went well, you see a nice message from Docker telling you everything is working !&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
Now, you need to make &#039;&#039;your&#039;&#039; app work in the docker container. For this, you need:&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div lang=&amp;quot;fr&amp;quot; dir=&amp;quot;ltr&amp;quot; class=&amp;quot;mw-content-ltr&amp;quot;&amp;gt;&lt;br /&gt;
* To update the Dockerfile to install everything you need. The following works for a basic (Django) python app :&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
FROM python:3&lt;br /&gt;
&lt;br /&gt;
# copies all the code inside the container&lt;br /&gt;
COPY . /my_super_project&lt;br /&gt;
&lt;br /&gt;
WORKDIR /my_super_project&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
CMD python3 manage.py runserver&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To update the docker-compose file to expose the port you need (uncomment the corresponding line in the dockerfile).&lt;br /&gt;
&lt;br /&gt;
=== How to handle persistant data ===&lt;br /&gt;
&lt;br /&gt;
If you app uses an external database or need to not lose some files accross resets, you should use &#039;&#039;docker volumes&#039;&#039; with or without a &#039;&#039;postgres&#039;&#039; image. The [https://gitlab.binets.fr/br/docker-services/-/blob/master/docker-compose.site-jtx.yml?ref_type=heads jtx-docker-compose] might help you understand what you need.&lt;br /&gt;
&lt;br /&gt;
=== How to handle secrets  ===&lt;br /&gt;
&lt;br /&gt;
Often your app has some secrets in a file (such as &#039;&#039;.env&#039;&#039;) that is not in Git. DO NOT put it in git (or all your secrets will be stolen !). Later we are going to see how to securely make them available for the automatic gitlab build.&lt;br /&gt;
&lt;br /&gt;
== Automatic build ==&lt;br /&gt;
&lt;br /&gt;
We will you &#039;&#039;gitlab continuous integration&#039;&#039; to build your docker image directly on the BR&#039;s servers. Write the following into a file name &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; at the root of your repository :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
variables:&lt;br /&gt;
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_PIPELINE_IID&lt;br /&gt;
  PROJECT: mySuperProject&lt;br /&gt;
&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only: # put here the git branches you want the job to run on :&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039; # disables TLS in docker-in-docker (not needed)&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you commit this file to Gitlab, you should see a new job appear (or look under Build/jobs). Your image should build correctly (if not, it means something is not available to gitlab that is when you build on your computer. Read the job logs and try to fix it !)&lt;br /&gt;
&lt;br /&gt;
=== Checking the image ===&lt;br /&gt;
&lt;br /&gt;
This step is optional, but it is the easiest way to debug your image ! You can run it locally like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
docker login registry.binets.fr&lt;br /&gt;
docker run --rm registry.binets.fr/&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;:&amp;lt;image&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;image&amp;lt;/code&amp;gt; is the number of the image (available in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Deploy -&amp;gt; Container registry&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;&amp;lt;nom.prenom&amp;gt;/&amp;lt;my-gitlab-repo&amp;gt;&amp;lt;/code&amp;gt; is the same as in your project Gitlab URL.&lt;br /&gt;
&lt;br /&gt;
Typically, your app won&#039;t start because you forgot a secret file (see below how to manage that !).&lt;br /&gt;
&lt;br /&gt;
== Automatic deployment ==&lt;br /&gt;
&lt;br /&gt;
We will now add a second CI job to your repository to deploy your image. It will trigger &#039;&#039;another&#039;&#039; CI pipeline of [https://gitlab.binets.fr/br/docker-services br/docker-services]. This pipeline has the rights to deploy on &amp;lt;code&amp;gt;endalcher&amp;lt;/code&amp;gt;, and does so using a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file. To trigger it, add the following to your &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  only:&lt;br /&gt;
    - stable&lt;br /&gt;
  image: debian:latest&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --fail-with-body --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=$PROJECT --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure the variable &amp;lt;code&amp;gt;PROJECT&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;.gitlab-ci.yml&amp;lt;/code&amp;gt; is correct : our pipeline will deploy the file named &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order to create the correct &amp;lt;code&amp;gt;docker-compose.${PROJECT}.yaml&amp;lt;/code&amp;gt; file, you will need to create a Merge Request on [https://gitlab.binets.fr/br/docker-services br/docker-services], or send a &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file to a BRman. The [https://gitlab.binets.fr/br/docker-services br/docker-services] is full of examples and a basic one is explained below :&lt;br /&gt;
&lt;br /&gt;
=== Extra parameters and secrets ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way is still visible to the BR and everyone that has maintainer access to you repository ! If you need help setting up, don&#039;t hesitate to ask for help from the BR !&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also pass any parameter needed in the compose file by adding arguments to the cURL call like so : &amp;lt;code&amp;gt;--form variables[MY_SUPER_VARIABLE]=&amp;quot;elle vaut 42!&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pass secret environnements variables, store them in &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Variables&amp;lt;/code&amp;gt; and make sure they are &amp;quot;protected&amp;quot; and &amp;quot;masked&amp;quot;. Pass them like so &amp;lt;code&amp;gt;--form variables[MY_PASSWORD]=$PASSWORD_STORED_IN_GITLAB&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Secret files ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be aware that any secret passed this way too is visible to the BR and everyone that has &#039;&#039;ANY&#039;&#039; access to you repository (because they can get the docker image) ! So only do this for a private registry or make sure your setting &amp;lt;code&amp;gt;Settings -&amp;gt; General -&amp;gt; Visibility, project features, permissions&amp;lt;/code&amp;gt; only allows for registry access for members&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Another way to store secrets in your Gitlab repo is &amp;lt;code&amp;gt;Gitlab -&amp;gt; Settings -&amp;gt; CI-CD -&amp;gt; Secure-files&amp;lt;/code&amp;gt;. You can upload any (small) secret file here and it will not be exposed ! You can downlod it at buildtime like so :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=yaml&amp;gt;&lt;br /&gt;
# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - main&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &amp;quot;&amp;quot;&lt;br /&gt;
    # !!! where to download our secure .env file &lt;br /&gt;
    SECURE_FILES_DOWNLOAD_PATH: &amp;quot;.&amp;quot;&lt;br /&gt;
  script:&lt;br /&gt;
    # !!! download secure .env file&lt;br /&gt;
    - apk add --no-cache curl bash&lt;br /&gt;
    - curl --silent &amp;quot;https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer&amp;quot; | bash&lt;br /&gt;
    # build docker image&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&lt;br /&gt;
    - echo &amp;quot;=&amp;gt; pushed $IMAGE_TAG&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Private repository ===&lt;br /&gt;
&lt;br /&gt;
Keeping your repository private can be beneficial for security or privacy. But it require an extra step for the BR to access the docker image. We wille pass a [https://docs.gitlab.com/ee/user/project/deploy_tokens/#gitlab-deploy-token CI deploy token] as cURL parameter.&lt;br /&gt;
&lt;br /&gt;
* Go to your &amp;lt;code&amp;gt;Settings -&amp;gt; Repository -&amp;gt; Deploy token&amp;lt;/code&amp;gt; and create a token name exactly &amp;lt;code&amp;gt;gitlab-deploy-token&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Add the following parameters to the cURL call in your CI deploy job : &amp;lt;code&amp;gt; --form variables[OPTIONAL_PRIVATE_CI_REGISTRY]=$CI_REGISTRY --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_USER]=$CI_DEPLOY_USER --form variables[OPTIONAL_PRIVATE_CI_REGISTRY_PASSWORD]=$CI_DEPLOY_PASSWORD &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
You want to deploy the QDJ site with docker, and bind it to the server name &amp;lt;code&amp;gt;qdj.binets.fr&amp;lt;/code&amp;gt;. Your site is running on flask and uses a postgresql database.&lt;br /&gt;
&lt;br /&gt;
=== Pre-existant configuration ===&lt;br /&gt;
&lt;br /&gt;
You have a little &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# Base image: python3&lt;br /&gt;
FROM python:3&lt;br /&gt;
WORKDIR /usr/src/app&lt;br /&gt;
&lt;br /&gt;
# Install dependacies&lt;br /&gt;
COPY requirements.txt ./&lt;br /&gt;
RUN pip install --no-cache-dir -r requirements.txt&lt;br /&gt;
&lt;br /&gt;
# Copy application files&lt;br /&gt;
COPY . .&lt;br /&gt;
&lt;br /&gt;
EXPOSE 5000/tcp&lt;br /&gt;
&lt;br /&gt;
# the command runs the migrations and then launches gunicorn to serve the app&lt;br /&gt;
CMD python -m flask db upgrade &amp;amp;amp;&amp;amp;amp; gunicorn -b :5000 qdj:app&amp;lt;/pre&amp;gt;&lt;br /&gt;
You have the following &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
  db:&lt;br /&gt;
    # Use a small postgres image, as we don&#039;t need anything on this container&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: somepassword&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    # store the data on a persistent file&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
    restart: always&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    # Use the image from Dockerfile&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:somepassword@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    # Tells to docker to start app after db (otherwise flask crashes)&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    # Always restart on crash&lt;br /&gt;
    restart: always&lt;br /&gt;
    &lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Production &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We will adapt your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt; file in order to bind your site to the hostname :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First let&#039;s connect your &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; container to the global network. We won&#039;t bind the &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; container to the global network to protect it from intruders. [[File:https://cloud.binets.fr/s/QTgY55AapFDTyyW/preview|Network graph in endalcher]] We will add network configuration to the &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to enable the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add at the bottom of the file:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;to connect &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; to the network &amp;lt;code&amp;gt;web&amp;lt;/code&amp;gt;, we add to the &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt; configuration:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;networks:&lt;br /&gt;
  - web&lt;br /&gt;
  - default&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Then we can add labels to tell &amp;lt;code&amp;gt;traefik&amp;lt;/code&amp;gt; to match the hostname to a packet going to &amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;labels:&lt;br /&gt;
    - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
    - &amp;quot;traefik.port=5000&amp;quot;&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This gives us the following &amp;lt;code&amp;gt;docker-compose.qdj.yaml&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;version: &#039;3.1&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
&lt;br /&gt;
  db:&lt;br /&gt;
    image: postgres:alpine&lt;br /&gt;
    restart: always&lt;br /&gt;
    environment:&lt;br /&gt;
      POSTGRES_USER: qdj&lt;br /&gt;
      POSTGRES_PASSWORD: qdjpw&lt;br /&gt;
      POSTGRES_DB: qdj&lt;br /&gt;
    volumes:&lt;br /&gt;
      - &amp;quot;qdj-data:/var/lib/postgresql/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  app:&lt;br /&gt;
    image: ${DOCKER_IMAGE}&lt;br /&gt;
    environment:&lt;br /&gt;
      FLASK_APP: qdj.py&lt;br /&gt;
      FLASK_ENV: production&lt;br /&gt;
      FLASK_DEBUG: 0&lt;br /&gt;
      DATABASE_URI: &amp;quot;postgresql://qdj:qdjpw@db:5432/qdj&amp;quot;&lt;br /&gt;
      SECRET_KEY:&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - db&lt;br /&gt;
    restart: always&lt;br /&gt;
    networks:&lt;br /&gt;
      - web&lt;br /&gt;
      - default&lt;br /&gt;
    labels:&lt;br /&gt;
      - &amp;quot;traefik.docker.network=web&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.frontend.rule=Host:qdj.binets.fr&amp;quot;&lt;br /&gt;
      - &amp;quot;traefik.port=5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
volumes:&lt;br /&gt;
  qdj-data:&lt;br /&gt;
&lt;br /&gt;
networks:&lt;br /&gt;
  web:&lt;br /&gt;
    external: true&amp;lt;/source&amp;gt;&lt;br /&gt;
This file goes into the [https://gitlab.binets.fr/br/docker-services br/docker-services] repository, it will be used by the triggered pipeline to create your containers.&lt;br /&gt;
&lt;br /&gt;
=== Triggering pipelines with Gitlab CI ===&lt;br /&gt;
&lt;br /&gt;
In this pipeline, we will need to add 2 jobs:&lt;br /&gt;
&lt;br /&gt;
* one to build the docker image using the &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt;&lt;br /&gt;
* one to trigger the [https://gitlab.binets.fr/br/docker-services br/docker-services] pipeline to create the containers.&lt;br /&gt;
&lt;br /&gt;
To build the docker image, we will use the template do so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;# Build docker image and upload to registry&lt;br /&gt;
docker:build:&lt;br /&gt;
  stage: build&lt;br /&gt;
  only:&lt;br /&gt;
    - master&lt;br /&gt;
    - stable&lt;br /&gt;
  image: docker:stable&lt;br /&gt;
  services:&lt;br /&gt;
    - docker:dind&lt;br /&gt;
  variables:&lt;br /&gt;
    DOCKER_HOST: tcp://docker:2375/&lt;br /&gt;
    DOCKER_DRIVER: overlay2&lt;br /&gt;
    # For disabling TLS in docker-in-docker (not needed)&lt;br /&gt;
    DOCKER_TLS_CERTDIR: &#039;&#039;&lt;br /&gt;
  script:&lt;br /&gt;
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY&lt;br /&gt;
    - docker build --pull --build-arg version=$CI_PIPELINE_IID -t $IMAGE_TAG -f deployment/Dockerfile .&lt;br /&gt;
    - docker push $IMAGE_TAG&amp;lt;/source&amp;gt;&lt;br /&gt;
The second job is rather tricky. We will use &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; to trigger the pipeline, using [https://docs.gitlab.com/ce/ci/triggers/README.html Gitlab Pipeline API]. This call is secured by a trigger token, which should be saved into your project variables as &amp;lt;code&amp;gt;$TRIGGER_TOKEN&amp;lt;/code&amp;gt;. This is what the job looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;yaml&amp;quot;&amp;gt;docker:deploy:&lt;br /&gt;
  stage: deploy&lt;br /&gt;
  when: manual&lt;br /&gt;
  script:&lt;br /&gt;
    - apt-get update &amp;amp;&amp;amp; apt-get install -y curl&lt;br /&gt;
    - curl --request POST --form token=$TRIGGER_TOKEN --form ref=master --form variables[PROJECT]=qdj --form variables[DOCKER_IMAGE]=$IMAGE_TAG https://gitlab.binets.fr/api/v4/projects/560/trigger/pipeline&amp;lt;/source&amp;gt;&lt;br /&gt;
Pay attention to this syntax because debugging this api call takes a lot of time...&lt;br /&gt;
&lt;br /&gt;
If you want to add variables that will be used in your &amp;lt;code&amp;gt;docker-compose.yaml&amp;lt;/code&amp;gt;, add other arguments to &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; like &amp;lt;code&amp;gt;--form variables[WELCOME_MESSAGE]=&amp;amp;quot;Hello World!&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can see an example of a CI using this in the [https://gitlab.binets.fr/br/qdj br/qdj] repo.&lt;br /&gt;
&lt;br /&gt;
Note: for BR project, you can use the &amp;lt;code&amp;gt;trigger&amp;lt;/code&amp;gt; syntax in the API call since you don&#039;t need autorisation.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
* In 2017, the BR16 set up a [https://kubernetes.io/ Kubernetes] cluster. They managed to set up a workflow to deploy seamlessly from gitlab on that cluster. However, the configuration was hard to maintain and the BR17 was not able to keep it going.&lt;br /&gt;
* In 2018, the BR17 (Oliver Facklam + Hadrien Renaud) set up a small docker service on a computer from the Salle Informatiques&lt;br /&gt;
&lt;br /&gt;
= Developping a site for BR docker deployement =&lt;br /&gt;
&lt;br /&gt;
Docker allows for most technologies to be abstracted into a container and thus most - if not all - sites can be deployed in docker. However, here is a bit of advice to make deployement less painful :&lt;br /&gt;
&lt;br /&gt;
* Before using a particular external service (something that should run in a seperate container), check that a well supported docker image exists and with a BRman that there are no other constraints (for example, using a MinIO will go through a seperate dedicated server that already exists rather than a container).&lt;br /&gt;
* Use a postgres database to get access to an admin website for your server.&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
	<entry>
		<id>https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/4/en&amp;diff=10937</id>
		<title>Translations:Tuto pour le déploiement des sites avec Docker/4/en</title>
		<link rel="alternate" type="text/html" href="https://wikibr.binets.fr/index.php?title=Translations:Tuto_pour_le_d%C3%A9ploiement_des_sites_avec_Docker/4/en&amp;diff=10937"/>
		<updated>2026-08-05T12:39:48Z</updated>

		<summary type="html">&lt;p&gt;Daniela.cojocaru : Page créée avec « == Overview == »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;/div&gt;</summary>
		<author><name>Daniela.cojocaru</name></author>
	</entry>
</feed>