<?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>Forem: Kevin Pollet</title>
    <description>The latest articles on Forem by Kevin Pollet (@kevinpollet).</description>
    <link>https://forem.com/kevinpollet</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%2F158956%2F01bd38c5-bd7b-4355-ade2-db108a16aa8f.jpeg</url>
      <title>Forem: Kevin Pollet</title>
      <link>https://forem.com/kevinpollet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/kevinpollet"/>
    <language>en</language>
    <item>
      <title>Introducing seel — Build Docker images for your Node.js applications without effort</title>
      <dc:creator>Kevin Pollet</dc:creator>
      <pubDate>Thu, 17 Oct 2019 12:55:53 +0000</pubDate>
      <link>https://forem.com/kevinpollet/introducing-seel-a-docker-image-builder-for-your-node-js-applications-4g3e</link>
      <guid>https://forem.com/kevinpollet/introducing-seel-a-docker-image-builder-for-your-node-js-applications-4g3e</guid>
      <description>&lt;p&gt;I'm impatient and thrilled to introduce &lt;a href="https://github.com/kevinpollet/seel"&gt;seel&lt;/a&gt;, a command-line tool to containerize your &lt;strong&gt;Node.js&lt;/strong&gt; application without effort. Not all developers are Docker/container experts and containerizing a Node.js application is not a simple task. For example, you will have to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write a &lt;a href="https://docs.docker.com/engine/reference/builder/"&gt;Dockerfile&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Follow the security best practices&lt;/li&gt;
&lt;li&gt;Build the smallest image possible&lt;/li&gt;
&lt;li&gt;Optimize the Docker build cache&lt;/li&gt;
&lt;li&gt;Define a tagging strategy (e.g. &lt;a href="https://semver.org/"&gt;semantic versioning&lt;/a&gt;, git commit hash)&lt;/li&gt;
&lt;li&gt;Write and maintain build and publish scripts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Focus on your application, seel takes care of the containerization
&lt;/h2&gt;

&lt;p&gt;To simplify this &lt;strong&gt;seel&lt;/strong&gt; uses opinionated, but configurable, defaults based on the properties defined in the application &lt;code&gt;package.json&lt;/code&gt; (e.g. name, version, bin/main scripts, description, ...).&lt;/p&gt;

&lt;p&gt;The following screencast shows the containerization of an application created from scratch with &lt;code&gt;npm&lt;/code&gt; (more examples are available &lt;a href="https://github.com/kevinpollet/seel#examples"&gt;here&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/j01FVlT7tF0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Some features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Tree shaking, only the entry module dependencies are packaged&lt;/li&gt;
&lt;li&gt;Automatic image tagging with &lt;a href="https://semver.org/"&gt;semantic versioning&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Automatic image labelling (description, maintainer, version)&lt;/li&gt;
&lt;li&gt;Secure private package registry configuration&lt;/li&gt;
&lt;li&gt;Optimized Docker build cache&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's next?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;seel&lt;/strong&gt; is actively developed and at its early stages. If you want to test it, file issues, request a feature or contribute some code, go to the &lt;a href="https://github.com/kevinpollet/seel"&gt;GitHub repository&lt;/a&gt; and don't miss to give some 💚 and support with a ⭐.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kevinpollet"&gt;
        kevinpollet
      &lt;/a&gt; / &lt;a href="https://github.com/kevinpollet/seel"&gt;
        seel
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Build container images for your Node.js applications
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>showdev</category>
      <category>docker</category>
      <category>node</category>
      <category>devops</category>
    </item>
    <item>
      <title>How to use your .dockerignore as a whitelist</title>
      <dc:creator>Kevin Pollet</dc:creator>
      <pubDate>Sun, 11 Aug 2019 13:36:13 +0000</pubDate>
      <link>https://forem.com/kevinpollet/how-to-use-your-dockerignore-as-a-whitelist-3b77</link>
      <guid>https://forem.com/kevinpollet/how-to-use-your-dockerignore-as-a-whitelist-3b77</guid>
      <description>&lt;p&gt;Many tools use ignore files to exclude files from build, process or publish steps (e.g. &lt;code&gt;.npmignore&lt;/code&gt; for npm, &lt;code&gt;.gitignore&lt;/code&gt; for Git and &lt;code&gt;.dockerignore&lt;/code&gt; for Docker). As your project grows, evolves, it can be hard to maintain the exclusion patterns and, as a side effect, you can expose unwanted or sensitive files. Using your &lt;code&gt;.dockerignore&lt;/code&gt; as a whitelist can be an elegant option to avoid these mistakes and to reduce the effort to keep things up to date.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's the &lt;code&gt;.dockerignore&lt;/code&gt; for?
&lt;/h2&gt;

&lt;p&gt;When you're creating a Docker image, the very first step is to define the build &lt;a href="https://docs.docker.com/engine/reference/builder/"&gt;instructions&lt;/a&gt; in a &lt;code&gt;Dockerfile&lt;/code&gt;. The second step is to run the &lt;code&gt;docker build PATH&lt;/code&gt; command from the Docker CLI. The &lt;code&gt;PATH&lt;/code&gt; argument is the path to the folder containing your &lt;code&gt;Dockerfile&lt;/code&gt;. As a result, the Docker CLI will send the build &lt;code&gt;context&lt;/code&gt; to the Docker daemon.&lt;/p&gt;

&lt;h3&gt;
  
  
  The build &lt;code&gt;context&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Every file and folder within the given &lt;code&gt;PATH&lt;/code&gt; are &lt;code&gt;tar&lt;/code&gt;d by the Docker CLI and sent to the Docker daemon. These files and folders compose the build &lt;code&gt;context&lt;/code&gt;. Your Docker image will be built with this &lt;code&gt;context&lt;/code&gt;, so unwanted files sent to the daemon can be packaged by error in the final image with the &lt;code&gt;ADD&lt;/code&gt; or &lt;code&gt;COPY&lt;/code&gt; instructions.&lt;/p&gt;

&lt;p&gt;Also, the Docker daemon can be executed on a remote machine, so it's better to avoid sending large, unnecessary and sensitive files to it.&lt;/p&gt;

&lt;p&gt;Remember, &lt;code&gt;ADD&lt;/code&gt; and &lt;code&gt;COPY&lt;/code&gt; instructions are run by the daemon and never by the CLI, so they are not used to remove unwanted files from the build &lt;code&gt;context&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exclude files from the build &lt;code&gt;context&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;When you invoke the &lt;code&gt;docker build&lt;/code&gt; command, the Docker CLI looks for a file named &lt;code&gt;.dockerignore&lt;/code&gt; in the root folder of the build &lt;code&gt;context&lt;/code&gt; (i.e. in the root folder of the given &lt;code&gt;PATH&lt;/code&gt;). If this file exists, every file and folder matching the &lt;a href="https://docs.docker.com/engine/reference/builder/#dockerignore-file"&gt;exclusion patterns&lt;/a&gt; will not be included in the &lt;code&gt;tar&lt;/code&gt; archive sent to the Docker daemon. The Docker build will be faster and the risk of packaging unwanted files reduced. &lt;/p&gt;

&lt;p&gt;For example, if you want to exclude the &lt;code&gt;.git&lt;/code&gt; folder and all markdown files from the build &lt;code&gt;context&lt;/code&gt;, add the following content to your &lt;code&gt;.dockerignore&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.git
*.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Use your &lt;code&gt;.dockerignore&lt;/code&gt; as a whitelist
&lt;/h2&gt;

&lt;p&gt;Blacklist vs whitelist is a long debate and, I think, both types have its use case. From my experience, you'll have more files to exclude from your build &lt;code&gt;context&lt;/code&gt; than to include, so to keep things clean and secure, whitelisting files is less error-prone.&lt;/p&gt;

&lt;p&gt;If you've read the &lt;code&gt;.dockerignore&lt;/code&gt; &lt;a href="https://docs.docker.com/engine/reference/builder/#dockerignore-file"&gt;documentation&lt;/a&gt;, you may have noticed the following lines:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Finally, you may want to specify which files to include in the context, rather than which to exclude. To achieve this, specify * as the first pattern, followed by one or more! exception patterns.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Pretty easy! &lt;/p&gt;

&lt;p&gt;As an example, the following &lt;code&gt;.dockerignore&lt;/code&gt; instructs the Docker CLI to exclude everything excepted the &lt;code&gt;JS&lt;/code&gt; files within the &lt;code&gt;lib&lt;/code&gt; folder from the build &lt;code&gt;context&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Ignore everything
*

# Allow files and folders with a pattern starting with !
!lib/**/*.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a whitelist it's also possible to publish unwanted or sensitive files from a whitelisted folder but, in my opinion, this issue is minor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Now that you know how to blacklist or whitelist files with your &lt;code&gt;.dockerignore&lt;/code&gt;, choose the best option for your use case. To conclude, using your &lt;code&gt;.dockerignore&lt;/code&gt; as a whitelist allows to: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exclude by default everything from the build &lt;code&gt;context&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Reduce the size of the &lt;code&gt;tar&lt;/code&gt; archive sent to the Docker daemon&lt;/li&gt;
&lt;li&gt;Reduce the risk of packaging unwanted or sensitive files in your Docker &lt;code&gt;image&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Reduce the effort to keep exclusion patterns up to date&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PS: You can use the same trick with your &lt;code&gt;.gitignore&lt;/code&gt; or &lt;code&gt;.npmignore&lt;/code&gt;. For npm, the best practice is to use the &lt;a href="https://docs.npmjs.com/files/package.json#files"&gt;files&lt;/a&gt; property in your &lt;code&gt;package.json&lt;/code&gt; instead of a &lt;code&gt;.npmignore&lt;/code&gt; file.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>beginners</category>
      <category>showdev</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
