<?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: Lag and Log</title>
    <description>The latest articles on DEV Community by Lag and Log (@lagandlog).</description>
    <link>https://dev.to/lagandlog</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%2Forganization%2Fprofile_image%2F3705%2Fc6781815-0ae9-447d-9cf9-e6885fb02e2c.png</url>
      <title>DEV Community: Lag and Log</title>
      <link>https://dev.to/lagandlog</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lagandlog"/>
    <language>en</language>
    <item>
      <title>Free icons for your next project</title>
      <dc:creator>Sasidharan</dc:creator>
      <pubDate>Tue, 13 Jul 2021 14:30:21 +0000</pubDate>
      <link>https://dev.to/lagandlog/free-icons-for-your-next-project-4736</link>
      <guid>https://dev.to/lagandlog/free-icons-for-your-next-project-4736</guid>
      <description>&lt;p&gt;Here some of the free icons we can use in any library for our next projects and do wish to credit the creator.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Hero Icons - &lt;a href="https://heroicons.com/?ref=lagandlog.com" rel="noopener noreferrer"&gt;Visit&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Beautiful hand-crafted SVG icons, by the makers of Tailwind CSS. Simple to use.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Flaticon - &lt;a href="https://www.flaticon.com/icons/?ref=lagandlog.com" rel="noopener noreferrer"&gt;Visit&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;The largest database of free icons available in PNG, SVG, EPS, PSD, and BASE 64 formats. More variants so more to choose from.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. The Noun Project - &lt;a href="https://thenounproject.com/?ref=lagandlog.com" rel="noopener noreferrer"&gt;Visit&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;The World’s Most Diverse and Extensive Icon Collection. Over 3 million unique and simple icons.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. TablerIcons - &lt;a href="https://tablericons.com/?ref=lagandlog.com" rel="noopener noreferrer"&gt;Visit&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Open source, fully customizable 1000+ icons.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Icons8 - &lt;a href="https://icons8.com/?ref=lagandlog.com" rel="noopener noreferrer"&gt;Visit&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;The modern, unique set of icons in both SVG and png formats. Available in various styles.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://lagandlog.com/logs/free-icons-for-your-next-project" rel="noopener noreferrer"&gt;View all&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These are the various icon sets that I came across, feel free to add your favorite and go-to icons library in the comments below.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Go through the website to learn about free licensing on illustrations that you use.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Happy coding!
&lt;/h3&gt;

</description>
      <category>webdev</category>
      <category>icons</category>
    </item>
    <item>
      <title>How to dockerize React App</title>
      <dc:creator>Sasidharan</dc:creator>
      <pubDate>Sun, 02 May 2021 06:41:09 +0000</pubDate>
      <link>https://dev.to/lagandlog/how-to-dockerize-react-app-34df</link>
      <guid>https://dev.to/lagandlog/how-to-dockerize-react-app-34df</guid>
      <description>&lt;p&gt;Developing apps today requires so much more than writing code. Multiple languages, frameworks, architectures, and discontinuous interfaces between tools for each lifecycle stage create enormous complexity. It helps to speed up the development and deployment processes. If you’re working with microservices, Docker makes it much easier to link together small, independent services.&lt;/p&gt;

&lt;p&gt;React is an open-source, front-end, JavaScript library for building user interfaces or UI components. React can be used as a base in the development of single-page or mobile applications. &lt;/p&gt;

&lt;p&gt;I recently came up with a situation to containerize my React application, so learned the steps to containerize  &lt;strong&gt;production-ready&lt;/strong&gt;  applications and I'm sharing the same in this log,&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1
&lt;/h2&gt;

&lt;p&gt;To create react application via the command line, you should have  &lt;strong&gt;Node&lt;/strong&gt;  installed on your computer. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://nodejs.org/en/download/" rel="noopener noreferrer"&gt;Node Download&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-app
cd my-app
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Open &lt;a href="http://localhost:3000/" rel="noopener noreferrer"&gt;http://localhost:3000/&lt;/a&gt; to see your app.&lt;/p&gt;

&lt;p&gt;The folder structure will look like this,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; my-app/
      README.md
      node_modules/
      package.json
      public/
        index.html
        favicon.ico
      src/
        App.css
        App.js
        App.test.js
        index.css
        index.js
        logo.svg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2
&lt;/h2&gt;

&lt;p&gt;Before we containerize our application, we should create a special file that Docker understands, i.e, &lt;em&gt;Dockerfile&lt;/em&gt; in the root of your application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-app/
      Dockerfile &amp;lt;-
      README.md
      node_modules/
      package.json
      public/
        index.html
        favicon.ico
      src/
        App.css
        App.js
        App.test.js
        index.css
        index.js
        logo.svg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Docker builds images automatically by reading the instructions from a &lt;code&gt;Dockerfile&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A Docker image consists of read-only layers each of which represents a Dockerfile instruction. The layers are stacked and each one is a delta of the changes from the previous layer.&lt;/p&gt;

&lt;p&gt;Without further ado, let's write into our Dockerfile,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM node:13.12.0-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
RUN npm i --silent
COPY . ./
RUN npm run build

FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each instruction creates one layer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;FROM&lt;/code&gt; creates a layer from the &lt;code&gt;node:13.12.0-alpine&lt;/code&gt; Docker image.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;COPY&lt;/code&gt; adds files from your Docker client’s current directory.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RUN&lt;/code&gt; builds your application with &lt;code&gt;make&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CMD&lt;/code&gt; specifies what command to run within the container.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you run an image and generate a container, you add a new &lt;em&gt;writable layer&lt;/em&gt; (the “container layer”) on top of the underlying layers. All changes made to the running container, such as writing new files, modifying existing files, and deleting files, are written to this thin writable container layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3
&lt;/h2&gt;

&lt;p&gt;Now, let's build our Dockerfile,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -f Dockerfile -t my_react_app:prod .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  In the first 7 lines of the Dockerfile,
&lt;/h3&gt;

&lt;p&gt;it pulls the image that we specified in FROM and starts executes all our commands, and generates a single page react build.&lt;/p&gt;

&lt;h3&gt;
  
  
  the rest,
&lt;/h3&gt;

&lt;p&gt;takes that build folder, pulls Nginx image from Dockerhub, and copies our build to the &lt;code&gt;/html&lt;/code&gt; folder we specified. Now Nginx serves our React application inside  &lt;strong&gt;port 80&lt;/strong&gt;  inside the container.&lt;/p&gt;

&lt;p&gt;After all the steps/layers in Dockerfile are completed successfully, we can spin up the image using the following command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it --rm -p 5000:80 my_react_app:prod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in this, the port 80 from container listens in 5000 in our machine, which means we can view our application on &lt;a href="http://localhost:5000/" rel="noopener noreferrer"&gt;http://localhost:5000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this, now you can able to containerize your application in a docker. The steps will be similar to all large react projects.&lt;/p&gt;

&lt;p&gt;Follow me on twitter - &lt;a href="https://twitter.com/sasiKdharan" rel="noopener noreferrer"&gt;https://twitter.com/sasiKdharan&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Happy Coding 🤖
&lt;/h3&gt;

</description>
      <category>react</category>
      <category>docker</category>
    </item>
    <item>
      <title>Blog using Gatsby and Strapi</title>
      <dc:creator>Sasidharan</dc:creator>
      <pubDate>Sun, 02 May 2021 06:38:24 +0000</pubDate>
      <link>https://dev.to/lagandlog/blog-using-gatsby-and-strapi-5c00</link>
      <guid>https://dev.to/lagandlog/blog-using-gatsby-and-strapi-5c00</guid>
      <description>&lt;p&gt;Gatsby is a React-based framework, popular for performance, static site generation, and scalability. We have covered everything you need to &lt;a href="https://lagandlog.com/logs/get-started-with-gatsby" rel="noopener noreferrer"&gt;Get Started with Gatsby&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because it is based on React, the website pages are never reloaded which makes the generated website super fast. A large set of plugins is available to allow developers to save time coding.&lt;/p&gt;

&lt;p&gt;Strapi is the leading open-source headless CMS. It’s 100% Javascript, fully customizable, and developer-first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You need to have node v.12 installed.&lt;/li&gt;
&lt;li&gt;Basic knowledge of ReactJs and Javascript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Checkout  &lt;strong&gt;Get Started&lt;/strong&gt;  logs for Gatsby and Strapi,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://lagandlog.com/logs/get-started-with-gatsby" rel="noopener noreferrer"&gt;Get Started with Gatsby&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://lagandlog.com/logs/backend-made-easy-with-strapi" rel="noopener noreferrer"&gt;Backend made easy with Strapi&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I am using the same sample application that was created in the above logs. After completing the Gatsby project setup, and start editing the index.js file in /pages folder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect Gatsby with Strapi
&lt;/h2&gt;

&lt;p&gt;Strapi built a plugin for gatsby called &lt;code&gt;gatsby-source-strapi&lt;/code&gt; , install the plugin in our Gatsby application using the command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add gatsby-source-strapi

(or)

npm install gatsby-source-strapi`

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This plugin needs to be configured, so inside plugins array add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
{
 resolve: "gatsby-source-strapi",
 options: {
 apiURL: process.env.API_URL || "http://localhost:1337",
 contentTypes: ["blog"],
 queryLimit: 1000,
 },
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will allow Gatsby to fetch all our blogs on build time.&lt;/p&gt;

&lt;p&gt;Now you can start creating components and layouts for our blog. To get list of all blog posts inside our component refer to the following  &lt;strong&gt;Graphql&lt;/strong&gt;  query,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import { graphql, useStaticQuery } from "gatsby";
import PostComponent from "../components/posts";

const IndexPage = () =&amp;gt; {
  const data = useStaticQuery(query);

  return (
      &amp;lt;div&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;h1&amp;gt;Posts&amp;lt;/h1&amp;gt;
          &amp;lt;PostComponent articles={data.allStrapiPost.edges} /&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
  );
};

const query = graphql`
  query {
    allStrapiBlog(filter: { status: { eq: "published" } }) {
      edges {
        node {
          strapiId
          slug
          title
          }
        }
      }
    }
  }
`;

export default IndexPage;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will query all the posts and the data is passed via  &lt;strong&gt;data&lt;/strong&gt;  props to the component.&lt;/p&gt;

&lt;p&gt;Use the list of posts to render your blog posts on the page. Make your own styles.&lt;/p&gt;

&lt;p&gt;Image Source - &lt;a href="https://strapi.io/blog/build-a-static-blog-with-gatsby-and-strapi" rel="noopener noreferrer"&gt;Strapi Blog&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.strapi.io%2Fuploads%2FCapture-d-e-cran-2020-01-29-a--16.53.48--1-.png_8a775dfc1a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.strapi.io%2Fuploads%2FCapture-d-e-cran-2020-01-29-a--16.53.48--1-.png_8a775dfc1a.png" alt="Gatsby blog" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also use Javascript fetch() to list all posts via a REST API call to localhost:1337/blogs and render it on the screen.&lt;/p&gt;

&lt;p&gt;To create pages dynamically for all posts during build time, we have gatsby.node.js file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.createPages = async ({ graphql, actions }) =&amp;gt; {
  const { createPage } = actions;
  const result = await graphql(
    `
      {
        posts: allStrapiPost {
          edges {
            node {
              strapiId
              slug
            }
          }
        }
      }
    `
  );

  if (result.errors) {
    throw result.errors;
  }

  // Create blog pages.
  const posts = result.data.articles.edges;

  const PostTemplate = require.resolve("./src/templates/post.js");

  posts.forEach((post, index) =&amp;gt; {
    createPage({
      path: `/post/${post.node.slug}`,
      component: PostTemplate,
      context: {
        slug: post.node.slug,
      },
    });
  });
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will create pages for all your slugs dynamically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/post/my-first-post
/post/another-post
/post/my-second-post

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;using any markdown packages to render your markdown as HTML in Gatsby frontend.&lt;/p&gt;

&lt;p&gt;For more details, visit the documentation&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.gatsbyjs.com/docs/" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt; and &lt;a href="https://strapi.io/documentation/developer-docs/latest/getting-started/introduction.html" rel="noopener noreferrer"&gt;Strapi&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Happy Coding 👾
&lt;/h2&gt;

&lt;p&gt;AMA on &lt;a href="https://twitter.com/sasiKdharan" rel="noopener noreferrer"&gt;https://twitter.com/sasiKdharan&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gatsby</category>
      <category>strapi</category>
      <category>webdev</category>
    </item>
    <item>
      <title>LL Beta is out🎉</title>
      <dc:creator>Sasidharan</dc:creator>
      <pubDate>Mon, 15 Feb 2021 18:39:54 +0000</pubDate>
      <link>https://dev.to/lagandlog/ll-beta-is-out-2e72</link>
      <guid>https://dev.to/lagandlog/ll-beta-is-out-2e72</guid>
      <description>&lt;h1&gt;
  
  
  Knowledge sharing needs a simple platform!
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://lagandlog.com" rel="noopener noreferrer"&gt;https://lagandlog.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The easiest way to share knowledge and keep building your portfolio online.&lt;/p&gt;

&lt;p&gt;Rebuild your personal growth with Lag and Log and make use of the following features,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Write and share your thoughts seamlessly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Follow interests and topics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Grow with your community.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get noticed for promising content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get your own portfolio. (ex - &lt;a href="https://sudo.lglg.me" rel="noopener noreferrer"&gt;https://sudo.lglg.me&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use your own domain for your site.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Completely free to use.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start using &lt;a href="https://lagandlog.com/user/onboard" rel="noopener noreferrer"&gt;https://lagandlog.com/user/onboard&lt;/a&gt; and grow yourself by writing.&lt;/p&gt;

</description>
      <category>portfolio</category>
      <category>logs</category>
      <category>articles</category>
      <category>bloggers</category>
    </item>
  </channel>
</rss>
