<?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: Tejesh Palagiri</title>
    <description>The latest articles on DEV Community by Tejesh Palagiri (@tejeshp).</description>
    <link>https://dev.to/tejeshp</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%2F724818%2F8db8b890-cff3-442c-a279-5a3b5cd3e091.png</url>
      <title>DEV Community: Tejesh Palagiri</title>
      <link>https://dev.to/tejeshp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tejeshp"/>
    <language>en</language>
    <item>
      <title>Dockerizing Angular App</title>
      <dc:creator>Tejesh Palagiri</dc:creator>
      <pubDate>Thu, 26 Jan 2023 10:52:12 +0000</pubDate>
      <link>https://dev.to/tejeshp/dockerizing-angular-app-48m1</link>
      <guid>https://dev.to/tejeshp/dockerizing-angular-app-48m1</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;What is Dockerizing?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Dockerzing&lt;/strong&gt; is the process of packing whole app into a single bundle that will be ready to deploy anywhere in any system that has docker got installed.&lt;/p&gt;

&lt;h1&gt;
  
  
  Let's get started....
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Angular&lt;/strong&gt; is a very popular framework to make single-page applications. I prepared a simple angular app that helps us in making HTTP Requests(GET,POST, PUT, DELETE, PATCH), simply like post man. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nginx&lt;/strong&gt; is a popular web-server that serves static content and also it will works as a reverse proxy. Since our web-app contains simple static content, We'll be using the Nginx to serve the static project.&lt;/p&gt;

&lt;p&gt;Dockerizing the angular app is so simple with the following steps&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prepare the Dockerfile in the Angular project directory&lt;/li&gt;
&lt;li&gt;Build the docker image with the following command&lt;/li&gt;
&lt;li&gt;Run the project with the help of image that we created&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Preparing the docker file
&lt;/h1&gt;

&lt;p&gt;Copy down the following script and create a new file with name &lt;strong&gt;Dockerfile&lt;/strong&gt; in the root directory of the project.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#stage 1&lt;/code&gt;&lt;br&gt;
&lt;code&gt;FROM node:latest as node&lt;/code&gt;&lt;br&gt;
&lt;code&gt;WORKDIR /app&lt;/code&gt;&lt;br&gt;
&lt;code&gt;COPY . .&lt;/code&gt;&lt;br&gt;
&lt;code&gt;RUN npm install&lt;/code&gt;&lt;br&gt;
&lt;code&gt;RUN npm run build&lt;/code&gt;&lt;br&gt;
&lt;code&gt;#stage 2&lt;/code&gt;&lt;br&gt;
&lt;code&gt;FROM nginx:alpine&lt;/code&gt;&lt;br&gt;
&lt;code&gt;COPY --from=node /app/dist/&amp;lt;app-name&amp;gt; /usr/share/nginx/html&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note: Replace the &lt;strong&gt;&lt;/strong&gt; with your application name&lt;/p&gt;

&lt;h1&gt;
  
  
  Preparing the image
&lt;/h1&gt;

&lt;p&gt;Use the following command to build the docker image&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;docker build -t &amp;lt;dockerhub-username&amp;gt;/&amp;lt;image-name&amp;gt;:&amp;lt;version&amp;gt; .&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or if you created the docker file in the other directory replace &lt;strong&gt;.&lt;/strong&gt; with the actual path of the docker file.&lt;/p&gt;

&lt;p&gt;After the successful building of the image. We should check if the image got added to the local repository of the docker with the following command&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;docker images&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now let's deploy the image into a container&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;docker run -p 8080:80 --name &amp;lt;container-name&amp;gt; -d &amp;lt;dockerhub-username&amp;gt;/&amp;lt;image-name&amp;gt;:&amp;lt;version&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After the successful running of the container we should see the status of the container with the following command and it says Up and running from some minutes/hours.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;docker ps&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6x4yff079tpgwns05lrk.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6x4yff079tpgwns05lrk.png" alt="Image description" width="800" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now if we go to browser and access it with &lt;code&gt;http://localhost:8080&lt;/code&gt; we should see the app running.&lt;/p&gt;

&lt;h1&gt;
  
  
  Pushing images to Docker hub
&lt;/h1&gt;

&lt;p&gt;We should have a docker hub account and we have to authenticate first. And then go through with the following steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Login with docker hub &lt;code&gt;docker login&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Push the image &lt;code&gt;docker push &amp;lt;dockerhub-username&amp;gt;/&amp;lt;image-name&amp;gt;&amp;lt;version&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;We have learnt creating an image of our angular application, running it in a docker container and pushing the image to docker hub.&lt;/p&gt;

&lt;p&gt;Thank you for reading the post. Hope the post is beginner friendly and it may helps you. I'm too a beginner :)&lt;/p&gt;

&lt;p&gt;Git Repo: &lt;code&gt;git clone https://github.com/TejeshPalagiri/REST-Pilot.git --branch master&lt;/code&gt;&lt;br&gt;
Docker Image: &lt;code&gt;docker pull tejeshpalagiri/rest_pilot&lt;/code&gt;&lt;/p&gt;

</description>
      <category>hackathon</category>
      <category>motivation</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
    <item>
      <title>How I made a URL shortener app -&gt; From making To deployment</title>
      <dc:creator>Tejesh Palagiri</dc:creator>
      <pubDate>Thu, 21 Oct 2021 13:30:13 +0000</pubDate>
      <link>https://dev.to/tejeshp/how-i-made-a-url-shortener-app-from-making-to-deployment-2emi</link>
      <guid>https://dev.to/tejeshp/how-i-made-a-url-shortener-app-from-making-to-deployment-2emi</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fapi-staging-shortio.herokuapp.com%2Faccessstats" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fapi-staging-shortio.herokuapp.com%2Faccessstats" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Shortbit
&lt;/h2&gt;

&lt;p&gt;The name of the app we created is &lt;a href="https://shortbit.netlify.app/" rel="noopener noreferrer"&gt;&lt;strong&gt;Shortbit&lt;/strong&gt;&lt;/a&gt;. This is pretty simple application that makes a long URL into a short URL and gives more in-depth insights of the link clicks and all other stuff such as the number of clicks, links shortened, from where the link is being clicked, which browser, referrer channel etc. These all things are visualized graphically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech used
&lt;/h2&gt;

&lt;p&gt;All the tech used for this app is &lt;strong&gt;MEAN&lt;/strong&gt; stack&lt;br&gt;
&lt;strong&gt;MongoDB&lt;/strong&gt; used for storing data of users, short URLs and some other stats.&lt;br&gt;
&lt;strong&gt;Redis&lt;/strong&gt; used for maintaining user sessions.&lt;br&gt;
&lt;strong&gt;Amazon SQS&lt;/strong&gt; helped in counting stats.&lt;br&gt;
&lt;strong&gt;Angular&lt;/strong&gt; for front-end and all other normal stuff.&lt;/p&gt;

&lt;h2&gt;
  
  
  Behind scenes
&lt;/h2&gt;

&lt;p&gt;All the implementation is pretty simple. Same as other URL shortener apps finds the long link with the given short link code and redirects the user to the long link.&lt;/p&gt;

&lt;p&gt;But after redirecting how can we count the stats like country, referrer channel, browser, device and other stats ?&lt;/p&gt;

&lt;p&gt;At first we made this as a simple project that doesn't counts any stats and it just redirects the user.&lt;/p&gt;

&lt;p&gt;After then we implemented counting stats logic with some known modules of NodeJS for processing a request and storing the stats. All this logic went well but when there are a huge number of requests server stopped working and again we need to restart the app.&lt;/p&gt;

&lt;p&gt;After then we tried to implement a message broker that holds the request data in a queue and then a micro service pick each item from the queue and consumes it and updates the related stats data.&lt;br&gt;
We searched for a free service provider of Message Broker service. Unfortunately we didn't find any provider that goes with a free plan. &lt;/p&gt;

&lt;p&gt;Then &lt;a href="https://aws.amazon.com/sqs/" rel="noopener noreferrer"&gt;&lt;strong&gt;Amazon SQS&lt;/strong&gt;&lt;/a&gt; helped us to make the requests save in the queue and helped the consumer microservice to consume the requests in the queue and updated the stats.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployment
&lt;/h2&gt;

&lt;p&gt;As the idea of the app is completely free. We hosted the whole back-end part of the app in &lt;a href="https://www.heroku.com/" rel="noopener noreferrer"&gt;Heroku&lt;/a&gt;. And tried of serving front-end also from back-end heroku dyno, but it costed us more in consuming the free dynos. So for front-end used &lt;a href="https://www.netlify.com/" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt;. For hosting a single page application we need to make necessary &lt;a href="https://answers.netlify.com/t/page-not-found-after-deployment/2362" rel="noopener noreferrer"&gt;changes&lt;/a&gt; such that we won't face any issues after reloading a page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Please feel free to check the &lt;a href="https://shortbit.netlify.app/" rel="noopener noreferrer"&gt;app&lt;/a&gt; we made. It's just a simple project that helps us to know and develop more deeper insights in creating any applicaiton.&lt;br&gt;
Thanks for reading !!!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>node</category>
    </item>
  </channel>
</rss>
