<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adis Durakovic on Medium]]></title>
        <description><![CDATA[Stories by Adis Durakovic on Medium]]></description>
        <link>https://medium.com/@adis-durakovic?source=rss-da3a67e08a78------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*w7uwpiVEPmdDJwTAeztd4Q.jpeg</url>
            <title>Stories by Adis Durakovic on Medium</title>
            <link>https://medium.com/@adis-durakovic?source=rss-da3a67e08a78------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 15:10:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adis-durakovic/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to use LetsEncrypt certificates for local development]]></title>
            <link>https://adis-durakovic.medium.com/how-to-use-letsencrypt-certificates-for-local-development-f974a1d19ff9?source=rss-da3a67e08a78------2</link>
            <guid isPermaLink="false">https://medium.com/p/f974a1d19ff9</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[local]]></category>
            <dc:creator><![CDATA[Adis Durakovic]]></dc:creator>
            <pubDate>Tue, 05 Jan 2021 19:37:03 GMT</pubDate>
            <atom:updated>2021-01-05T19:37:03.676Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YUa-uGUE1BDRSpvO" /><figcaption>Image from pexels.com</figcaption></figure><p>Since the communication over the internet is moving toward SSL, it became really frustrating for developers to setup their local environments in that manner.</p><p>On one hand, you want to replicate your local-environment as close to production as possible, and on the other hand (and most importantly) when writing mobile apps, the communication layer to REST-APIs requires you nowadays to use SSL encrypted endpoints (HTTPS).</p><p>There are methods out there, where you create a self-signed certificate and import them, but this most of the time does not work as expected.</p><p>Fortunately enough, there’s a workaround which I was able to get running on my local setup, using LetsEncrypt certificates.</p><h3>The idea (in short)</h3><p>Just use a LetsEncrypt certificate for your local setup, and create a DNS record to point the domain to your local machine.</p><p>So let’s say you’re the owner of example.com and you have a valid wildcard certificate for both, example.com and *.example.com .</p><p>This means you have a valid certificate which you can use for domains likelocalproject.example.com , localapi.example.com etc.</p><p>So, locally, you set up your nginx-server to listen to localproject.example.com and use the (valid) wildcard certificate which you obtained from LetsEncrypt. Then you simply point that domain (in your hosts file) to the IP of your local machine 127.0.0.1</p><h3>How to do it?</h3><p>I’ll give you a brief overview of the steps. Although, I’m going to mention some services as examples, you’re still free to chose the ones you’d like.</p><h4>1. Get a cloud server</h4><p><a href="https://www.hetzner.com/">https://www.hetzner.com/</a> is not only cheap, but it allows you to spin up a server literally within seconds. The servers already have a public IP and you can access them instantly.</p><h4>2a. Register a domain</h4><p>You need to own a TLD domain, if you don’t already have one. In this example I’ll go with example.com . The easiest way is to get one at <a href="https://www.namecheap.com/">https://www.namecheap.com/</a></p><h4>2b. Point the domain to the cloud server</h4><p>If you register a domain, you need to point its primary and secondary nameserver (NS) to that of the provider where you have your cloud server running.</p><h4>3. Grab the certificate</h4><p>Now, if everything is set up correctly, example.com should point to the IP of your cloud server. Verify it with ping example.com</p><p>I won’t cover the process in detail, since there are already a few guides out there, on how to use certbot. The only thing you MUST do is to register a certificate for both domains example.com and its wildcard*.example.com</p><p><a href="https://www.digitalocean.com/community/tutorials/how-to-use-certbot-standalone-mode-to-retrieve-let-s-encrypt-ssl-certificates-on-ubuntu-16-04">https://www.digitalocean.com/community/tutorials/how-to-use-certbot-standalone-mode-to-retrieve-let-s-encrypt-ssl-certificates-on-ubuntu-16-04</a></p><h4>4. Use the obtained wildcard certificates on your local http-server</h4><p>Now that you have your certificates, download them so that you can use them in your nginx or apache configurations.</p><p>Very simplified, your nginx configuration should look like. The important part here are the ssl_certificate and ssl_certificate_key</p><pre>server {</pre><pre>listen 443 ssl default_server;</pre><pre>server_name project.example.com;</pre><pre>location / {</pre><pre>try_files $uri $uri/ /index.php?$query_string;</pre><pre>}</pre><pre>root /var/www/html;</pre><pre>index index.php;</pre><pre>include /etc/nginx/vhost.common.d/*.conf;</pre><pre>ssl_certificate     /etc/nginx/ssl/live/example.com/fullchain.pem;</pre><pre>ssl_certificate_key /etc/nginx/ssl/live/example.com/privkey.pem;</pre><pre>}</pre><h4>5. Point project.example.com to your local server</h4><p>This is the final step. When you browse project.example.com you’ll be pointed to the public cloud server, you just created. But we don’t want that, at least not for project.example.com , but we sure do want it for example.com , since there’s where your public website is, and you still want to access it.</p><p>The easiest way to do this, is to modify your hosts file and add a line like this</p><p>project.example.com 127.0.0.1</p><p>If you’re very fancy like me, and you have dnsmasq running on your router, you can configure it like this</p><p>address=/example.com/192.168.1.10 (local IP of your machine)</p><p>This will tell dnsmasq to point all subdomains of *.example.com to your local machine. This way, if you’re developing websites, you can test them on other devices too.</p><h4>Done!</h4><p>Now when you open project.example.com in your browser, you should be greeted with the satisfying green lock, indicating that your connection to your local website is secure, yeaah! :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f974a1d19ff9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Flutter Text Helpers]]></title>
            <link>https://adis-durakovic.medium.com/introducing-flutter-text-helpers-f3ea9b963091?source=rss-da3a67e08a78------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3ea9b963091</guid>
            <category><![CDATA[helpers]]></category>
            <category><![CDATA[widget]]></category>
            <category><![CDATA[text]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Adis Durakovic]]></dc:creator>
            <pubDate>Wed, 23 Dec 2020 11:17:13 GMT</pubDate>
            <atom:updated>2020-12-23T11:17:13.976Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever since I started developing apps with Flutter, I found that using the Text() widget in combination with styles becomes quite difficult to read, when flying over the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AnubOsBt_StT22BUcJSE0g.png" /></figure><h3>The ugly problem</h3><p>Imagine you want to add a headline, you’d have something like this.</p><pre><em>Text(&#39;Body text&#39;, style: Theme.of(context).textTheme.headline1)</em></pre><p>You’d have to look at the ending of the code-line to identify which element is actually rendered here.</p><p>Now, what if you for some reason need to change the color of that particular text, you’d end up with something like this.</p><pre><em>Text(&#39;Body text&#39;, style: Theme.of(context).textTheme.bodyText.copyWith(color: Colors.blue))</em></pre><p>You can’t clearly see what’s going on here, until you read the whole line of code. And this line of code can become even bigger sometimes.</p><h4>How to solve that?</h4><p>Well, one solution might be to create stateless Widgets for each and every piece of custom formatted text like GreenHeadline(‘some text’), GreenHeadlineBigger(‘Bigger text’), and so on.</p><p>The problem with this would be, that you’d have to create these Widgets for every new project.</p><h3>Meet flutter_text_helpers!</h3><p>The plugin offers shortcuts for rendering different styles of text-widgets while still allowing to add “ad-hoc” modifications, which are more readable.</p><p>Let me show you.</p><pre>HeadlineText1(&#39;Some headline!&#39;, color: Colors.blue, fontSize: 30),</pre><p>As you can see, it’s more readable and you know what’s going on here. A big blue headline :-)</p><p>Compare this to the Flutter-way of using the Text() widget, you’d have to write something like this.</p><pre><em>Text(&#39;</em>Some headline!<em>&#39;, style: Theme.of(context).textTheme.headline1.copyWith(color: Colors.blue, fontSize: 12))</em></pre><p>You’re still able to pass Text-specific properties like overflow, maxLines, etc… with the the addional (and in my opinion mostly overridden) properties like color and fontSize, which are usually passed to the ‘style’ property.</p><pre>HeadlineText1(&#39;Some headline!&#39;, overflow: TextOverflow.ellipsis)</pre><h4>Where to find?</h4><p>You can find it on pub.dev <a href="https://pub.dev/packages/flutter_text_helpers">https://pub.dev/packages/flutter_text_helpers</a></p><p>Contributions, issues etc. can be filed at <a href="https://gitlab.com/ad-on-is/flutter_text_helpers">https://gitlab.com/ad-on-is/flutter_text_helpers</a></p><h3>Hope you enjoy it!</h3><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3ea9b963091" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I turned my old 55" Samsung TV into a SmartTV with AmbiLight]]></title>
            <link>https://adis-durakovic.medium.com/how-i-turned-my-old-55-samsung-tv-into-a-smarttv-with-ambilight-357d009b61ee?source=rss-da3a67e08a78------2</link>
            <guid isPermaLink="false">https://medium.com/p/357d009b61ee</guid>
            <category><![CDATA[ambilight]]></category>
            <category><![CDATA[tv]]></category>
            <category><![CDATA[iot]]></category>
            <dc:creator><![CDATA[Adis Durakovic]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 11:31:21 GMT</pubDate>
            <atom:updated>2018-07-25T11:31:21.399Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AEYKhbMlGPmccTQ8dcC4gw.jpeg" /><figcaption>Colors in the image are not very accurate because of the smartphone camera</figcaption></figure><h4>TLDR;</h4><p>This solution, uses an AndroidTV box to provide the SmartTV functionality. For the ambilight, I had to “hack” into my TV to grab the pixel-information of what is shown on the screen and send that to an ESP8266-controller to control the LED-strip attached to it.</p><h3>Motivation</h3><p>I’m one of these guys who likes to modify and improve things that I already own, without buying new ones.</p><p>So, one day I decided to improve my old Samsung TV, which I got as a present from my parents, to extend it being more “smart” with a Philips-like Ambilight solution.</p><h3>The SmartTV</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*nSadUmuSrReIadExVPwOtQ.jpeg" /><figcaption>Photo by android.com</figcaption></figure><p>Looking around at many of the solutions, AppleTV, AndroidTV, etc… I opted for the Xiami MiBox, which recently got upgraded to AndroidTV Oreo.</p><p>It’s a full working stock AndroidTV, with built in ChromeCast and which also allows me to sideload apps, that are not accessible from the GooglePlay-store.</p><p>For 70,- bucks a great extension.</p><h3>The AmbiLight</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n1kWgo0dPS80uoE430hqSQ.jpeg" /></figure><p>Now this one is tricky. As of now, there is a great ambilight project out there, the <a href="https://hyperion-project.org/">hyperion-project</a>. But the fact, that I have to use an HDMI-splitter and not being able to switch HDMI-sources with my TV remote and automatically having the LED-strip using that source, bothered me.</p><p>As a smartphone-user who is familiar with rooting and installing custom software, I thought of the idea, that there MUST be some “rooting” method for a TV, to gain access to the TV’s pixel data and to send that somehow to a LED-strip. Luckily, there actually is something like that, well… kind of.</p><p>Doing my research, I stumbled upon SamyGO. Which is a community of programmers, providing useful instructions, how to “root” a Samsung TV, and offering some useful “libraries” to extend it’s functionality. Unfortunately, the information is just accessible to people who donate a small amount of BTC (10$) to the forum-owner. Which is really worth the money.</p><p>After I rooted my TV, I hoped, that one of these programmers already had the same idea like me and developed a library for an ambilight-solution. But unfortunately there wasn’t — so I had to write my own.</p><p>Since, I could not find any instructions on how to write libraries, I started digging into the source-code of other libraries to find out, how they’re developed. Well, after some trial&amp;error, and after crashing my TV a bunch of times :-D, I finally had a working solution.</p><h4>How it works</h4><p>The idea is very simple. I grab the TVs pixel, and send them via UDP to an ESP8266, which controls the LED-strip. This works no matter what is displayed on the TV, so the integrated tuner, every HDMI-source (AndroidTV, PlayStation4, … you name it).</p><h3>Installation</h3><p>So, if you want to try it on your own, here are some instructions how to achieve the same result as I have.</p><h4>Requirements</h4><ul><li>Samsung TV (E, F or H series)</li><li>Good USB-Stick (16GB)</li><li>ESP8266 12E (NodeMCU)</li><li>Addressable LED-strip (WS2801, WS2811… etc)</li><li>Power supply unit for the LED strip</li><li>Xiaomi MiBox</li></ul><h4>Rooting the TV</h4><p>Head over to <a href="https://forum.samygo.tv/">https://forum.samygo.tv/</a>, get into the Donator group and find a rooting method that works for your TV. I’d suggest one of these methods, where you install the root onto a USB stick. Since this is the saver method. If you screw anything up, you can remove the USB stick, and start over again, without messing with your TV system.</p><h4>Setting up the AmbientLight</h4><p>When you’re in the donor group, you should be able to access the files provided by me in the libAmbilight-topic and follow the installation-instructions there: <a href="https://forum.samygo.tv/viewtopic.php?f=75&amp;t=12460">https://forum.samygo.tv/viewtopic.php?f=75&amp;t=12460</a></p><h3>Total Costs</h3><ul><li>TV 55&quot;: free (but 830 € if I hadn’t one)</li><li>USB-Stick: 20 €</li><li>ESP8266: 5 €</li><li>LED-strip: 40€</li><li>PSU for LED-strip: 10€</li><li>Xiaomi MiBox: 70 €</li><li>Total: ~ 145 € (975 € with TV)</li><li>Hours spent in research and programming: ~ 70h</li></ul><h3>Conclusion</h3><p>Now the question is, was it worth all the effort. Considering that, if I haven’t had the TV and had to buy a new one, I would’ve spent 975 € for these setup, and another 70h of research and programming. Since there’s a Philips 55&quot; with AndroidTV and ambilight for around 700 €, it’d be much cheaper buying a new one with all the features included.</p><p>Another option would be to sell the TV, since it’s an older model, I don’t think I’d get more than 400 € for it, so I’d have to spend 300€ to buy the Philips one, which would be 150€ more than extending it myself. Although, I’d save on the 70hrs of research and programming.</p><p>IMHO: It was totally worth it. The 70 € for the MiBox is a really good deal. The nice-to-have-ambilight which is another 75€ was a great opportunity to improve my programming skills.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=357d009b61ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you should consider buying a MacBook Pro with higher SSD storage or not buying it at all]]></title>
            <link>https://adis-durakovic.medium.com/why-you-should-consider-buying-a-macbook-pro-with-higher-ssd-storage-or-not-buying-it-at-all-a4fc296d73db?source=rss-da3a67e08a78------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4fc296d73db</guid>
            <category><![CDATA[mpb]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[issues]]></category>
            <dc:creator><![CDATA[Adis Durakovic]]></dc:creator>
            <pubDate>Sun, 24 Jun 2018 13:34:27 GMT</pubDate>
            <atom:updated>2018-06-24T13:43:33.438Z</atom:updated>
            <content:encoded><![CDATA[<p>Back in late 2016 when I was about to buy the shiny new MBP, I opted for the 256 GB variant.</p><p>My intention was to use the internal SSD for the system and the apps, while storing all my user-files on an external drive.</p><p>I used a similar approach previously, when I had my<strong> iMac late 2012</strong>, which I upgraded with an SSD drive, while still keeping the HD inside and mounting it as my home directory. Being a long-time Windows user, who had to deal with lost data due to missing backups, I considered this to be an ideal solution for setting up a system, that can easily be recovered in case something breaks down —<em> which thankfully never happened ;-)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*73AsgTKlrSELRieOuHoC-w.png" /><figcaption>You can change the home directory in System Preferences -&gt; Users &amp; Groups, right click the user and select “Advanced Options” — you have to unlock this setting in the bottom left corner first</figcaption></figure><p>After setting up my fresh new MBP, I quickly found out, that the approach of mounting the home directory to an external drive, was a bad idea. And yes, I know: I should’ve kept in mind, that I’m dealing with an portable machine now, and that re-plugging external hard-drives will become a pain in the a** — <em>but hey, we all learn from our mistakes, right?</em></p><p>So I set everything back as it was before and only stored my project-files, photos, videos etc on the external SSD. I thought I can live with that, having this stuff stored externally, and knowing that I should be able to access it reliably each time I need it. — <em>As it turned out, this wasn’t the case.</em></p><p>Which brings me to my main point of this story, or let’s say my next big mistake:</p><p><strong>I opted for an MBP late 2016 with 256GB of storage to save money!</strong></p><p>It’s now over a year since I use it as my daily machine for work, and I’d be lying if I wouldn’t admit, that I had more struggles than I ever had with any Mac before (iMac late 2012, MBP…etc.)</p><p>Besides the usual flaws I had with my shiny new machine, and I’m sure you’ve heard of most of them:</p><ul><li>loosing fingerprint on Touch ID</li><li>faulty keyboard</li><li>external display issues after sleep mode, etc.</li></ul><p>There’s one major issue that really annoys my daily workflow — and it’s this little notification, which pops up a bunch of times, depending on how many external drives (or partitions/volumes) you have connected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*WVL2edxGfVnarXn0oRoOww.png" /><figcaption>Some notifications disturbing my workflow!</figcaption></figure><p>Yes… the system keeps ejecting all my external drives, <strong>during my workflow.</strong></p><p>One can imagine how annoying this really is, especially when you’re in the middle of a project, which uses files that are located on an external drive. As a web developer, using Docker, this is not reliable at all.</p><p>Additionally I have another hard drive which serves as a TimeMachine backup. Right now, I’m afraid, that all these “re-pluggings” may corrupt some backed up data, which I might rely on in the future. — <em>Only God knows, and maybe the guys at Apple.</em></p><p>Well, with that being said:</p><p>If you expect to store more than 256GB of data, which you’ll need for your every-day-usage, like project-files, photos, videos, etc… go at least for the 512GB option or maybe a bigger one, if you want to be on the safe side. And if you think that this might be too expensive for you, well then, don’t buy a MacBook Pro at all.</p><p>Unfortunately, I had to learn it the hard way, so therefore I’m sharing my experience with you, saving you from making the same mistake I did.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4fc296d73db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup an nginx-based webserver for multiple websites on Google Cloud Platform with Docker and Let’s…]]></title>
            <link>https://adis-durakovic.medium.com/setup-an-nginx-based-webserver-for-multiple-websites-on-google-cloud-platform-with-docker-and-lets-1ebfd9ee8841?source=rss-da3a67e08a78------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ebfd9ee8841</guid>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Adis Durakovic]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 10:23:24 GMT</pubDate>
            <atom:updated>2018-02-26T10:23:24.700Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setup an nginx-based webserver for multiple websites on Google Cloud Platform with Docker and Let’s Encrypt auto-updates</h3><p>If you need to run multiple websites on one place, you can either get one of the preconfigured web-hosting solutions or setup one by yourself which allows you to have full control over your configuration. Thanks to docker the latter is easier nowadays then ever before.</p><h3>Steps</h3><ol><li>Google Cloud Platform setup (VM instance, IP-address, domain)</li><li>Setup Docker and docker-compose</li><li>Obtain Let’s Encrypt certificate and auto-renewal</li></ol><h3>Google Cloud Platform setup</h3><h4>Create a VM instance</h4><p>The first thing you will need is a VM instance in GCP. You can create VM instances very easily under “Computing Engine” &gt; VM instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*T59nWqOnvrAlpeWGPTlRag.png" /></figure><p>Make sure to enable “Allow HTTP traffic” and “Allow HTTPS traffic”. This will set the right firewall settings for you. You can also set the Access scopes to “Allow full access to all Cloud APIs” which will make it easier for you to work with all GCP APIs in the future if you need.</p><p>Note that your VM instance has an IP assigned to it. This IP is temporary, which means it will change after you restart your instance. We want the instance to have a static IP address.</p><h4>Create a static IP address</h4><p>For that, we have to go over to “VPC network” &gt; External IP addresses and “Reserve a static address”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*f-a9m6GLWNA7hEbfxr3BcA.png" /></figure><p>Make sure to select your previously created VM instance in the “Attached to” dropdown.</p><p>Now that your VM instance has a fixed IP address, we need to create a DNS entry for a domain which will point to that address.</p><h4>Point your domain to the VM instance/IP address</h4><p><strong>Important note:</strong> Depending on where you’ve registered your domain, you additionally need to point the domain to the previously created IP address in your registrars settings. Since your registrar and all the other root-servers in the world don’t know nothing about your intention to host your website on GCP. The propagation of the DNS can take up to 48 hours. As a workaround you may want to edit your hosts-file and point the IP address manually.</p><p>For detailed information on how DNS works: <a href="https://en.wikipedia.org/wiki/Domain_Name_System">https://en.wikipedia.org/wiki/Domain_Name_System</a></p><p>So, let’s setup the DNS entry for your first domain, you want to point to your newly created VM instance. Go to “Network services” &gt; Cloud DNS and create a new zone. Repeat this step for every domain you want to point to your future web server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*dglKR2CAtQV0CSt5sUJoIw.png" /></figure><p><strong>BONUS: </strong>If you want to use your domain’s emails with Google GSuite, this is the place where you can set the MX-records according to the GSuite guidlines. Otherwise you can ignore them.</p><p>Now that you’ve a piece of server where you can work on, an IP address, that points to that server and a domain, which points to that IP, you’re ready to move to the next step. Setup a web-server with Docker.</p><h3>Setup Docker</h3><h4>Install Docker and docker-compose</h4><p>So to setup Docker we have to SSH into our VM instance and install docker there.</p><p>Head back to “Compute Engine” &gt; VM instances and click on the SSH button next to your instance. A new window with a console will pop up and you’re ready to go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*bgVThS40bpSUCbhDK5fu3A.png" /></figure><p>To install Docker, follow the instructions as shown on the official Docker documentation: <a href="https://docs.docker.com/install/linux/docker-ce/debian/#set-up-the-repository">https://docs.docker.com/install/linux/docker-ce/debian/#set-up-the-repository</a></p><p>Do the same for docker-compose: <a href="https://docs.docker.com/compose/install/">https://docs.docker.com/compose/install/</a></p><p>To verify that everything is installed correctly, type `docker -v` and `docker-compose -v` to get the versions respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*4qJ5rIDSasXB5r2ZG8m3jg.png" /></figure><h4>Choose a Docker image</h4><p>When you search for pre-configured web-server images, you will come across many good ones. I like to work with the WebDevOps Docker images, since I find them to be the best configured ones and you can use them in your docker-compose right out of the box without further configuration.</p><p><a href="https://github.com/webdevops/Dockerfile">webdevops/Dockerfile</a></p><p>For this tutorial I’m going to use the <strong>webdevops/php-nginx:ubuntu-17.04</strong> tag. As the name already suggests, it’s an Ubuntu based image, with PHP and nginx. With that image, I was able to run WordPress, TYPO 3, CakePHP without any further configuration. Other frameworks like Laravel, Symfony, Drupal, etc. should work as well.</p><p>For MySQL, I’ll use the official <strong>mysql:latest</strong> Docker image.</p><p>Well, before we create our docker-compose.yml, let’s first start up a container and extract the configuration files for the webdevops-image so that you can add virtual hosts, SSL-certificates etc. more easily later on.</p><p>Type the following command into your console:</p><pre>docker run --name webtmp -d webdevops/php-nginx:ubuntu-17.04</pre><p>This will download and execute the Docker container in the background and give it a name we can refer to.</p><p>Now copy the nginx folder from the container to your home-folder:</p><pre>docker cp webtmp:/opt/docker/etc/nginx .</pre><p>Finally you must stop and delete the container with, so that we can run it with docker-compose later.</p><pre>docker stop webtmp &amp;&amp; docker rm webtmp</pre><h4>Configure docker-compose.yml</h4><p>We need to create a docker-compose.yml that will start up a Docker container for the nginx web-server and one for the MySQL-server.</p><p>You can use my pre-configured docker-yompose.yml and modify it to your settings:<br><a href="https://github.com/ad-on-is/gcp/blob/master/docker_compose.yaml">https://github.com/ad-on-is/gcp/blob/master/docker_compose.yaml</a></p><p>When done, run `<strong>docker-compose up -d`</strong> to start up the containers in the background.</p><p>As for now, you should have a running web-server, be able to create an index.html file in the html folder which will be mounted in the web-containers /var/www/html folder, which then should be shown when you browse to <a href="http://example.com./">http://example.com.</a></p><p>This also allows you to SFTP into your server and copy all your files into the html folder without worrying about colliding read/write permissions.</p><p>I’d recommend to create a new subfolder for each domain within the html-folder and thus setup the nginx virtual hosts.</p><p>Let’s move on to the Let’s Encrypt certificates.</p><h3>Obtain a Let’s Encrypt certificate for your domain and setup auto-renewal cronjob</h3><h4>Obtain certificate</h4><p>If the DNS propagation isn’t done by now, you have to postpone this step until it’s done.</p><p>To generate and renew Let’s Encrypt certificates we well use the official certbot Docker image. Since we don’t need this image to run continuously in the background, simply run the container with Docker and follow the instructions.</p><pre>docker run --rm -v nginx/ssl:/etc/letsencrypt -v html:/webroot certbot/certbot certonly --webroot</pre><p>Repeat this step for every domain you want to obtain a certificate for.</p><p>Your obtained SSL-certificate should now be in the nginx/ssl folder.</p><p>Make sure, your nginx/ssl/renewal/example.com.conf has the proper webroot_map set, otherwise the renewal won’t work properly.</p><pre>[[webroot_map]]<br>example.com = /webroot/example.com</pre><h4>Setup cronjob for renewal</h4><p>Finally, we will create a cronjob that runs every day at 01:00AM to renew all the certificates.</p><p>I’ve written a small shell script that runs the certbot renewal and restarts the nginx server for the changes to take effect. It also logs the output to a file in your home folder. Feel free to use it and adapt it to your needs.<br><a href="https://github.com/ad-on-is/gcp/blob/master/cronjob_renew_letsencrypt.sh">https://github.com/ad-on-is/gcp/blob/master/cronjob_renew_letsencrypt.sh</a></p><p>Opening up the cron editor we can execute the script every day at 01:00AM.</p><pre>crontab -e</pre><p>Add the following line to your cronfile and save.</p><pre>0 1 * * * sh /home/YOUR_GCP_USERNAME/cronjob_renew_letsencrypt.sh</pre><h3>Done!</h3><p>We’re done folks :-) As you can see, It’s that simple to set up a web-server on Google Cloud Platform with Docker.</p><p>Let me know in the comments if you have troubles or any recommendations.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ebfd9ee8841" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>