<?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: Shivam Singhal</title>
    <description>The latest articles on DEV Community by Shivam Singhal (@championshuttler).</description>
    <link>https://dev.to/championshuttler</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%2F125179%2F391639c2-a84a-4310-ac0a-a05e4ae9b880.jpeg</url>
      <title>DEV Community: Shivam Singhal</title>
      <link>https://dev.to/championshuttler</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/championshuttler"/>
    <language>en</language>
    <item>
      <title>Creating accordions with native HTML
</title>
      <dc:creator>Shivam Singhal</dc:creator>
      <pubDate>Sat, 12 Dec 2020 12:43:24 +0000</pubDate>
      <link>https://dev.to/itsopensource/creating-accordions-with-native-html-1mgi</link>
      <guid>https://dev.to/itsopensource/creating-accordions-with-native-html-1mgi</guid>
      <description>&lt;p&gt;Accordions are one of the most commonly used UI components for any website. For example FAQs section of the website, where only the question is shown, and when clicked the answer just opens up.&lt;br&gt;
Generally, we handle this by creating 2 &lt;code&gt;divs&lt;/code&gt; and adding some javascript to handle the open and close of the accordion. But recently I stumbled upon this hidden gem in HTML that eliminates the need of all this - &lt;a href="https://developer.mozilla.org/docs/Web/HTML/Element/details"&gt;&lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can simply design a simple FAQ or summary section with &lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt; HTML tag without using Javascript!!! 🤯🤯🤯.&lt;br&gt;
And the best part... it is supported by all the modern browsers (obviously except IE :( ) - &lt;a href="https://caniuse.com/?search=details"&gt;browser compatibility&lt;/a&gt;.  &lt;/p&gt;
&lt;h3&gt;
  
  
  Using &lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt; tag
&lt;/h3&gt;

&lt;p&gt;There are two elements here: &lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;summary&amp;gt;&lt;/code&gt;. &lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt; is the wrapper for all the content you want to show and hide, and  contains the — well, the summary and title of the section. &lt;code&gt;&amp;lt;summary&amp;gt;&lt;/code&gt; is optional, if you do not add it, the browser will use some default text. For example, in Firefox and Chrome, it is &lt;code&gt;Details&lt;/code&gt;. Below is a sample HTML markup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;details&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;Details&lt;span class="nt"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Something small enough to escape casual notice.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/details&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it will render like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TrZYOQZC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vgjgg43x944mbadpks72.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TrZYOQZC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vgjgg43x944mbadpks72.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This markup can be designed with CSS as any other HTML element. Now for creating beautiful accordions all you need is just HTML and CSS (and a will to let go of IE).&lt;/p&gt;

&lt;p&gt;Demo: &lt;a href="https://bit.ly/htmldetails"&gt;https://itsopensource.com/demos/details/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details"&gt;MDN: details&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cheers.&lt;/p&gt;

</description>
      <category>html</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>How to checkout github pull requests locally like Pro
</title>
      <dc:creator>Shivam Singhal</dc:creator>
      <pubDate>Thu, 01 Oct 2020 18:57:16 +0000</pubDate>
      <link>https://dev.to/itsopensource/how-to-checkout-github-pull-requests-locally-like-pro-1f22</link>
      <guid>https://dev.to/itsopensource/how-to-checkout-github-pull-requests-locally-like-pro-1f22</guid>
      <description>&lt;p&gt;If you work with the repositories hosted on Github , you have to deal with lot of Pull requests daily generally, and the process to checkout the PR's locally in your machine is quite not easy, you have to see the PR's id and also the branch name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git fetch origin pull/ID/head:BRANCHNAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if the PR is in upstream repository, first you need to add that particular user as remote in your local copy of the project and then pull the particular branch of the contributor. For example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git remote add fayem git@github.com:fayepal/itsopensource.git
git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; fayem fayepal/blog-docker-vm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we see its quite long process and you will have lot of remote added in your repository as well.&lt;/p&gt;

&lt;p&gt;To solve this there is a awesome &lt;a href="https://gist.github.com/gnarf/5406589" rel="noopener noreferrer"&gt;git alias&lt;/a&gt; by gnarf:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;alias&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
  &lt;span class="nb"&gt;pr&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"!f() { git fetch -fu &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;2&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git remote |grep ^upstream &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;echo &lt;/span&gt;origin&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; refs/pull/&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;/head:pr/&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt; &amp;amp;&amp;amp; git checkout pr/&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;; }; f"&lt;/span&gt;
  pr-clean &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"!git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; do branch=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;#refs/heads/&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; ; git branch -D &lt;/span&gt;&lt;span class="nv"&gt;$branch&lt;/span&gt;&lt;span class="s2"&gt; ; done"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Either you can add them directly in your &lt;code&gt;.gitconfig&lt;/code&gt; file or by doing so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; alias.pr &lt;span class="s1"&gt;'!f() { git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull/$1/head:pr/$1 &amp;amp;&amp;amp; git checkout pr/$1; }; f'&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; alias.pr-clean &lt;span class="s1"&gt;'!git for-each-ref refs/heads/pr/* --format="%(refname)" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you simply do &lt;code&gt;git pr x&lt;/code&gt; and it will do the magic for you:&lt;/p&gt;

&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8epzbjljjo7t49wiaf3h.jpg" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8epzbjljjo7t49wiaf3h.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cheers&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to move forward and backward between commits in git</title>
      <dc:creator>Shivam Singhal</dc:creator>
      <pubDate>Thu, 03 Sep 2020 16:31:52 +0000</pubDate>
      <link>https://dev.to/itsopensource/how-to-move-forward-and-backward-between-commits-in-git-16i3</link>
      <guid>https://dev.to/itsopensource/how-to-move-forward-and-backward-between-commits-in-git-16i3</guid>
      <description>&lt;p&gt;We always keep moving forward and backward between commits in &lt;code&gt;git&lt;/code&gt;. Once you checked out a previous hash &lt;code&gt;git log&lt;/code&gt; no more shows the next commits, we end up rebasing or resetting, but git provides a way to see all the commits, and we can checkout the next commits too from a previous state.&lt;/p&gt;

&lt;p&gt;The simple and easiest way to do this is:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

git log &lt;span class="nt"&gt;--online&lt;/span&gt; &lt;span class="nt"&gt;--all&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Consider this example:&lt;/p&gt;

&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffw8f8g61scfz14m3mj85.jpg" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffw8f8g61scfz14m3mj85.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here if we check out to commit id &lt;code&gt;95613ab Fix more TOC links&lt;/code&gt; and then see the git history with &lt;code&gt;git log&lt;/code&gt; or &lt;code&gt;git log --oneline&lt;/code&gt; you will only see:&lt;/p&gt;

&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbiwtwx5i8q3sx9edmsr5.jpg" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbiwtwx5i8q3sx9edmsr5.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we see here we missed the commits ahead of &lt;code&gt;95613ab&lt;/code&gt;. You can see the HEAD with &lt;code&gt;git show-ref --head&lt;/code&gt; but it will not show the commits in between the &lt;code&gt;HEAD&lt;/code&gt; and the commit you checked out. So if you do &lt;code&gt;git log --oneline --all&lt;/code&gt; you will get the whole history with the commit where the &lt;code&gt;HEAD&lt;/code&gt; is right now.&lt;/p&gt;

&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbprablapi53w3g8ehdjz.jpg" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbprablapi53w3g8ehdjz.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us know if you know the better solution for this problem.&lt;/p&gt;

&lt;p&gt;Cheers.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>beginners</category>
      <category>howto</category>
    </item>
    <item>
      <title>How to Reduce Node Docker Image Size by 10X</title>
      <dc:creator>Shivam Singhal</dc:creator>
      <pubDate>Sat, 04 Jul 2020 09:35:29 +0000</pubDate>
      <link>https://dev.to/itsopensource/how-to-reduce-node-docker-image-size-by-10x-1h81</link>
      <guid>https://dev.to/itsopensource/how-to-reduce-node-docker-image-size-by-10x-1h81</guid>
      <description>&lt;p&gt;Dockerizing an application is simple, effective, but optimizing the size of Docker Image is the tricky part. Docker is easy to use but once the application starts scaling, the image size inflates exponentially. In general, the node docker image size of the applications is over 1 GB most of the time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why the Size matters
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Large docker image sizes - Bigger image size requires more space means increased expense.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Long build durations - It takes a longer time to push the images over the network and results in CI Pipeline delays.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Let’s Start The Optimization
&lt;/h3&gt;

&lt;p&gt;Here is our &lt;a href="https://github.com/championshuttler/fluentbit-dashboard"&gt;demo application&lt;/a&gt; built using the VueJS Application. &lt;/p&gt;

&lt;p&gt;Here is the initial Dockerfile.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;FROM node:10

WORKDIR /app

COPY &lt;span class="nb"&gt;.&lt;/span&gt; /app

EXPOSE 8080

RUN npm &lt;span class="nb"&gt;install &lt;/span&gt;http-server &lt;span class="nt"&gt;-g&lt;/span&gt;

RUN npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm run build

CMD http-server ./dist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The size of this image is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_aM9nfwM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ta1hdfyjshvo3o2stzz6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_aM9nfwM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ta1hdfyjshvo3o2stzz6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is 1.34GB! Whoops!&lt;/p&gt;

&lt;p&gt;Let's start optimizing step by step&lt;/p&gt;

&lt;p&gt;1) Use &lt;strong&gt;Multi-Stage&lt;/strong&gt; Docker Builds&lt;/p&gt;

&lt;p&gt;Multi-stage builds make it easy to optimize Docker images by using multiple &lt;strong&gt;intermediate&lt;/strong&gt; images in a single Dockerfile. Read more about it &lt;a href="https://docs.docker.com/develop/develop-images/multistage-build/"&gt;here&lt;/a&gt;. By using multi-stage builds, we can install all dependencies in the build image and copy them to the leaner runtime image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;FROM node:10 AS BUILD_IMAGE

WORKDIR /app

COPY &lt;span class="nb"&gt;.&lt;/span&gt; /app

EXPOSE 8080

RUN npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm run build

FROM node:10

WORKDIR /app

&lt;span class="c"&gt;# copy from build image&lt;/span&gt;
COPY &lt;span class="nt"&gt;--from&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;BUILD_IMAGE /app/dist ./dist
COPY &lt;span class="nt"&gt;--from&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;BUILD_IMAGE /app/node_modules ./node_modules

RUN npm i &lt;span class="nt"&gt;-g&lt;/span&gt; http-server

CMD http-server ./dist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the size of this image is 1.24GB:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gviww1fS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/n6uityca4i5u1ib2yjd4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gviww1fS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/n6uityca4i5u1ib2yjd4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2) Remove Development Dependencies and use &lt;strong&gt;Node Prune&lt;/strong&gt; Tool&lt;/p&gt;

&lt;p&gt;node-prune is an open-source tool for removing unnecessary files from the node_modules folder. Test files, markdown files, typing files and *.map files in Npm packages are not required at all in the production environment generally, most of the developers do not remove them from the production package. By using node-prune it can safely be removed.&lt;/p&gt;

&lt;p&gt;We can use this to remove Development Dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm prune &lt;span class="nt"&gt;--production&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After making these changes &lt;code&gt;Dockerfile&lt;/code&gt; will look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;FROM node:10 AS BUILD_IMAGE

RUN curl &lt;span class="nt"&gt;-sfL&lt;/span&gt; https://install.goreleaser.com/github.com/tj/node-prune.sh | bash &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;-b&lt;/span&gt; /usr/local/bin

WORKDIR /app

COPY &lt;span class="nb"&gt;.&lt;/span&gt; /app

EXPOSE 8080

RUN npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm run build

&lt;span class="c"&gt;# remove development dependencies&lt;/span&gt;
RUN npm prune &lt;span class="nt"&gt;--production&lt;/span&gt;

&lt;span class="c"&gt;# run node prune&lt;/span&gt;
RUN /usr/local/bin/node-prune

FROM node:10

WORKDIR /app

&lt;span class="c"&gt;# copy from build image&lt;/span&gt;
COPY &lt;span class="nt"&gt;--from&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;BUILD_IMAGE /app/dist ./dist
COPY &lt;span class="nt"&gt;--from&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;BUILD_IMAGE /app/node_modules ./node_modules

RUN npm i &lt;span class="nt"&gt;-g&lt;/span&gt; http-server

CMD http-server ./dist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using this we reduced the overall size to 1.09GB&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jMocakz0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r87f0ip9ctrdgvt08yb1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jMocakz0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r87f0ip9ctrdgvt08yb1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3) Choose &lt;strong&gt;Smaller Final Base Image&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When dockerizing a node application, there are lots of &lt;a href="https://hub.docker.com/_/node/"&gt;base images&lt;/a&gt; available to choose from.&lt;/p&gt;

&lt;p&gt;Here we will use &lt;strong&gt;alpine&lt;/strong&gt; image; alpine is a lean docker image with minimum packages but enough to run node applications.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;FROM node:10 AS BUILD_IMAGE

RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin

WORKDIR /app

COPY . /app

EXPOSE 8080

RUN npm install &amp;amp;&amp;amp; npm run build

&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;remove development dependencies
&lt;span class="go"&gt;RUN npm prune --production

&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;run node prune
&lt;span class="go"&gt;RUN /usr/local/bin/node-prune

FROM node:10-alpine

WORKDIR /app

&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;copy from build image
&lt;span class="go"&gt;COPY --from=BUILD_IMAGE /app/dist ./dist
COPY --from=BUILD_IMAGE /app/node_modules ./node_modules

RUN npm i -g http-server

CMD http-server ./dist
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using this &lt;code&gt;Dockerfile&lt;/code&gt; the image size dropped to &lt;code&gt;157MB&lt;/code&gt; \o/&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_8lcgFKg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o9rypq0k50co2w2betrl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_8lcgFKg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o9rypq0k50co2w2betrl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;By applying these 3 simple steps, we reduced our docker image size by 10 times.&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>beginners</category>
      <category>howto</category>
      <category>devops</category>
    </item>
    <item>
      <title>How to get rid of branch name from git push origin master
</title>
      <dc:creator>Shivam Singhal</dc:creator>
      <pubDate>Thu, 25 Jun 2020 10:13:08 +0000</pubDate>
      <link>https://dev.to/itsopensource/how-to-get-rid-of-branch-name-from-git-push-origin-master-2egg</link>
      <guid>https://dev.to/itsopensource/how-to-get-rid-of-branch-name-from-git-push-origin-master-2egg</guid>
      <description>&lt;p&gt;We always type &lt;code&gt;git push origin master&lt;/code&gt;, while working on feature branch we type &lt;code&gt;git push origin JIRA-1&lt;/code&gt;, sometimes the names of the feature branch is not easy then we use &lt;code&gt;git push origin this-branch-will-do-something&lt;/code&gt; to push the code over GitHub or any other hosting service. In each case, we are doing redundant work of copy-pasting or typing branch name which is redundant and annoying as you have to remember the branch name exactly or you might end up pushing the code to the wrong branch. This can be handled by just with one command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config push.default current
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So this command push changes to &lt;code&gt;.gitconfig&lt;/code&gt; file and after change git config file looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;user]
  name &lt;span class="o"&gt;=&lt;/span&gt; author
  email &lt;span class="o"&gt;=&lt;/span&gt; author@itsopensource.com

&lt;span class="o"&gt;[&lt;/span&gt;push]
  default &lt;span class="o"&gt;=&lt;/span&gt; current
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can directly append in git config too.&lt;/p&gt;

&lt;p&gt;After this, all you need to do is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; - If you do this inside a git repo, this will only be available for that repo, if you want to do it globally and add &lt;code&gt;--global&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; push.default current
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will make these changes to be set globally across all the git repos you are using.&lt;/p&gt;

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

</description>
      <category>git</category>
      <category>github</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understand Docker step by step. A tutorial repo for beginners
</title>
      <dc:creator>Shivam Singhal</dc:creator>
      <pubDate>Mon, 22 Jun 2020 21:52:40 +0000</pubDate>
      <link>https://dev.to/championshuttler/understand-docker-step-by-step-a-tutorial-repo-for-beginners-205m</link>
      <guid>https://dev.to/championshuttler/understand-docker-step-by-step-a-tutorial-repo-for-beginners-205m</guid>
      <description>&lt;p&gt;Hello Everyone, I wrote a simple beginner tutorial for Docker, you can read here &lt;a href="https://github.com/championshuttler/docker-basicLearning"&gt;https://github.com/championshuttler/docker-basicLearning&lt;/a&gt; or &lt;a href="https://championshuttler.github.io/docker-basicLearning"&gt;https://championshuttler.github.io/docker-basicLearning&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you like it please do not forget to give the repo a ⭐.&lt;/p&gt;

&lt;p&gt;Happy Open Source&lt;/p&gt;

</description>
      <category>docker</category>
      <category>beginners</category>
      <category>devops</category>
      <category>tuto</category>
    </item>
    <item>
      <title>How to get rid of branch name from git push origin master
</title>
      <dc:creator>Shivam Singhal</dc:creator>
      <pubDate>Tue, 02 Jun 2020 13:48:55 +0000</pubDate>
      <link>https://dev.to/championshuttler/how-to-get-rid-of-branch-name-from-git-push-origin-master-4ia4</link>
      <guid>https://dev.to/championshuttler/how-to-get-rid-of-branch-name-from-git-push-origin-master-4ia4</guid>
      <description>&lt;p&gt;We always type &lt;code&gt;git push origin master&lt;/code&gt;, while working on feature branch we type &lt;code&gt;git push origin JIRA-1&lt;/code&gt;, sometimes the names of the feature branch is not easy then we use &lt;code&gt;git push origin this-branch-will-do-something&lt;/code&gt; to push the code over GitHub or any other hosting service. In each case, we are doing redundant work of copy-pasting or typing branch name which is redundant and annoying as you have to remember the branch name exactly or you might end up pushing the code to the wrong branch. This can be handled by just with one command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config push.default current
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So this command push changes to &lt;code&gt;.gitconfig&lt;/code&gt; file and after change git config file looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;user]
  name &lt;span class="o"&gt;=&lt;/span&gt; author
  email &lt;span class="o"&gt;=&lt;/span&gt; author@itsopensource.com

&lt;span class="o"&gt;[&lt;/span&gt;push]
  default &lt;span class="o"&gt;=&lt;/span&gt; current
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can directly append in git config too.&lt;/p&gt;

&lt;p&gt;After this, all you need to do is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; - If you do this inside a git repo, this will only be available for that repo, if you want to do it globally and add &lt;code&gt;--global&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; push.default current
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will make these changes to be set globally across all the git repos you are using.&lt;/p&gt;

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

&lt;p&gt;Originally published at &lt;a href="https://itsopensource.com"&gt;https://itsopensource.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>howto</category>
    </item>
    <item>
      <title>How to always keep files open in Visual Studio Code</title>
      <dc:creator>Shivam Singhal</dc:creator>
      <pubDate>Wed, 20 May 2020 20:56:19 +0000</pubDate>
      <link>https://dev.to/championshuttler/how-to-always-keep-files-open-in-visual-studio-code-4me2</link>
      <guid>https://dev.to/championshuttler/how-to-always-keep-files-open-in-visual-studio-code-4me2</guid>
      <description>&lt;p&gt;Visual Code is an amazing editor and I use it for my everyday code. One thing bugs me every time is the files are not open permanently until I use the shortcut &lt;code&gt;cmd + k&lt;/code&gt; &lt;code&gt;enter&lt;/code&gt; or right-click and select &lt;code&gt;keep open&lt;/code&gt; on the filename. This happens because the VS Code opens the files by default in &lt;code&gt;preview mode&lt;/code&gt;, so whenever the new file name is clicked from explorer, the opened file closes and the new file is visible. But if you are equally frustrated by this behavior here is what you need to do.&lt;/p&gt;

&lt;p&gt;The solution is way simpler than expected, just add the following line to your  &lt;code&gt;setting.json&lt;/code&gt;&lt;br&gt;
(Code Menu &amp;gt; Preferences &amp;gt; Setting)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"workbench.editor.enablePreview": false
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Follow me on &lt;a href="//github.com/championshuttler"&gt;GitHub&lt;/a&gt; and &lt;a href="//twitter.com/idkhtml"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cheers!
&lt;/h2&gt;

</description>
      <category>vscode</category>
      <category>tricks</category>
      <category>howto</category>
    </item>
    <item>
      <title>How to remove all images and containers in Docker</title>
      <dc:creator>Shivam Singhal</dc:creator>
      <pubDate>Wed, 20 May 2020 20:51:25 +0000</pubDate>
      <link>https://dev.to/championshuttler/how-to-remove-all-images-and-containers-in-docker-pmj</link>
      <guid>https://dev.to/championshuttler/how-to-remove-all-images-and-containers-in-docker-pmj</guid>
      <description>&lt;p&gt;Recently I started using Docker in my internship and sometimes you just mess up your docker images and containers, so you wanted to start from clean but first you need to remove all images and containers of Docker locally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Delete all Docker containers&lt;/span&gt;
docker &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;docker ps &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Delete all Docker images&lt;/span&gt;
docker rmi &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;docker images &lt;span class="nt"&gt;-q&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Also there is a new docker command, that will delete all unused images and volumes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;docker system prune &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can read more about this command &lt;a href="https://docs.docker.com/engine/reference/commandline/system_prune/"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="//github.com/championshuttler"&gt;GitHub&lt;/a&gt; and &lt;a href="//twitter.com/idkhtml"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;




</description>
      <category>docker</category>
      <category>tricks</category>
      <category>howto</category>
    </item>
  </channel>
</rss>
