<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Quang Son Le</title>
    <description>The latest articles on DEV Community by Quang Son Le (@quangle).</description>
    <link>https://dev.to/quangle</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F100184%2F28afd883-8832-4bfb-9ac1-fcdae9b1c8e2.png</url>
      <title>DEV Community: Quang Son Le</title>
      <link>https://dev.to/quangle</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/quangle"/>
    <language>en</language>
    <item>
      <title>Git - Déplacer des dossiers d'un repo à un autre sans perdre l'historique</title>
      <dc:creator>Quang Son Le</dc:creator>
      <pubDate>Mon, 17 Sep 2018 12:49:24 +0000</pubDate>
      <link>https://dev.to/quangle/git---dplacer-des-dossiers-dun-repo--un-autre-sans-perdre-lhistorique-3kc4</link>
      <guid>https://dev.to/quangle/git---dplacer-des-dossiers-dun-repo--un-autre-sans-perdre-lhistorique-3kc4</guid>
      <description>&lt;p&gt;&lt;strong&gt;En deux mots, il va falloir:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cloner le repo d'origine dans un dossier local temporaire&lt;/li&gt;
&lt;li&gt;Isoler les fichiers à garder&lt;/li&gt;
&lt;li&gt;Copier les fichiers dans le repo de destination&lt;/li&gt;
&lt;li&gt;Faire un &lt;code&gt;git pull&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Il y a aussi  quelques précautions à prendre pour éviter que des erreurs de manipulation ne mettent le chaos dans le repo d'origine.&lt;/p&gt;

&lt;p&gt;La méthode décrite ci-dessous est un résumé/traduction/compte-rendu d'expérience de la méthode décrite par &lt;em&gt;mcarans&lt;/em&gt; sur &lt;a href="https://stackoverflow.com/questions/1365541/how-to-move-files-from-one-git-repo-to-another-not-a-clone-preserving-history"&gt;StackOverflow&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Préparer les fichiers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Soit A: le repo à déplacer&lt;br&gt;
  Et B, le repo de destination&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Clonez le repo en local et allez dedans:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone &amp;lt;lien vers le repo A&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cd &amp;lt;dossier du repo A&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Si vous avez déjà une copie du repo en local, je conseille de créer un dossier             temporaire et d'y cloner A.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pour éviter les dégâts liés aux fausses manoeuvres, coupez le lien avec origin:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git remote rm origin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Maintenant, si ça foire, vous êtes &lt;em&gt;safe&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Si vous ne voulez déplacer qu'un dossier en particulier, la commande suivante permet de ne garder que le dossier voulu et son historique:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git filter-branch --subdirectory-filter &amp;lt;~/dossier à garder&amp;gt; -- --all&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note: Dans mon cas, cette commande livre un message d'erreur:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fatal: &amp;lt;~/dossier à partager&amp;gt; est hors du dépôt&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Could not get the commits&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Je n'ai pas trouvé ce qui causait cette erreur, mais ça n'a pas empêché la suite du processus de se dérouler correctement.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;L'étape précedente met tous les fichiers de votre dossier tels quels dans le dossier principal de votre repo. Vous pouvez les réorganiser avant la migration:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;mkdir &amp;lt;nouveau dossier&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;mv * &amp;lt;nouveau dossier&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git add .&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git commit -m "&amp;lt;description du commit&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Pas besoin du &lt;code&gt;push&lt;/code&gt; vu qu'on a plus de lien avec origin.&lt;/p&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;La migration&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Si vous ne l'avez pas en local, clonez le repo B:&lt;br&gt;
&lt;code&gt;git clone &amp;lt;lien vers le repo B&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cd &amp;lt;dossier du repo B&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Créez une connection &lt;em&gt;remote&lt;/em&gt; de B vers A (où A sera une branche de B):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git remote add branche-A &amp;lt;chemin/local/vers/repoA&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;L'expression &lt;em&gt;branche-A&lt;/em&gt; peut être ce que vous voulez, c'est une désignation arbitraire que vous choisissez. Faites court, ça vous fera gagner du temps quand vous devrez le retaper.&lt;/p&gt;

&lt;p&gt;La solution sur StackOverflow disait de mentionner le chemin vers le sous-dossier à transférer. Lors de ma tentative, cela donnait un message d'erreur. Si vous mentionnez le dossier du repo (le dossier principal qui est créer quand vous clonez), ça marche tout aussi bien.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faites un bon vieux pull:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git pull branche-A master --allow-unrelated-histories&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;IMPORTANT: il se peut que vous deviez mettre git à jour pour qu'il reconnaisse &lt;code&gt;--allow-unrelated-histories&lt;/code&gt;. Sur Ubuntu, cela nécessite d'ajouter un repo:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo add-apt-repository ppa:git-core/ppa&lt;/code&gt;&lt;br&gt;
&lt;code&gt;sudo apt-get update&lt;/code&gt;&lt;br&gt;
&lt;code&gt;sudo apt-get install git -y&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Un peu de cleanup, et on push:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git remote rm &amp;lt;branche-A&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git push&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Normalement, les fichiers sont sur votre repo B avec leur historique de commit.     Si jamais ça a foiré, votre copie locale et votre repo sur GitHub sont &lt;em&gt;safe&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Bon rangement!&lt;/p&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Crédits: &lt;a href="http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/"&gt;http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/&lt;/a&gt;, &lt;a href="https://stackoverflow.com/questions/1365541/how-to-move-files-from-one-git-repo-to-another-not-a-clone-preserving-history"&gt;https://stackoverflow.com/questions/1365541/how-to-move-files-from-one-git-repo-to-another-not-a-clone-preserving-history&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>git</category>
    </item>
    <item>
      <title>Deploy your web app with Docker (Beginner)</title>
      <dc:creator>Quang Son Le</dc:creator>
      <pubDate>Wed, 12 Sep 2018 14:50:21 +0000</pubDate>
      <link>https://dev.to/quangle/deploy-your-web-app-with-docker-beginner-43ph</link>
      <guid>https://dev.to/quangle/deploy-your-web-app-with-docker-beginner-43ph</guid>
      <description>&lt;p&gt;During my internship at BeCode, I've been able to handle all deployements with &lt;a href="https://pages.github.com/"&gt;GitHub pages&lt;/a&gt; or &lt;a href="https://www.heroku.com/"&gt;Heroku&lt;/a&gt;. And then, last week, came the databases.&lt;/p&gt;

&lt;p&gt;Long stories short, we had to develop a basic client register with a mySQL database (so goodbye Heroku). Everything was working as expected locally, but - I'm pretty sure you can see what's coming - the whole thing collapsed when we tried to deploy.&lt;/p&gt;

&lt;p&gt;Let me share a post-mortem of what went wrong, before sharing a few tips on how to make your life easier with &lt;a href="//www.docker.com"&gt;Docker&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The details of the app don't matter, but here's a tiny bit of context:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We didn't anticipate that deployement would require a large amount of time, so we didn't start until the very last minute, which made the chaos and panic even worse.&lt;/li&gt;
&lt;li&gt;I had fiddled with Docker on a server in my free time, but couldn't make it work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we chose a free hosting service, moved all the files on their server, and then nothing worked.&lt;/p&gt;

&lt;p&gt;What seems to have happened is that the server was not running the same version of PHP we used to develop the website. It could have been avoided if we had done our research earlier, but hey, we learn from our mistakes.&lt;/p&gt;

&lt;p&gt;Which brings me to the meat of this post: Deploying with Docker.&lt;/p&gt;

&lt;p&gt;The little story above shows that the tricky thing with deploying your site or your app is that the environement provided by your host might differ considerably from your development environment. As a result, you need to anticipate and allocate time for deployment when planning your project.&lt;/p&gt;

&lt;p&gt;Now, if you're reading this post and have already heard about Docker, you know where this is going: using Docker can make your life easier by replicating your development environment on your server, quite literally.&lt;/p&gt;

&lt;p&gt;I'll let you follow the link if you want to learn what &lt;a href="https://www.docker.com/"&gt;Docker&lt;/a&gt; is and how it does what it does. Let me just share how I used it to redeploy our site elsewhere and saved us some tedious work:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Choose your host.&lt;br&gt;
I went for &lt;a href="https://www.digitalocean.com/"&gt;Digital Ocean&lt;/a&gt;, because it was recommended by someone I trust. It's not free though.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install Docker on the server&lt;br&gt;
It turns out Digital Ocean allows you to create VMs with Docker already installed. If you want to do it manually, just find a Ubuntu server and follow &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04"&gt;this tutorial&lt;/a&gt; (don't forget to install docker-compose).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Import your &lt;code&gt;docker-compose.yml&lt;/code&gt; into your server&lt;br&gt;
That's the magic part: if you used Docker to set up your developement environment, &lt;em&gt;you already have this file&lt;/em&gt;. All you need to do is to put it on a repository (GitHub, BitBucket, whatever you like) and clone it on your server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create the containers&lt;br&gt;
Go to the folder that will contain your app, put the &lt;code&gt;docker-compose.yml&lt;/code&gt; in it, then:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;docker-compose up&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That's it. Well almost. At this point, you might need to restart the server for things to work. I don't know why, but I had to do it.&lt;/p&gt;

&lt;p&gt;Now, all you need to do is clone your app's repository in the right folder on your server, and your app will run &lt;em&gt;exactly as it did locally&lt;/em&gt; because it will be running in the exact same environment. &lt;/p&gt;

&lt;p&gt;That should save you some time.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>php</category>
      <category>lamp</category>
      <category>xamp</category>
    </item>
  </channel>
</rss>
