<?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: Tanmay Jain</title>
    <description>The latest articles on DEV Community by Tanmay Jain (@tanminator).</description>
    <link>https://dev.to/tanminator</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%2F148988%2F2381f6d0-1784-456f-a65a-d817fcaf92c0.jpg</url>
      <title>DEV Community: Tanmay Jain</title>
      <link>https://dev.to/tanminator</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tanminator"/>
    <language>en</language>
    <item>
      <title>asdf Basics &amp; Cheat Sheet</title>
      <dc:creator>Tanmay Jain</dc:creator>
      <pubDate>Thu, 01 Sep 2022 16:42:38 +0000</pubDate>
      <link>https://dev.to/tanminator/asdf-basics-cheat-sheet-hn8</link>
      <guid>https://dev.to/tanminator/asdf-basics-cheat-sheet-hn8</guid>
      <description>&lt;p&gt;&lt;strong&gt;One tool to rule them all.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;code&gt;asdf&lt;/code&gt;&lt;/em&gt;&lt;/strong&gt; is a tool version manager. Manage each of your project runtimes with a single CLI tool and command interface.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Large ecosystem of existing runtimes &amp;amp; tools. Simple API to add support for new tools as you need!&lt;/li&gt;
&lt;li&gt;Support for existing config files .nvmrc, .node-versions, .ruby-version for smooth migration!&lt;/li&gt;
&lt;li&gt;.tool-versions to manage all your tools, runtimes and their versions in a single, sharable place.&lt;/li&gt;
&lt;li&gt;Supports Bash, ZSH, Fish &amp;amp; Elvish with completions available.&lt;/li&gt;
&lt;li&gt;Provides a GitHub Action to install and utilize your .tool-versions in your CI/CD workflows.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Install ASDF
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/asdf-vm/asdf.git ~/.asdf &lt;span class="nt"&gt;--branch&lt;/span&gt; v0.8.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Add to ~/.bashrc
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.asdf/asdf.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.asdf/completions/asdf.bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Basic commands
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Update asdf
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add plugin (eg.: ruby)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin add ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;List all languages plugin:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin list &lt;span class="nt"&gt;--urls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Update plugins
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin update &lt;span class="nt"&gt;--all&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin update ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remove plugin
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin remove ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;List all possible ruby versions
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf list-all ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install a ruby version using ruby plugin
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf &lt;span class="nb"&gt;install &lt;/span&gt;ruby 3.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;List all installed ruby versions
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf list ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Check current version of language plugin
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf current ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Check current version of all languages plugin
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Check installation path of plugin version
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Change plugin version locally/globally
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf &lt;span class="nb"&gt;local &lt;/span&gt;ruby 3.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf global ruby 2.7.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Remove asdf
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Remove following from &lt;code&gt;~/.bashrc&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.asdf/asdf.sh
&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.asdf/completions/asdf.bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ASDF_DATA_DIR&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="p"&gt;/.asdf&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; ~/.tool-versions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>asdf</category>
      <category>rvm</category>
      <category>nvmrc</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Setup Docker locally for private registries</title>
      <dc:creator>Tanmay Jain</dc:creator>
      <pubDate>Thu, 18 Aug 2022 09:42:34 +0000</pubDate>
      <link>https://dev.to/tanminator/setup-docker-locally-for-private-registries-3hko</link>
      <guid>https://dev.to/tanminator/setup-docker-locally-for-private-registries-3hko</guid>
      <description>&lt;h2&gt;
  
  
  Why would you need this setup ever?
&lt;/h2&gt;

&lt;p&gt;For organizations that build their own Base Images or have custom Docker Base Images, will most likely be hosted on a private Docker Registry like AWS etc.&lt;/p&gt;

&lt;p&gt;To run those Dockerfiles on your local machine, one would require to authenticate first. There can be external authorization services being used in combination with Docker Registries like Artifactory (jFrog).&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Docker (private) registry?
&lt;/h2&gt;

&lt;p&gt;A Docker registry is a storage and distribution system for named Docker images.&lt;/p&gt;

&lt;p&gt;A private Docker registry allows you to share and use base images within your organization. It is a centralized source of truth for the building blocks of your architecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F9jhQOeI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ndoalui2hg5hl2ak84n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F9jhQOeI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ndoalui2hg5hl2ak84n.png" alt="Docker Registry" width="472" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;In this example, we would focus on Artifactory as a Authorization Service for our private images and plugins.&lt;/p&gt;

&lt;h3&gt;
  
  
  Downloading the base Custom Image:
&lt;/h3&gt;

&lt;p&gt;You will need to login into the Docker Registry using your credentials.&lt;/p&gt;

&lt;p&gt;For Artifactory,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Login to your company's Artifactory client.&lt;/li&gt;
&lt;li&gt;Click on top-right corner on your name.&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;Set me up&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Package Type: &lt;code&gt;docker&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select relevant Repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, you should see the command you need to run to authenticate and download private images.&lt;/p&gt;

&lt;p&gt;It should be something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker login {org-name}-{docker-repository-name}.jfrog.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can manually add your credentials in &lt;code&gt;~/.docker/config.json&lt;/code&gt; file like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"auths"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"https://{org-name}-{docker-repository-name}.jfrog.io"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"auth"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{username}:{PASSWORD} (converted to base 64)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"youremail@email.com"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that you have access to download custom private images. Lets take a look at what our Dockerfile would look like and how can we install private libraries which are also hosted on Artifactory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up Dockerfile for private libraries:
&lt;/h3&gt;

&lt;p&gt;We will be focusing on Artfactory as an authentication service for our private libraries / gems etc.&lt;/p&gt;

&lt;p&gt;Our Dockerfile should look something like this:&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="c"&gt;# Fetch base image&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; {org-name}-{docker-repository-name}.jfrog.io/{path-to-docker-image}&lt;/span&gt;
&lt;span class="k"&gt;LABEL&lt;/span&gt;&lt;span class="s"&gt; maintainer="Tanmay Jain &amp;lt;tanmayj28@gmail.com&amp;gt;"&lt;/span&gt;

&lt;span class="c"&gt;# Setup your work directory&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; APP_HOME=/home/app/web&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; $APP_HOME&lt;/span&gt;

&lt;span class="c"&gt;# Copy required files&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; Gemfile.lock $APP_HOME&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;bundler &lt;span class="nt"&gt;--force&lt;/span&gt; &lt;span class="nt"&gt;-N&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 1 Gemfile.lock | &lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'[:blank:]\n'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; bundle &lt;span class="nt"&gt;--version&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . $APP_HOME&lt;/span&gt;

&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; app:app &lt;span class="nv"&gt;$APP_HOME&lt;/span&gt;

&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; app&lt;/span&gt;

&lt;span class="c"&gt;# Setup ssh keys to allow installing gems from artifactory&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; SSH_KEY&lt;/span&gt;
&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; SSH_KEY=$SSH_KEY&lt;/span&gt;

&lt;span class="c"&gt;# Create id_rsa from string arg, and set permissions&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SSH_KEY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /root/.ssh/id_rsa
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;600 /root/.ssh/id_rsa

&lt;span class="c"&gt;# Create known_hosts&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; /root/.ssh/known_hosts

&lt;span class="c"&gt;# bundle rubygems&lt;/span&gt;
&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; BUNDLE_DEPLOYMENT=true&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; BUNDLE_JOBS=4&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; BUNDLE_WITHOUT=development:test&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nt"&gt;--mount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ssh,target&lt;span class="o"&gt;=&lt;/span&gt;/home/app/.ssh/id_rsa,uid&lt;span class="o"&gt;=&lt;/span&gt;9999,gid&lt;span class="o"&gt;=&lt;/span&gt;9999 &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="nt"&gt;--mount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;secret,id&lt;span class="o"&gt;=&lt;/span&gt;artifactory,uid&lt;span class="o"&gt;=&lt;/span&gt;9999,gid&lt;span class="o"&gt;=&lt;/span&gt;9999 &lt;span class="se"&gt;\
&lt;/span&gt;    BUNDLE_&lt;span class="o"&gt;{&lt;/span&gt;ORG-NAME&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="nv"&gt;__JFROG__IO&lt;/span&gt;&lt;span class="o"&gt;={&lt;/span&gt;JFROG_USERNAME&lt;span class="o"&gt;}&lt;/span&gt;:&lt;span class="o"&gt;{&lt;/span&gt;JFROG_API_KEY&lt;span class="o"&gt;}&lt;/span&gt; bundle &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 3000&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["bundle", "exec", "rails", "server"]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;and we would build from our Dockerfile using command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build --build-arg SSH_KEY="$(cat ~/.ssh/id_rsa)" .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lets take a look at what we did above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following command would fetch your private custom base image which now you have access to.
&lt;/li&gt;
&lt;/ul&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; {org-name}-{docker-repository-name}.jfrog.io/{path-to-docker-image}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Following command would copy your &lt;code&gt;Gemfile.lock&lt;/code&gt;, which is needed for bundlig gems. You would need other files like, &lt;code&gt;package.json&lt;/code&gt;, &lt;code&gt;yarn.lock&lt;/code&gt; &lt;code&gt;Gemfile&lt;/code&gt; etc. ot be copied as well (as per need).
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; Gemfile.lock $APP_HOME&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Following command is used to add your private &lt;code&gt;ssh&lt;/code&gt; keys which probably have access granted to download private libraries.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; SSH_KEY&lt;/span&gt;
&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; SSH_KEY=$SSH_KEY&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SSH_KEY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /root/.ssh/id_rsa
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;600 /root/.ssh/id_rsa
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; /root/.ssh/known_hosts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Following command is used to install the private gems / libraries using the &lt;code&gt;ssh&lt;/code&gt; key we just copied.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nt"&gt;--mount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ssh,target&lt;span class="o"&gt;=&lt;/span&gt;/home/app/.ssh/id_rsa,uid&lt;span class="o"&gt;=&lt;/span&gt;9999,gid&lt;span class="o"&gt;=&lt;/span&gt;9999 &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="nt"&gt;--mount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;secret,id&lt;span class="o"&gt;=&lt;/span&gt;artifactory,uid&lt;span class="o"&gt;=&lt;/span&gt;9999,gid&lt;span class="o"&gt;=&lt;/span&gt;9999 &lt;span class="se"&gt;\
&lt;/span&gt;    BUNDLE_&lt;span class="o"&gt;{&lt;/span&gt;ORG-NAME&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="nv"&gt;__JFROG__IO&lt;/span&gt;&lt;span class="o"&gt;={&lt;/span&gt;JFROG_USERNAME&lt;span class="o"&gt;}&lt;/span&gt;:&lt;span class="o"&gt;{&lt;/span&gt;JFROG_API_KEY&lt;span class="o"&gt;}&lt;/span&gt; bundle &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that is how you setup your local machine with Docker pulling images and libraries from your private stores.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>jfrog</category>
      <category>deployment</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Installing Gem in Production Rails console</title>
      <dc:creator>Tanmay Jain</dc:creator>
      <pubDate>Sat, 11 Dec 2021 09:24:21 +0000</pubDate>
      <link>https://dev.to/tanminator/installing-gem-in-production-rails-console-47ka</link>
      <guid>https://dev.to/tanminator/installing-gem-in-production-rails-console-47ka</guid>
      <description>&lt;p&gt;For a good few years, I have been using &lt;code&gt;awesome_print&lt;/code&gt; for improved readability in rails console. But recently, I came across an issue where I had to read Audits from the console and my usual savior &lt;code&gt;awesome_print&lt;/code&gt; wasn't bundled.&lt;/p&gt;

&lt;p&gt;So, I stopped doing what I was meant to and spent next few hours figuring out, how can I install a gem in any environment without making code changes?&lt;/p&gt;

&lt;p&gt;Apparently this is possible by updating the &lt;code&gt;$LOAD_PATH&lt;/code&gt; variable and then requiring the gem manually.&lt;br&gt;
In Ruby, an identifier starting with a &lt;code&gt;$&lt;/code&gt; symbol is a global variable. &lt;code&gt;$LOAD_PATH&lt;/code&gt; is an array of absolute paths i.e it stores the exact location of all the dependencies in the project.&lt;/p&gt;

&lt;p&gt;So, let's assume we want to install &lt;code&gt;awesome_print&lt;/code&gt; in a production Rails Console. We can do so by following these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSH into the production server.&lt;/li&gt;
&lt;li&gt;Run this to install the gem,
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle install awesome_print
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Run this to figure out the path where gem is installed,
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem which awesome_print
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;which should give something like,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/user/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/awesome_print-1.9.2/lib/awesome_print.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now, lets start our Rails console&lt;/li&gt;
&lt;li&gt;We can add the path of this gem to the &lt;code&gt;$LOAD_PATH&lt;/code&gt; global variable using:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$LOAD_PATH &amp;lt;&amp;lt; /home/user/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/awesome_print-1.9.2/lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Let's try and require our freshly installed gem using:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require "/home/user/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/awesome_print-1.9.2/lib/awesome_print.rb"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow the above steps and you should be able to install and use any gem you want on your production server without making any code changes.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>gem</category>
      <category>bundler</category>
      <category>production</category>
    </item>
  </channel>
</rss>
