<?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: Ken Flake</title>
    <description>The latest articles on DEV Community by Ken Flake (@kensixx).</description>
    <link>https://dev.to/kensixx</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%2F124218%2F59972054-116c-44d1-be6f-fd9c966c8fd3.jpg</url>
      <title>DEV Community: Ken Flake</title>
      <link>https://dev.to/kensixx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kensixx"/>
    <language>en</language>
    <item>
      <title>Guide on how to apply Nuxt Color Mode with Bulma</title>
      <dc:creator>Ken Flake</dc:creator>
      <pubDate>Thu, 15 Oct 2020 02:26:15 +0000</pubDate>
      <link>https://dev.to/kensixx/guide-on-how-to-apply-nuxt-color-mode-with-bulma-1ekc</link>
      <guid>https://dev.to/kensixx/guide-on-how-to-apply-nuxt-color-mode-with-bulma-1ekc</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://color-mode.nuxtjs.org/" rel="noopener noreferrer"&gt;@nuxtjs/color-mode&lt;/a&gt; is a Nuxt.js module that will help us implement a Dark Mode toggle on our Nuxt.js apps much easier.&lt;/p&gt;

&lt;p&gt;These are one of the ways on how you can leverage &lt;a href="https://color-mode.nuxtjs.org/" rel="noopener noreferrer"&gt;@nuxtjs/color-mode&lt;/a&gt; if you're using Bulma.&lt;/p&gt;

&lt;p&gt;When using a CSS Framework such as Bulma, we need to override Bulma's &lt;code&gt;.scss&lt;/code&gt; variables as stated in this guide. &lt;/p&gt;

&lt;p&gt;You can see the source code here!&lt;br&gt;
&lt;a href="https://github.com/kensixx/nuxt-color-mode-with-bulma" rel="noopener noreferrer"&gt;https://github.com/kensixx/nuxt-color-mode-with-bulma&lt;/a&gt;&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%2Fgithub.com%2Fkensixx%2Fnuxt-color-mode-with-bulma%2Fraw%2Fmain%2Fassets%2Freadme-assets%2Fnuxt-color-mode-with-bulma-screen-capture.gif" 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%2Fgithub.com%2Fkensixx%2Fnuxt-color-mode-with-bulma%2Fraw%2Fmain%2Fassets%2Freadme-assets%2Fnuxt-color-mode-with-bulma-screen-capture.gif" alt="Video"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Setup
&lt;/h1&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Installing dependencies
&lt;/h2&gt;

&lt;p&gt;Install &lt;code&gt;node-sass&lt;/code&gt; and &lt;code&gt;sass-loader&lt;/code&gt; if you haven't yet, so we can use our &lt;code&gt;.scss&lt;/code&gt; files properly.&lt;br&gt;(in &lt;code&gt;devDependencies&lt;/code&gt; only because we won't need in during runtime, only during compilation)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-D&lt;/span&gt; node-sass sass-loader
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;Install &lt;a href="https://github.com/nuxt-community/color-mode-module" rel="noopener noreferrer"&gt;&lt;code&gt;@nuxtjs/color-mode&lt;/code&gt;&lt;/a&gt; that will take care of the toggling for us:&lt;br&gt;(in &lt;code&gt;devDependencies&lt;/code&gt; as well for the same reason)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-D&lt;/span&gt; @nuxtjs/color-mode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;&lt;strong&gt;Install:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;@nuxtjs/style-resources&lt;/code&gt; - so we can use our &lt;code&gt;.scss&lt;/code&gt; files globally in Nuxt. Share variables, mixins, functions across all style files (no &lt;code&gt;@import&lt;/code&gt; needed)&lt;/li&gt;
&lt;li&gt;Bulma - so we can import, use and override Bulma &lt;code&gt;scss&lt;/code&gt; variables in our customized &lt;code&gt;.scss&lt;/code&gt; files&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nuxt-svg-loader&lt;/code&gt; - So we can load SVG icons and use as Vue components, for the toggle switch of Dark mode using SVG icon later
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i @nuxtjs/style-resources bulma nuxt-svg-loader
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  nuxt.config.js
&lt;/h2&gt;

&lt;p&gt;Remove &lt;code&gt;@nuxtjs/bulma&lt;/code&gt; if you haven't yet. Moving forward we will use Bulma .scss that we &lt;code&gt;npm install&lt;/code&gt;-ed earlier.&lt;br&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fkensixx%2Fnuxt-color-mode-with-bulma%2Fraw%2Fmain%2Fassets%2Freadme-assets%2Fremove-bulma.png" 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%2Fgithub.com%2Fkensixx%2Fnuxt-color-mode-with-bulma%2Fraw%2Fmain%2Fassets%2Freadme-assets%2Fremove-bulma.png" alt="image.png"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Include these on your &lt;code&gt;modules[]&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;modules: &lt;span class="o"&gt;[&lt;/span&gt;
    // Doc: https://github.com/nuxt-community/style-resources-module/
    // Used with styleResources&lt;span class="o"&gt;{}&lt;/span&gt;
    &lt;span class="s1"&gt;'@nuxtjs/style-resources'&lt;/span&gt;,
    // Doc: https://github.com/Developmint/nuxt-svg-loader
    // So we can load SVG icons as Vue components
    &lt;span class="s1"&gt;'nuxt-svg-loader'&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Include &lt;code&gt;@nuxtjs/color-mode&lt;/code&gt; on your &lt;code&gt;buildModules[]&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;buildModules: &lt;span class="o"&gt;[&lt;/span&gt;
    // Doc: https://color-mode.nuxtjs.org/
    &lt;span class="s1"&gt;'@nuxtjs/color-mode'&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;Add this on your &lt;code&gt;css[]&lt;/code&gt;, and also add the new &lt;code&gt;styleResources{}&lt;/code&gt; like so:&lt;br&gt;We'll setup our &lt;code&gt;assets/scss/main.scss&lt;/code&gt; file later on below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="cm"&gt;/*
   ** Global CSS
   */&lt;/span&gt;
  &lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~assets/scss/main.scss&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="cm"&gt;/*
   ** So we can use our .scss file globally in the Nuxt app
   */&lt;/span&gt;
  &lt;span class="nx"&gt;styleResources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;scss&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~assets/scss/main.scss&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Adding light and dark icons for the toggle switch
&lt;/h1&gt;

&lt;p&gt;Create an &lt;code&gt;icons&lt;/code&gt; directory inside &lt;code&gt;assets&lt;/code&gt; like so, and add the &lt;code&gt;.svg&lt;/code&gt; icons.&lt;br&gt;You can download the icons here: &lt;a href="https://github.com/nuxt-community/color-mode-module/tree/master/example/assets/icons" rel="noopener noreferrer"&gt;https://github.com/nuxt-community/color-mode-module/tree/master/example/assets/icons&lt;/a&gt;&lt;br&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fkensixx%2Fnuxt-color-mode-with-bulma%2Fraw%2Fmain%2Fassets%2Freadme-assets%2Fsvg-icons.png" 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%2Fgithub.com%2Fkensixx%2Fnuxt-color-mode-with-bulma%2Fraw%2Fmain%2Fassets%2Freadme-assets%2Fsvg-icons.png" alt="svg-icons.png"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Configuring our &lt;code&gt;main.scss&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;This should be the bread and butter of this guide, the &lt;code&gt;scss&lt;/code&gt; files. This shall be the content of our &lt;code&gt;assets/scss/main.scss&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Theme style (colors &amp;amp; sizes) */&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"~bulma/sass/utilities/initial-variables"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"theme-default"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c"&gt;/* Core Libs &amp;amp; Lib configs */&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"~bulma"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c"&gt;/* Mixins */&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"mixins"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c"&gt;/* Theme components */&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"nav-bar"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"title-bar"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"hero-bar"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"card"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"table"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"tiles"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"form"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"main-section"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"modal"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"progress"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"footer"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"misc"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c"&gt;/* For our dark mode scss implementation */&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"dark-mode"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So what we've done here is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Import &lt;code&gt;bulma/sass/utilities/initial-variables&lt;/code&gt; first,&lt;/li&gt;
&lt;li&gt;then override some Bulma variables in our custom &lt;code&gt;theme-default.scss&lt;/code&gt; settings that will help us configure our dark mode colors and light mode base colors / CSS components&lt;/li&gt;
&lt;li&gt;Import the rest of Bulma using &lt;code&gt;~bulma&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Override some components like the Navbar, and so on&lt;/li&gt;
&lt;li&gt;Lastly, our dark mode implementation of the Bulma components when it is toggled on&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;br&gt;Next is to put the other supporting .scss files. You can get it here: &lt;a href="https://github.com/kensixx/nuxt-color-mode-with-bulma/tree/main/assets/scss" rel="noopener noreferrer"&gt;https://github.com/kensixx/nuxt-color-mode-with-bulma/tree/main/assets/scss&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;strong&gt;I borrowed these .scss files on &lt;strong&gt;[&lt;/strong&gt;admin-null-nuxt**](&lt;a href="https://github.com/justboil/admin-null-nuxt" rel="noopener noreferrer"&gt;https://github.com/justboil/admin-null-nuxt&lt;/a&gt;)&lt;/strong&gt; Nuxt.js template (the free version one).**&lt;br&gt;&lt;br&gt;
&lt;br&gt;So we're done with the &lt;code&gt;.scss&lt;/code&gt; files! What we need next is the actual toggling action of dark and light mode.&lt;br&gt;&lt;/p&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Creating a Vue component that will serve as our light/dark toggle switch
&lt;/h1&gt;

&lt;p&gt;create &lt;code&gt;components/ColorModePicker.vue&lt;/code&gt;, and follow the code implementation below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"button is-info is-block"&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;click=&lt;/span&gt;&lt;span class="s"&gt;"toggleDarkMode()"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ColorScheme&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"..."&lt;/span&gt; &lt;span class="na"&gt;tag=&lt;/span&gt;&lt;span class="s"&gt;"span"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;v-if=&lt;/span&gt;&lt;span class="s"&gt;"$colorMode.value === 'dark'"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;IconDark&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;v-else&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;IconLight&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/ColorScheme&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;IconLight&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~/assets/icons/light.svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;IconDark&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~/assets/icons/dark.svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;IconLight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;IconDark&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="na"&gt;methods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;toggleDarkMode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$colorMode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preference&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$colorMode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preference&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$colorMode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preference&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This is a simple Button component that will help toggle &lt;code&gt;@nuxtjs/color-mode&lt;/code&gt; whether we want to use light or dark mode. You can change this one as you wish. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.$colorMode.preference&lt;/code&gt; is the one that will inject a &lt;code&gt;dark-mode&lt;/code&gt; class in the whole &lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;/html&amp;gt;&lt;/code&gt; of the Nuxt project if it's set to &lt;code&gt;dark&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
&lt;br&gt;It will then trigger the &lt;code&gt;dark-mode.scss&lt;/code&gt; to change the Bulma components accordingly depending on what we set in the &lt;code&gt;dark-mode.scss&lt;/code&gt; file.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Using the &lt;code&gt;ColorModePicker.vue&lt;/code&gt; component
&lt;/h1&gt;

&lt;p&gt;I think that's it! You can now include the &lt;code&gt;ColorModePicker.vue&lt;/code&gt; component anywhere in your code, for me I've put it in the Navbar beside the Brand Logo like so:&lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;nav&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar-brand"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;nuxt-link&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar-item is-hoverable"&lt;/span&gt; &lt;span class="na"&gt;to=&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          Nuxt Color Mode With Bulma
        &lt;span class="nt"&gt;&amp;lt;/nuxt-link&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"button navbar-burger"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"navbarBasicExample"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar-menu"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar-start"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;ColorModePicker&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/nav&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;&lt;strong&gt;Note: remember to import this component like so:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ColorModePicker&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~/components/ColorModePicker&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;ColorModePicker&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>vue</category>
    </item>
    <item>
      <title>Docker for Complete Beginners!</title>
      <dc:creator>Ken Flake</dc:creator>
      <pubDate>Fri, 24 Apr 2020 09:55:49 +0000</pubDate>
      <link>https://dev.to/kensixx/docker-for-complete-beginners-d5o</link>
      <guid>https://dev.to/kensixx/docker-for-complete-beginners-d5o</guid>
      <description>&lt;p&gt;This is my take on learning Docker if you are a complete beginner.&lt;/p&gt;

&lt;h3&gt;
  
  
  Traditional Approach, and the Problem
&lt;/h3&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%2Fimgur.com%2F27JdtuV" 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%2Fimgur.com%2F27JdtuV" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;So you have your separate EC2 Instances, 1 for UAT env, and 1 for Prod.

&lt;ul&gt;
&lt;li&gt;I like to think of the &lt;strong&gt;EC2 Instance&lt;/strong&gt; as &lt;strong&gt;like a laptop you bought remotely from Amazon&lt;/strong&gt;, and you can't physically touch it.&lt;/li&gt;
&lt;li&gt;You can only remotely control it using &lt;code&gt;ssh&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Everything works fine for your &lt;strong&gt;Hotel Reservation system&lt;/strong&gt;.&lt;/li&gt;

&lt;li&gt;There was a new functionality introduced at your Hotel Reservation system, say,

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Java 8 in UAT was upgraded to Java 10&lt;/strong&gt;, for some reason.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;in Production, it's still Java 8.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;So you used Java 10 new features, say, a new Streams API, in your local and UAT.&lt;/li&gt;

&lt;li&gt;So, everything works in UAT, QA is also happy with it.&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;But guess what. When it was deployed in Prod, it broke.&lt;/strong&gt;&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;And you probably can't pinpoint it directly.&lt;/strong&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;That's why, the idea of containerization was introduced!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Containerization Approach
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Docker
&lt;/h3&gt;

&lt;p&gt;In 2013, Docker introduced what would become the industry standard for containers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Containers
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Containers&lt;/strong&gt; are a standardized unit of software that allows developers to isolate their app from its environment, &lt;strong&gt;solving the “it works on my machine” headache.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The idea is that, having a &lt;strong&gt;container&lt;/strong&gt; is like having a "&lt;strong&gt;super&lt;/strong&gt; &lt;strong&gt;mini-laptop&lt;/strong&gt;" that has NO OS (it shares with its Host's OS), just a bare minimum drivers / kernels that is essential for running, say, a MySQL server, or a Java server with Maven.&lt;br&gt;
&lt;em&gt;The "super mini-laptop" term is an oversimplification&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So, &lt;strong&gt;YES&lt;/strong&gt;, it is possible to put your Java server, Maven, and DB in one whole container.&lt;br&gt;
&lt;strong&gt;But,&lt;/strong&gt; it's very dangerous. &lt;strong&gt;If your container goes down, you will lose all of your data.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is still important to isolate your DB to a separate container,&lt;br&gt;
Or much better, resort to something like third-party platforms that can guarantee the persistence of your data. &lt;br&gt;
&lt;strong&gt;e.g. for MongoDB, -&amp;gt; &lt;/strong&gt;MongoDB Atlas, mLab, etc.&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%2Fcdn.nlark.com%2Fyuque%2F0%2F2020%2Fpng%2F517147%2F1587695466507-9342a91d-5401-4eec-8e10-fb9dd5d32d24.png%23align%3Dleft%26display%3Dinline%26height%3D543%26margin%3D%255Bobject%2520Object%255D%26name%3Dimage.png%26originHeight%3D1085%26originWidth%3D1650%26size%3D102290%26status%3Ddone%26style%3Dnone%26width%3D825" 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%2Fcdn.nlark.com%2Fyuque%2F0%2F2020%2Fpng%2F517147%2F1587695466507-9342a91d-5401-4eec-8e10-fb9dd5d32d24.png%23align%3Dleft%26display%3Dinline%26height%3D543%26margin%3D%255Bobject%2520Object%255D%26name%3Dimage.png%26originHeight%3D1085%26originWidth%3D1650%26size%3D102290%26status%3Ddone%26style%3Dnone%26width%3D825" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Images
&lt;/h3&gt;

&lt;p&gt;With that said, you need an &lt;strong&gt;image &lt;/strong&gt;which is &lt;strong&gt;stored inside containers&lt;/strong&gt; where it will run.&lt;br&gt;
And you need a &lt;strong&gt;Dockerfile &lt;/strong&gt;in order to build an image. It sits alongside your source code.&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;Dockerfile &lt;/strong&gt;will be the same regardless when you're in &lt;code&gt;develop&lt;/code&gt; branch or in &lt;code&gt;master&lt;/code&gt; branch of your project's Git repo.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.nlark.com%2Fyuque%2F0%2F2020%2Fpng%2F517147%2F1587695518013-50264525-1b10-40bb-81cc-f4b9f0424038.png%23align%3Dleft%26display%3Dinline%26height%3D480%26margin%3D%255Bobject%2520Object%255D%26name%3Dimage.png%26originHeight%3D960%26originWidth%3D1280%26size%3D850355%26status%3Ddone%26style%3Dnone%26width%3D640" 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%2Fcdn.nlark.com%2Fyuque%2F0%2F2020%2Fpng%2F517147%2F1587695518013-50264525-1b10-40bb-81cc-f4b9f0424038.png%23align%3Dleft%26display%3Dinline%26height%3D480%26margin%3D%255Bobject%2520Object%255D%26name%3Dimage.png%26originHeight%3D960%26originWidth%3D1280%26size%3D850355%26status%3Ddone%26style%3Dnone%26width%3D640" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Dockerfile
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Consider this Dockerfile example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; maven:3.6.3-ibmjava-8-alpine&lt;/span&gt;

&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; TZ=Asia/Manila&lt;/span&gt;

&lt;span class="c"&gt;# Apache POI uses JRE 8 Font on writing Excel cells, so this package must be installed in the Docker container&lt;/span&gt;
&lt;span class="c"&gt;# to be able to use it.&lt;/span&gt;
&lt;span class="c"&gt;# source: https://stackoverflow.com/a/56664613/7209628&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;apk &lt;span class="nt"&gt;--update&lt;/span&gt; add fontconfig ttf-dejavu

&lt;span class="c"&gt;# Copy whole source code to the docker image&lt;/span&gt;
&lt;span class="c"&gt;# Note of .dockerignore, this ensures that folders such as `target` is not copied&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . /usr/src/xrecon/&lt;/span&gt;

&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /usr/src/xrecon/ &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; mvn clean package &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /usr/src/xrecon-app &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cp&lt;/span&gt; /usr/src/xrecon/target/&lt;span class="k"&gt;*&lt;/span&gt;.jar /usr/src/xrecon-app/xrecon-app.jar

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /usr/src/xrecon-app&lt;/span&gt;

&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 8080&lt;/span&gt;

&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["java", "-Djava.security.egd=file:/dev/./urandom", "-Xms500M", "-Xmx900M", "-jar", "xrecon-app.jar"]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Let's digest these commands one step at a time..&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;code&gt;FROM&lt;/code&gt;&lt;/strong&gt; command means &lt;strong&gt;I want to use &lt;code&gt;maven:3.6.3-ibmjava-8-alpine&lt;/code&gt; as my base image.&lt;/strong&gt;&lt;br&gt;
**&lt;br&gt;
Meaning, I won't have any difficulty creating a blank image from scratch and installing Maven with JDK 8 in there.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;maven:3.6.3-ibmjava-8-alpine&lt;/code&gt; image took care of it.&lt;/p&gt;

&lt;p&gt;This base image will be &lt;strong&gt;STANDARD&lt;/strong&gt; and &lt;strong&gt;FIXED&lt;/strong&gt; &lt;strong&gt;regardless on what environment&lt;/strong&gt; I'm at. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;-alpine&lt;/code&gt; at the image name indicates that I want to use this base image that also has &lt;strong&gt;Alpine Linux&lt;/strong&gt; inside it.&lt;/p&gt;

&lt;p&gt;This way, I have  a very very small distro like Ubuntu, helpful for installing packages like &lt;code&gt;curl&lt;/code&gt;, &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;ssh&lt;/code&gt;, or any Linux packages that you need.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;code&gt;RUN&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;means I want to execute shell commands inside the image; equivalent to using your Terminal.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this Dockerfile case above ☝️☝️, I want to execute a shell command that installs a package that will be helpful for the Apache POI Java library. Without this, my Apache POI Excel generation will crash.&lt;/p&gt;

&lt;p&gt;I'm using &lt;code&gt;apk add&lt;/code&gt; as this is how you would install a package in Alpine Linux,&lt;br&gt;
as you would do &lt;code&gt;apt-get&lt;/code&gt; in Ubuntu, or &lt;code&gt;brew install&lt;/code&gt; in Mac's Homebrew.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;code&gt;COPY&lt;/code&gt;&lt;/strong&gt; is like magic, &lt;strong&gt;because you can literally copy your source code files inside your Git repo, to the Docker image.&lt;/strong&gt;&lt;br&gt;
**&lt;br&gt;
So, I went and copied my whole source code inside the Docker image like so.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;NEXT: Running Maven inside the image&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;As I was using the official Maven image available from Dockerhub, &lt;/strong&gt;I didn't have any difficulty running &lt;code&gt;mvn clean package&lt;/code&gt; inside the image. &lt;/p&gt;

&lt;p&gt;And we want to preserve &lt;em&gt;"layers"&lt;/em&gt; as using FROM, COPY and RUN etc commands consumes &lt;em&gt;"layers"&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;In this case, we are able to &lt;code&gt;mvn clean package&lt;/code&gt;, &lt;code&gt;mkdir&lt;/code&gt;, and &lt;code&gt;cp&lt;/code&gt; in one single Docker &lt;strong&gt;&lt;code&gt;RUN&lt;/code&gt;&lt;/strong&gt; command.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;code&gt;WORKDIR&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;is where the default directory will go if you enter this Docker container using &lt;code&gt;docker exec&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this case, if you enter inside this Docker container, it will land you to the &lt;code&gt;/usr/src/xrecon-app&lt;/code&gt; directory.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;code&gt;EXPOSE&lt;/code&gt; is what port you would expose your image to.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because &lt;strong&gt;a container can have more than one image, &lt;/strong&gt;it is essential how the client would access your app through a port inside the Docker image.&lt;/p&gt;

&lt;p&gt;For example, suppose you have a &lt;strong&gt;Java server&lt;/strong&gt; &lt;strong&gt;image&lt;/strong&gt; and &lt;strong&gt;FTP server image&lt;/strong&gt; together inside a container.&lt;br&gt;
You would &lt;code&gt;expose&lt;/code&gt; the Java server usually in &lt;strong&gt;port 8080&lt;/strong&gt;, and the FTP server usually in &lt;strong&gt;port 21.&lt;/strong&gt;&lt;br&gt;
**&lt;br&gt;
&lt;strong&gt;Think of it like the container is a hotel.&lt;/strong&gt;&lt;br&gt;
You can reach the Java server  inside the &lt;strong&gt;hotel room number 8080&lt;/strong&gt;.&lt;br&gt;
And you can reach the FTP server inside the &lt;strong&gt;hotel room number 21&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;But it is greatly advised that you only have strictly one image inside a container especially if you want a Microservices nature of architecture.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;We're done with our short Docker basics!&lt;/strong&gt;&lt;br&gt;
Hope this helped!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Fear of asking questions? What mindset should you have?</title>
      <dc:creator>Ken Flake</dc:creator>
      <pubDate>Mon, 20 Jan 2020 12:41:38 +0000</pubDate>
      <link>https://dev.to/kensixx/fear-of-asking-questions-in-the-workspace-what-mindset-should-you-have-5552</link>
      <guid>https://dev.to/kensixx/fear-of-asking-questions-in-the-workspace-what-mindset-should-you-have-5552</guid>
      <description>&lt;p&gt;Hi, I'm having problems about approaching my manager, or other colleagues in work that I don't know of (or haven't talked to yet).&lt;/p&gt;

&lt;p&gt;Eventually there will come a time that I will have to come ask them of a subject matter they are specialized in.&lt;/p&gt;

&lt;p&gt;But it seems that, whenever I do, I always have that mindset that I'm technically disturbing them whenever I ask questions, whether it's a noob question or a question that actually makes sense.&lt;/p&gt;

&lt;p&gt;These questions may be technical in code or not, but of course mostly refers to questions in code and etc.&lt;/p&gt;

&lt;p&gt;Because there are times that asking a question once doesn't work, they have many people to support to, and I'm just one of them, so sometimes you have to bug them, it depends..&lt;/p&gt;

&lt;p&gt;One advice that I had from my colleague is that, if you don't remind of ask them constantly about your query, you're the one who will be delayed on your end at your task.&lt;/p&gt;

&lt;p&gt;But that's quite a negative remark in my perspective.&lt;/p&gt;

&lt;p&gt;For intermediate developers, and also senior managers, I would like to ask some advice on what beginner devs and new people in the office on what mindset should they have on approach when asking questions and assistance.. especially if you don't know who to approach to and such..&lt;/p&gt;

&lt;p&gt;This is also a good discussion for us developers, mentors and managers alike.&lt;/p&gt;

&lt;p&gt;Thank you so much!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>career</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
