<?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: Sandeep Chintala</title>
    <description>The latest articles on DEV Community by Sandeep Chintala (@sandeepchintala).</description>
    <link>https://dev.to/sandeepchintala</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%2F1063311%2F407d1b1c-ee1b-49ac-8409-8485df35dc8e.png</url>
      <title>DEV Community: Sandeep Chintala</title>
      <link>https://dev.to/sandeepchintala</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sandeepchintala"/>
    <language>en</language>
    <item>
      <title>Understanding Docker</title>
      <dc:creator>Sandeep Chintala</dc:creator>
      <pubDate>Wed, 12 Apr 2023 08:23:01 +0000</pubDate>
      <link>https://dev.to/sandeepchintala/understanding-of-docker-l0j</link>
      <guid>https://dev.to/sandeepchintala/understanding-of-docker-l0j</guid>
      <description>&lt;p&gt;In good olden days, Applications were managed to build and run in huge on-premises data centers allocated in separate rooms. Later trend shifted to Virtual machines. Now it is time for Docker. Maybe something in future but until then, it’s Docker….&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YbahAt_K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hekom7cd50df29koq04m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YbahAt_K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hekom7cd50df29koq04m.png" alt="Docker basics" width="728" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  History
&lt;/h2&gt;

&lt;p&gt;Container technology started in the year 2000. Many companies were involved in the evolution of Docker such as FreeBSD, Linux, Solaris, Google, Redhat, IBM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---o6usXgH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v43he7r940o9n9icl58b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---o6usXgH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v43he7r940o9n9icl58b.png" alt="Docker History" width="681" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is company called Docker, Inc. and technology called Docker. They are closely linked but they are not same. Docker, the company, technology start up from San francisco and main sponsor for the container technology Docker.&lt;/p&gt;

&lt;p&gt;Originally, it was company called dotCloud that provided a developer platform on top of AWS(Amazon Web Services). Around 2013, they designed a container to build, run and deploy the application on top of AWS and thought to give this tech to the world and build applications around it, that tech was nothing but Docker. Now Docker has literally changed the technology world.&lt;/p&gt;

&lt;p&gt;Docker , the technology is a software platform to build, run and deploy the applications. On the other hand, Docker, Inc. the company is now focused on orchestrating and supporting the containerised apps at scale on enterprise content management System.&lt;/p&gt;

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

&lt;p&gt;Docker is a Software platform to build, run and deploy applications. It is an open source and lives in Github. It has Community edition which is free to use and has many of the supporters Whereas enterprise edition is managed by Docker, Inc. provides support on enterprise content management system.&lt;/p&gt;

&lt;p&gt;To run applications in Docker, below is the workflow we follow to run inside the container.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Take application code&lt;/li&gt;
&lt;li&gt;Build it into a Docker image&lt;/li&gt;
&lt;li&gt;Push image to registry&lt;/li&gt;
&lt;li&gt;Start a container&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JHm0FtAt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zr5oy4vajgrurszdjjkt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JHm0FtAt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zr5oy4vajgrurszdjjkt.png" alt="Docker steps" width="682" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets elaborate each above step which gives us more clear view.&lt;/p&gt;

&lt;p&gt;Take you application code say Web, API or any other application. we can run anything in containers even if it is a monolithic application(it consumes more OS and supporting packages). But there are best principles we need to follow to run applications with minimal OS and minimal supporting packages. Saying it again Containers are not meant for Microservices and can run any applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Need Docker installed in your system to perform below operations.&lt;/p&gt;

&lt;p&gt;Create a file named with Dockerfile and write commands to build code into Docker images. Below is the sample snippet&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mZC9JkPj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gqued24r1wm37o1pr3x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mZC9JkPj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gqued24r1wm37o1pr3x.png" alt="Code Snippet" width="660" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run the following command to turn your code into images&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker image build -t reactweb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once after successful running, it pushes image to a registry. Now we start running image into container as below&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 -p 3000:80 -d reactweb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above command runs docker under host port with 3000. If you open browser and navigate to &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt;, it runs web applications.&lt;/p&gt;

&lt;p&gt;For reference, complete source code is in &lt;a href="https://github.com/sandeep0515/Microfrontends"&gt;React-Docker&lt;/a&gt; repository&lt;/p&gt;

&lt;p&gt;Isn’t it easy? yes it is. But still there is a lot to learn in Docker.&lt;/p&gt;

&lt;p&gt;Deep dive into Docker Architecture, Step by step for Installation and Docketerise the app and many more to come in upcoming blogs. Hope you like the content&lt;/p&gt;

&lt;p&gt;Stay tuned. See you in next article.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>beginners</category>
      <category>react</category>
      <category>devops</category>
    </item>
    <item>
      <title>Micro Frontends using React, Module Federation, Webpack 5</title>
      <dc:creator>Sandeep Chintala</dc:creator>
      <pubDate>Tue, 11 Apr 2023 21:48:50 +0000</pubDate>
      <link>https://dev.to/sandeepchintala/micro-frontends-using-react-module-federation-webpack-5-jio</link>
      <guid>https://dev.to/sandeepchintala/micro-frontends-using-react-module-federation-webpack-5-jio</guid>
      <description>&lt;h2&gt;
  
  
  Micro Frontends
&lt;/h2&gt;

&lt;p&gt;Extending the microservices idea to front end development. In the current trends, most of the application are migrating based on microservices architecture. In Microservice architecture, each feature or business is developed by independent teams and each team specialises in their respective feature and develops end-end.&lt;/p&gt;

&lt;p&gt;Monolith web applications sits on top of microservices which is a single page application develops all the features. Gradually application grows and team faces difficulty to maintain the entire application. Alike Microservices, design the same pattern from frontend and it is named as Micro Frontends, thought has come in the late 2016 by the Thoughtworks.&lt;/p&gt;

&lt;p&gt;Now Web application can maintain by independent teams for end-end development on each feature or business or module without knowing what other module does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Module federation
&lt;/h2&gt;

&lt;p&gt;New method of sharing code between frontend applications which makes code more straight forward and more independent. &lt;strong&gt;Module&lt;/strong&gt; &lt;strong&gt;federation&lt;/strong&gt; is one of the exciting features in Javascript architecture used in Webpack 5, loads code dynamically at runtime to reduce code duplication and host application loads only missing dependencies. It is one of the best ways to design the application in Microservice approach. And it has many benefits to web application if utilized appropriately.&lt;/p&gt;

&lt;h2&gt;
  
  
  Alternatives
&lt;/h2&gt;

&lt;p&gt;For Micro Frontends design, there are many other alternatives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bit&lt;/li&gt;
&lt;li&gt;Single-SPA&lt;/li&gt;
&lt;li&gt;SystemJs &lt;/li&gt;
&lt;li&gt;And many more ways to design the Micro Frontends.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Module Federation is not a framework, it is a plugin that is added to Webpack, which gives you freedom and flexibility to build your project the way you want and also offers developers to choose the technology they want to use. It integrates components at runtime. &lt;/p&gt;

&lt;h2&gt;
  
  
  Module Federation Configuration
&lt;/h2&gt;

&lt;p&gt;It is very easy to integrate Module federation within the application. It has two main concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Remote Federated Module&lt;/strong&gt;: Expose the components you want to share in Webpack.config.js&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Container Federated Module&lt;/strong&gt;: Consume and Render the exposed components by the Remote Federated Module.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step by Step
&lt;/h2&gt;

&lt;p&gt;Create two react applications, one for host (Shop-container) and other for remote(product) using below command&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shop-container
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app shop-container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app product
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Webpack in both applications&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i webpack webpack-dev-server webpack-cli css-loader 
html-webpack-plugin sass sass-loader style-loader url-loader 
@babel/core @babel/preset-env @babel/preset-react 
babel-loader -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Import Module Federation plugin as below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ModuleFederationPlugin = 
require("webpack/lib/container/ModuleFederationPlugin");
const dependencies = require("./package.json").dependencies;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create webpack.config.js file under root folder of Product application and plugin module federations&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Product application&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins: [
        new HtmlWebpackPlugin({
            template: "src/index.html",
        }),
        new ModuleFederationPlugin({
            name: "product",
            filename: "remoteEntry.js",
            remotes: {},
            exposes: {
                './App': './src/App.js',
            },
            shared: {
                ...dependencies,
                react: {
                    singleton: true,
                    requiredVersion: dependencies.react,
                },
                "react-dom": {
                    singleton: true,
                    requiredVersion: dependencies["react-dom"],
                },
            },
        })
    ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under &lt;strong&gt;ModuleFederationPlugin&lt;/strong&gt;, few of the properties which are common in use&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;exposes&lt;/strong&gt;: property is to expose the component which you want to share. If you share root components, all components will be loaded and route works the way it is.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;shared&lt;/strong&gt;: It is to include packages you needed when using this remote application. Suppose say, if you have angular as host/container application, remote is based on react, then it is where you include react packages to load the application. There are many benefits under the hood. some of them are singleton, avoid duplicate packages, loads missing packages and so on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;filename&lt;/strong&gt;: This plugin generates file with the name mentioned here and renders the file dynamically at runtime.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Similarly create webpack.config.js file under root folder of Shop-container application and plugin module federations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins: [
        new ModuleFederationPlugin({
            name: "shop-container",
            remotes: {
              product: "product@http://localhost:4500/remoteEntry.js"
            },
            exposes: {},
            shared: {
              ...dependencies,
              react: {
                singleton: true,
                requiredVersion: dependencies.react,
              },
              "react-dom": {
                singleton: true,
                requiredVersion: dependencies["react-dom"],
              },
            },
          })
    ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;remotes&lt;/strong&gt;: It is to mention all remote applications url along with filename. Here, shop-container application consumes Product application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now import product component and render the remote content as below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Product from 'product/App';

const App = () =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;Header&amp;gt;&amp;lt;/Header&amp;gt;
      &amp;lt;Routes&amp;gt;
        &amp;lt;Route path="/" element={&amp;lt;Home /&amp;gt;} /&amp;gt;
        &amp;lt;Route path="/products" element={&amp;lt;Product /&amp;gt;} /&amp;gt;          
      &amp;lt;/Routes&amp;gt;
      &amp;lt;Footer&amp;gt;&amp;lt;/Footer&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;use key name which mentioned in remotes property inside webpack.config.js and import the component name.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import Product from 'product/App';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and use the component&lt;/p&gt;

&lt;p&gt;Below are the screeshots of container and remote applications&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;product application&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u6CfmBF4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5tiyj3p75bujek6ynh4f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u6CfmBF4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5tiyj3p75bujek6ynh4f.png" alt="Product Application" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shop-container Application&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LRHU_v4Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v6yq5qov8rszn5o1bhey.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LRHU_v4Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v6yq5qov8rszn5o1bhey.png" alt="Shop Container Application" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For Reference, complete source code is in below repository&lt;br&gt;
[&lt;a href="https://github.com/sandeep0515/microfrontends-react"&gt;https://github.com/sandeep0515/microfrontends-react&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;We can create independent repositories for each application, containerized the applications separately and maintain the code easily.&lt;/p&gt;

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

</description>
      <category>react</category>
      <category>microservices</category>
      <category>javascript</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
