<?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: Nagailic Sergiu (Nikro)</title>
    <description>The latest articles on DEV Community by Nagailic Sergiu (Nikro) (@nikro).</description>
    <link>https://dev.to/nikro</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%2F641403%2F96920311-fb09-4513-b014-5f4b3b9d028a.jpeg</url>
      <title>DEV Community: Nagailic Sergiu (Nikro)</title>
      <link>https://dev.to/nikro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nikro"/>
    <language>en</language>
    <item>
      <title>Deep Dive into Drupal 8 + Gatsby.JS (Part 2)</title>
      <dc:creator>Nagailic Sergiu (Nikro)</dc:creator>
      <pubDate>Fri, 04 Jun 2021 10:39:27 +0000</pubDate>
      <link>https://dev.to/nikro/deep-dive-into-drupal-8-gatsby-js-part-2-h9h</link>
      <guid>https://dev.to/nikro/deep-dive-into-drupal-8-gatsby-js-part-2-h9h</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally posted on my personal / professional blog: &lt;a href="https://nikro.me/articles/professional/deep-dive-drupal-8-gatsbyjs-part-2/"&gt;Sergiu Nagailic - this is just a part of the full post&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Welcome to 2nd part -  hands-on or deep-dive into Drupal 8 + Gatsby.JS. Don’t treat this article as a tutorial - but hopefully, my experience will be useful for your journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who is it for?&lt;/strong&gt; 🎯&lt;/p&gt;

&lt;p&gt;If you’re a beginner that has some experience with Drupal (&lt;em&gt;or even if you’re pretty new to it&lt;/em&gt;) - during some 3-4 days, you can have a full-running website, secured, fast, and with zero hosting costs. If you want to experiment, learn something new, create a professional or personal blog, a product landing page, a business website, you name it - then it’s for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How much time?&lt;/strong&gt; ⌚&lt;/p&gt;

&lt;p&gt;It really depends on your knowledge and skills. It took me 5-8 days, but I mostly did around 2-3 hours per day (maybe with a weekend spike), that’s why I consider it 3-4 days (full-time). It also depends on the approach and template you’ll choose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why? What are the Advantages? Etc.&lt;/strong&gt; ❓&lt;/p&gt;

&lt;p&gt;Most of these things are covered in the &lt;a href="https://nikro.me/articles/professional/drupal-7-drupal-8-gatsbyjs/"&gt;1st article&lt;/a&gt; (aka part 1). But, to be short: Decoupled Drupal + Gatsby.JS combo offers a blazing fast website that looks and feels pretty dynamic, with a dynamic admin interface, editing experience, and no server costs, at the same time being able to handle almost any load. Sounds too good to be true? Don’t miss the &lt;a href="https://nikro.me/articles/professional/drupal-7-drupal-8-gatsbyjs/"&gt;1st article&lt;/a&gt; then.&lt;/p&gt;

&lt;p&gt;If you’re ready - let’s &lt;strong&gt;begin&lt;/strong&gt; 🚀&lt;/p&gt;

&lt;h1&gt;
  
  
  Initial Setup
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Docksal / Docker
&lt;/h2&gt;

&lt;p&gt;We will be using this boilerplate repo -  &lt;a href="https://github.com/docksal/boilerplate-drupal-gatsby"&gt;https://github.com/docksal/boilerplate-drupal-gatsby&lt;/a&gt;. It consists of Drupal, Gatsby, and Docksal (docksal is similar to pygmy (lagoon), or dd, or docker-compose - but it comes with a handy shell tool that glues everything together).&lt;/p&gt;

&lt;p&gt;Note - that I’ll explain everything only from a Linux (Debian-like) perspective as that’s what I’m working with.&lt;/p&gt;

&lt;p&gt;Make sure you have the following setup:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Basics - install curl, git; make sure apache / nginx / pygmy, etc isn’t running (this is explained &lt;a href="https://docs.docksal.io/getting-started/setup/"&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.Install &lt;a href="https://docksal.io/"&gt;Docksal&lt;/a&gt; - normally if you follow the steps, this should auto-install docker as well.&lt;/p&gt;

&lt;p&gt;Okay, now we can clone the repo - i.e. into /var/www/d8gatsby. Make sure you have some free space on the hard-drive and at least 8GB RAM in total - as this will create multiple docker containers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/docksal/boilerplate-drupal-gatsby /var/www/d8gatsby
cd /var/www/d8gatsby
fin start 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay, you can see things are happening now. To make sure that everything’s fine you can run: &lt;strong&gt;fin status&lt;/strong&gt; - you should get similar output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      Name                     Command                  State                 Ports           
-----------------------------------------------------------------------------------------------
d8gatsby_cli_1        /opt/startup.sh tail -f /d ...   Up             22/tcp, 3000/tcp, 9000/tcp
d8gatsby_db_1         docker-entrypoint.sh mysqld      Up (healthy)   0.0.0.0:49174-&amp;gt;3306/tcp   
d8gatsby_frontend_1   httpd-foreground                 Up             443/tcp, 80/tcp           
d8gatsby_php_1        /opt/startup.sh supervisord      Up             22/tcp, 3000/tcp, 9000/tcp
d8gatsby_preview_1    /opt/startup.sh bash -lc n ...   Up             22/tcp, 3000/tcp, 9000/tcp
d8gatsby_web_1        httpd-foreground                 Up             443/tcp, 80/tcp           
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If that’s the case - all good. Here’s what each container does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;d8gatsby_cli_1&lt;/strong&gt; - this is the CLI container - you interact with Drupal and Gatsby through it;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;d8gatsby_db_1&lt;/strong&gt; - this is the DB container - with Drupal Database;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;d8gatsby_php_1&lt;/strong&gt; - this is the PHP container - runs PHP;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;d8gatsby_web_1&lt;/strong&gt; - this is the web-server - configured to run Drupal;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;d8gatsby_frontend_1&lt;/strong&gt; - this is the Gatsby container - it’s showing the ‘production’ version of the Gatsby build;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;d8gatsby_preview_1&lt;/strong&gt; - this is the Gatsby container - it’s showing the ‘dev’ version of the Gatsby build - with ‘live’ changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re already familiar with Docksal - this repo adds some extra &lt;em&gt;custom commands&lt;/em&gt; - check those out. Also, feel free to explore the &lt;em&gt;.docksal/docksal.yml&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Drupal aka the CMS
&lt;/h2&gt;

&lt;p&gt;Now let’s configure the CMS side - we need to do the following steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd cms
fin composer install
fin composer update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands will run composer install and update from within the CLI container. You can now navigate to: &lt;a href="http://cms-d8gatsby.docksal/"&gt;http://cms-d8gatsby.docksal/&lt;/a&gt; and you should see an installation wizard for Drupal 8 (Note: the paths and the names of the containers depend on the folder name). I have chosen a Normal installation profile (not minimal) - so we can reuse the default defined fields and content-types. &lt;/p&gt;

&lt;p&gt;By the way, you can also run &lt;strong&gt;fin init&lt;/strong&gt;, instead of doing the wizard and all the following steps - and this will automatically install everything and wire things between them, but you will end up with an exact Umami installation profile and gatsby.js theme (like in the README file of the repo). This is not what I intend - instead, I want us to build our custom Gatsby theme and configure things manually - so &lt;strong&gt;don’t&lt;/strong&gt; run &lt;strong&gt;fin init&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;During installation - specify these details (default docksal mysql details):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Database name:&lt;/strong&gt; default&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database username:&lt;/strong&gt; user&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database password:&lt;/strong&gt; user&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Host:&lt;/strong&gt; db&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BTSImt1M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nikro.me/static/20b22ba1ff9665630318d301e4518b21/20530/install-wizard.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BTSImt1M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nikro.me/static/20b22ba1ff9665630318d301e4518b21/20530/install-wizard.png" alt="Wizard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don’t worry about production settings, these are temporary and only for local development (defined under &lt;strong&gt;settings.local.php&lt;/strong&gt;).&lt;/p&gt;

&lt;p&gt;Once you’re done, you have to see a fully installed Drupal 8 instance:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5F__iavH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nikro.me/static/9a28edae2f207d6bbab4e76f81541a7f/4628b/drupal8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5F__iavH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nikro.me/static/9a28edae2f207d6bbab4e76f81541a7f/4628b/drupal8.png" alt="Db Setup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Gatsby.JS aka Frontend
&lt;/h1&gt;

&lt;p&gt;Let’s leave the CMS at this point and focus our attention on the Gatsby.JS (frontend) side. &lt;br&gt;
Because we have deliberately chosen not to go with the default setup - building the frontend as-is - will fail, but let’s see how it fails:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ../frontend
fin fe/code-init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will initialize the code (run npm install, etc). And after, this we run the build command to build it: &lt;code&gt;fin fe/build&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You will see that it will fail - because currently our CMS doesn’t have any extra module installed, but the current Gatsby setup tries to query the JSON API and fails with http error message - 404.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3hEwFu7C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nikro.me/static/2319c3795779e15eaa4566ee8967b46c/1c2db/error-01.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3hEwFu7C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nikro.me/static/2319c3795779e15eaa4566ee8967b46c/1c2db/error-01.png" alt="Expected Error"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don’t worry, we’ll remedy this in a section below when we’ll be building our custom Gatsby ‘theme’.&lt;/p&gt;

&lt;p&gt;To sum-up: Drupal’s up and running, Docksal is up and running too, Gatsby isn’t but that’s what we’ll have to work on - we’re good to continue…&lt;/p&gt;

&lt;p&gt;--&lt;/p&gt;

&lt;p&gt;That was a part of the full tutorial, full &lt;a href="https://nikro.me/articles/professional/deep-dive-drupal-8-gatsbyjs-part-2/"&gt;post&lt;/a&gt; covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basics (of Gatsby.JS)&lt;/li&gt;
&lt;li&gt;Structure (file / folder structure)&lt;/li&gt;
&lt;li&gt;"Theme" setup&lt;/li&gt;
&lt;li&gt;Drupal Setup &amp;amp; Bridge&lt;/li&gt;
&lt;li&gt;GraphQL - query data&lt;/li&gt;
&lt;li&gt;Putting it all together...&lt;/li&gt;
&lt;li&gt;Deployment - going live&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://nikro.me/articles/professional/deep-dive-drupal-8-gatsbyjs-part-2/"&gt;Read the full post 👉&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hey, I'm new here, any suggestions / criticism is highly appreciated.&lt;/p&gt;

</description>
      <category>drupal</category>
      <category>gatsby</category>
      <category>react</category>
      <category>php</category>
    </item>
    <item>
      <title>From Drupal 7 to Drupal 8 + Gatsby.JS</title>
      <dc:creator>Nagailic Sergiu (Nikro)</dc:creator>
      <pubDate>Tue, 01 Jun 2021 08:42:42 +0000</pubDate>
      <link>https://dev.to/nikro/from-drupal-7-to-drupal-8-gatsby-js-41ko</link>
      <guid>https://dev.to/nikro/from-drupal-7-to-drupal-8-gatsby-js-41ko</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rnLck_dg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tyqodoqctame9vuw2gao.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rnLck_dg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tyqodoqctame9vuw2gao.jpg" alt="From Drupal 7 to Drupal 8 + Gatsby.JS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally posted on my personal / professional blog: &lt;a href="https://nikro.me/articles/professional/drupal-7-drupal-8-gatsbyjs/"&gt;Sergiu Nagailic&lt;/a&gt; - this is just a part of the full post.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Blog running on Drupal 7 (or any other CMS)
&lt;/h2&gt;

&lt;p&gt;Running a self-hosted blog has its challenges - and I bumped into some of those eventually. Well, rather than running out of ideas / motivation or time to come up with new articles, I eventually had some technical problems: &lt;strong&gt;Updates &amp;amp; Security&lt;/strong&gt; - being the most important one 🔑 👾.&lt;/p&gt;

&lt;p&gt;If you’re using a self-hosted blog, you eventually will need to do constant updates. The more popular engine you’re using - the more risks of being hacked and the more up-to-date you have to be (especially if you’re running on Wordpress). I am kinda lazy, so eventually I skipped some big updates and my hosting got hacked. And this happened many times.&lt;/p&gt;

&lt;p&gt;Many hacking waves are automated - they just crawl the web, identify Drupal websites and try commonly known exploits on them (that are documented everywhere), and if you’re not up-to-date, they breach-in. You can leave it hacked - but eventually someone will sell access to your hosting on the black-market and some shady things will start happening - in my cases I had some websites popping up on my VPS (I used DigitalOcean VPS) - and after making a backup of my website, I had enormous pleasure of destroying the Droplet with all the weird websites it had on it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l6nMGIoS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nikro.me/static/4604409326b9eaf48b5aec9bcb856929/df498/Things%252520I%252520had%252520problems%252520with.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l6nMGIoS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nikro.me/static/4604409326b9eaf48b5aec9bcb856929/df498/Things%252520I%252520had%252520problems%252520with.png" alt="Solutions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In modern days, there are ways one can automate this process, in example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;use something like &lt;a href="https://pantheon.io/"&gt;Pantheon&lt;/a&gt; - it comes with automatic core updates, however this still leaves room for contributed modules or plugins if you’re using Wordpress, which can also act as an attack vector&lt;/li&gt;
&lt;li&gt;use a CI tool, like &lt;a href="https://circleci.com/"&gt;CircleCI&lt;/a&gt; or &lt;a href="https://github.com/features/actions"&gt;Github Actions&lt;/a&gt; - you can have regular tasks that run daily, i.e. have proper Core Updates and Contributed Module Updates, maybe even run tests and if all goes well to deploy to production.&lt;/li&gt;
&lt;li&gt;something simpler but riskier would be - to have a cronjob that just runs updates directly on production - but you never know what will happen. Normally you want to test things first on your local environment and then replicate things on production.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, to me, these options are way overkill - I don’t want to pay extra for Pantheon, nor I want to write a CircleCI (or Github Actions) script or a crontab + shell script. Also I don’t want to constantly run updates locally and then deploy those (that’s why I got hacked in first place).&lt;/p&gt;

&lt;p&gt;Also, other than CMS’s vulnerabilities, there are also PHP’s vulnerabilities, Apache/Nginx’s vulnerabilities, ssh vulnerabilities - so you’d have to update the operating system itself and all the packages, then restart nginx, php-fpm, mysql and hope for the best.&lt;/p&gt;

&lt;p&gt;That's an introduction into the main post, &lt;strong&gt;more in this post&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Advantages of Headless Drupal + Static Front&lt;/li&gt;
&lt;li&gt;Gatsby.JS&lt;/li&gt;
&lt;li&gt;Migration Process (&lt;em&gt;with all the steps&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;Outcome&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://nikro.me/articles/professional/drupal-7-drupal-8-gatsbyjs/"&gt;Read the full post 👉&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hey, I'm new here, any suggestions / criticism is highly appreciated.&lt;/p&gt;

</description>
      <category>gatsby</category>
      <category>drupal</category>
      <category>php</category>
      <category>react</category>
    </item>
  </channel>
</rss>
