<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Private NPM Registry &#8211; Sibeesh Passion</title>
	<atom:link href="https://sibeeshpassion.com/tag/private-npm-registry/feed/" rel="self" type="application/rss+xml" />
	<link>https://sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Sat, 10 Nov 2018 11:43:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>Private NPM Registry &#8211; Sibeesh Passion</title>
	<link>https://sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Having a Docker Container as Your Private NPM Registry &#8211; The Easy Way</title>
		<link>https://sibeeshpassion.com/having-a-docker-container-as-your-private-npm-registry-the-easy-way/</link>
					<comments>https://sibeeshpassion.com/having-a-docker-container-as-your-private-npm-registry-the-easy-way/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Sat, 10 Nov 2018 11:43:33 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Docker and NPM Private Registry]]></category>
		<category><![CDATA[Dockerizing]]></category>
		<category><![CDATA[NPM]]></category>
		<category><![CDATA[NPM Registry]]></category>
		<category><![CDATA[Private NPM Registry]]></category>
		<category><![CDATA[Verdaccio]]></category>
		<category><![CDATA[Verdaccio with Docker]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=13347</guid>

					<description><![CDATA[[toc] Introduction At some point in our life, we may need almost everything in a private scope, and the same happens with your NPM packages as well. You have created a private NPM package for your company or for yourself and you wanted to host it somewhere, you might have already looked for some options like a paid version of npmjs and many more. But, you were not happy doing it, and somehow you have reached in this article, and I am sure you are expecting something with Docker here. Yes, we are actually going to change our Docker container [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h2>Introduction</h2>
<p>At some point in our life, we may need almost everything in a private scope, and the same happens with your NPM packages as well. You have created a private NPM package for your company or for yourself and you wanted to host it somewhere, you might have already looked for some options like a paid version of npmjs and many more. But, you were not happy doing it, and somehow you have reached in this article, and I am sure you are expecting something with <a href="https://sibeeshpassion.com/category/docker/">Docker</a> here. Yes, we are actually going to change our Docker container instance to a private NPM registry, and once it is ready you can always host your private npm packages to that registry. If you are not sure of how to create an npm package, please read my Sounds cool? Then, let&#8217;s jump into it. I hope you will find this post useful.</p>
<h2>Background</h2>
<p>As I mentioned before, I am going to create a Container Instance and will be changing it to a private NPM registry. I will be using <a href="https://sibeeshpassion.com/category/azure/">Microsoft Azure</a>, if you don&#8217;t have a valid Azure subscription, I strongly recommend you to create one.</p>
<h2>Setting up a Docker Private NPM Registry</h2>
<p>Once you get the Azure subscription, you can start the setups.</p>
<h3>Creating Azure Container Registry</h3>
<p>Do you have a GitHub account? Do you know what we can do with a Github account? Yes, we can upload our projects/source codes there and we can do versioning, we can create branches and many more. You can consider that the Azure Container Registry is a similar service to that. An Azure Container Registry or ACR is a private Docker registry where you can easily manage all of your Docker container images in the same place. Isn&#8217;t that cool? According to Microsoft, you can use Azure Container Registry to:</p>
<ul>
<li>Store and manage container images across all types of Azure deployments</li>
<li>Use familiar, open-source Docker command line interface (CLI) tools</li>
<li>Keep container images near deployments to reduce latency and costs</li>
<li>Simplify registry access management with Azure Active Directory</li>
<li>Maintain Windows and Linux container images in a single Docker registry</li>
</ul>
<p>To create the Azure Container Registry, you should have a valid Azure subscription. If you don&#8217;t have one, please get one, that will help you follow this article.</p>
<p>Once you logged in to the Portal. You can click on the + icon, Create a resource, and search for the Container Registry.</p>
<div id="attachment_13349" style="width: 644px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Search-Container-Registry-e1541839869109.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-13349" class="size-full wp-image-13349" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Search-Container-Registry-e1541839869109.png" alt="Search Container Registry" width="634" height="304" /></a><p id="caption-attachment-13349" class="wp-caption-text">Search Container Registry</p></div>
<p>When you click the Container Registry, you will be asked to give the details as shown in the preceding image.</p>
<div id="attachment_13350" style="width: 310px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Container-Registry-Details.png"><img decoding="async" aria-describedby="caption-attachment-13350" class="wp-image-13350" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Container-Registry-Details-225x300.png" alt="Container Registry Details" width="300" height="400" srcset="/wp-content/uploads/2018/11/Container-Registry-Details-225x300.png 225w, /wp-content/uploads/2018/11/Container-Registry-Details-400x533.png 400w, /wp-content/uploads/2018/11/Container-Registry-Details-450x600.png 450w, /wp-content/uploads/2018/11/Container-Registry-Details.png 558w" sizes="(max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-13350" class="wp-caption-text">Container Registry Details</p></div>
<p>Please remember to enable the Admin user, as you will be able to use the registry name as username and admin user access key as the password to docker login to your container registry only if it is enabled. I will explain the same in the coming section.</p>
<p>Once you create your Container Registry, you will be given a login server as yourregistryname.azurecr.io. You can always see other information in the overview section. If you click on the Access Keys link under the settings, you can see the username and the password for your Container Registry. Remember we have enabled the Admin User property while creating the Container Registry?</p>
<div id="attachment_13351" style="width: 463px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Container-Registry-Settings.png"><img decoding="async" aria-describedby="caption-attachment-13351" class="size-full wp-image-13351" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Container-Registry-Settings.png" alt="Container Registry Settings" width="453" height="662" srcset="/wp-content/uploads/2018/11/Container-Registry-Settings.png 453w, /wp-content/uploads/2018/11/Container-Registry-Settings-205x300.png 205w, /wp-content/uploads/2018/11/Container-Registry-Settings-400x585.png 400w, /wp-content/uploads/2018/11/Container-Registry-Settings-411x600.png 411w" sizes="(max-width: 453px) 100vw, 453px" /></a><p id="caption-attachment-13351" class="wp-caption-text">Container Registry Settings</p></div>
<div class="fxc-base azc-control azc-editableControl azc-validatableControl azc-itemList azc-optionPicker azc-validation-border azc-noRadio azc-validatableControl-valid-validated azc-is-edited" data-control="true" data-editable="true" data-canfocus="true"></div>
<div data-control="true" data-editable="true" data-canfocus="true">Please be noted that the registry name and the admin username is same.</div>
<h3 data-control="true" data-editable="true" data-canfocus="true">Creating a Docker Container in Local</h3>
<div data-control="true" data-editable="true" data-canfocus="true">To do this step, you should download and install Docker in your machine. Once it is installed, please make sure that the docker is running in your machine. If yes, let&#8217;s go ahead and start some amazing things together. Let&#8217;s just try Docker version command first to make sure that it is working.</div>
<div data-control="true" data-editable="true" data-canfocus="true"></div>
<div data-control="true" data-editable="true" data-canfocus="true">
<div id="attachment_13352" style="width: 666px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Docker-version.png"><img decoding="async" aria-describedby="caption-attachment-13352" class="size-full wp-image-13352" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Docker-version.png" alt="Docker version" width="656" height="102" srcset="/wp-content/uploads/2018/11/Docker-version.png 656w, /wp-content/uploads/2018/11/Docker-version-300x47.png 300w, /wp-content/uploads/2018/11/Docker-version-400x62.png 400w" sizes="(max-width: 656px) 100vw, 656px" /></a><p id="caption-attachment-13352" class="wp-caption-text">Docker version</p></div>
</div>
<div data-control="true" data-editable="true" data-canfocus="true"></div>
<div data-control="true" data-editable="true" data-canfocus="true">Cool, the docker is working fine. Now we can start creating a local NPM registry. To do so I am going to pull a package from Docker hub, which is nothing but Verdaccio.</div>
<div data-control="true" data-editable="true" data-canfocus="true"></div>
<div data-control="true" data-editable="true" data-canfocus="true">Verdaccio is a private npm proxy registry which is built on top of Node.js. According to the Verdaccio documentation,</div>
<div data-control="true" data-editable="true" data-canfocus="true">
<ul>
<li>It&#8217;s a web app based on Node.js</li>
<li>It&#8217;s a private npm registry</li>
<li>It&#8217;s a local network proxy</li>
<li>It&#8217;s a Pluggable application</li>
<li>It&#8217;s a fairly easy install and use</li>
<li>It is 100% compatible with yarn, npm, and pnpm</li>
<li>It was <strong>forked</strong> based on and<code>sinopia@1.4.0</code> 100% <strong>backward compatible</strong>.</li>
</ul>
<p>Let&#8217;s pull the image of Verdaccio now.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">docker pull verdaccio/verdaccio</pre>
<p>Once you have done that, try to run &#8220;docker images&#8221;  you should be able to see your Verdaccio image.</p>
</div>
<pre class="EnlighterJSRAW" data-enlighter-language="null">verdaccio/verdaccio           latest              c542d9e516e4        3 weeks ago         659MB</pre>
<p>It may take a few minutes to pull the entire image. As I have already pulled the latest image, it will be quick for me and get the output as below.</p>
<div id="attachment_13353" style="width: 644px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Docker-pull-verdaccio.png"><img decoding="async" aria-describedby="caption-attachment-13353" class="wp-image-13353 size-full" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Docker-pull-verdaccio-e1541843418760.png" alt="Docker pull verdaccio" width="634" height="91" /></a><p id="caption-attachment-13353" class="wp-caption-text">Docker pull verdaccio</p></div>
<p>You can also tag the version you need, just in case.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">docker pull verdaccio/verdaccio:3</pre>
<p>Now it is time to run the Verdaccio, are you ready?</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio</pre>
<p>The last argument is our image name, if you don&#8217;t have such an image in your local, the same will be pulled from the Docker hub. As you might have noticed already we are using the port 4873, and the same will be mapped to the container instance port later when we create the container instance. Now please make sure that you are getting an output as preceding.</p>
<div id="attachment_13354" style="width: 644px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Verdaccio-docker-run.png"><img decoding="async" aria-describedby="caption-attachment-13354" class="wp-image-13354 size-full" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Verdaccio-docker-run-e1541844369136.png" alt="Verdaccio docker run" width="634" height="90" /></a><p id="caption-attachment-13354" class="wp-caption-text">Verdaccio docker run</p></div>
<p>You should now be able to go into http://localhost:4873 and see that verdaccio is running successfully.</p>
<h3>Pushing Local Container to Azure Container Registry</h3>
<p>Now that we have an Azure Container Registry running and a local container which can act as a private NPM registry. What are we waiting for? Let&#8217;s just push this to our ACR. Before that, we need to login to our Azure Container Registry server.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">docker login sibeeshpassion.azurecr.io</pre>
<p>Once you run the above command with the correct credential, you will be able to see the output as below.</p>
<div id="attachment_13355" style="width: 644px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Docker-login-Azure-container-registry.png"><img decoding="async" aria-describedby="caption-attachment-13355" class="wp-image-13355 size-full" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Docker-login-Azure-container-registry-e1541845257194.png" alt="Docker login Azure container registry" width="634" height="97" /></a><p id="caption-attachment-13355" class="wp-caption-text">Docker login Azure container registry</p></div>
<p>Now let&#8217;s just tag our image, as this will help to manage our images easily in the Container Registry.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">docker tag &lt;image name&gt; &lt;login server&gt;/&lt;repository name&gt;/&lt;name&gt;:v1
</pre>
<p>For example, I used this command as below.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">docker tag verdaccio/verdaccio sibeeshpassion.azurecr.io/verdaccio/verdaccio:v1</pre>
<p>Let&#8217;s push our image to the Container Registry now.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">docker push sibeeshpassion.azurecr.io/verdaccio/verdaccio:v1</pre>
<p>If everything goes well, you must see an output as preceding.</p>
<div id="attachment_13356" style="width: 644px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Pushing-to-Container-Registry.png"><img decoding="async" aria-describedby="caption-attachment-13356" class="wp-image-13356 size-full" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Pushing-to-Container-Registry-e1541846656271.png" alt="Pushing to Container Registry" width="634" height="191" /></a><p id="caption-attachment-13356" class="wp-caption-text">Pushing to Container Registry</p></div>
<p>Now, you can log in to your Azure portal and check the repositories of your Azure Container Registry. You should be able to see your image with the tag we have provided.</p>
<div id="attachment_13358" style="width: 644px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Repository-in-Azure-Container-Registry.png"><img decoding="async" aria-describedby="caption-attachment-13358" class="size-full wp-image-13358" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Repository-in-Azure-Container-Registry.png" alt="Repository in Azure Container Registry" width="634" height="404" srcset="/wp-content/uploads/2018/11/Repository-in-Azure-Container-Registry.png 634w, /wp-content/uploads/2018/11/Repository-in-Azure-Container-Registry-300x191.png 300w, /wp-content/uploads/2018/11/Repository-in-Azure-Container-Registry-400x255.png 400w" sizes="(max-width: 634px) 100vw, 634px" /></a><p id="caption-attachment-13358" class="wp-caption-text">Repository in Azure Container Registry</p></div>
<h3>Creating a Container Instance</h3>
<p>Now, we have a valid Container Registry which can act as a private NPM registry and is that enough? N,o it is not, we are not finished yet. We need a place where this registry can run. Well, Azure has everything we need, we are going to create a Container Instance for this purpose. A container instance is a simplest and fastest way to run a single container. While creating the Container Instance, you will have to go through 3 steps.</p>
<ol>
<li>Configure the basic settings</li>
<li>Specify container requirements</li>
<li>Container instance</li>
</ol>
<h4>Configure Basic Settings</h4>
<p>You can configure the settings as per your needs, I have configured mine as below.</p>
<div id="attachment_13359" style="width: 583px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Container-Instance-Basic-Settings.png"><img decoding="async" aria-describedby="caption-attachment-13359" class="size-full wp-image-13359" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Container-Instance-Basic-Settings.png" alt="Container Instance Basic Settings" width="573" height="1075" srcset="/wp-content/uploads/2018/11/Container-Instance-Basic-Settings.png 573w, /wp-content/uploads/2018/11/Container-Instance-Basic-Settings-160x300.png 160w, /wp-content/uploads/2018/11/Container-Instance-Basic-Settings-546x1024.png 546w, /wp-content/uploads/2018/11/Container-Instance-Basic-Settings-400x750.png 400w, /wp-content/uploads/2018/11/Container-Instance-Basic-Settings-320x600.png 320w" sizes="(max-width: 573px) 100vw, 573px" /></a><p id="caption-attachment-13359" class="wp-caption-text">Container Instance Basic Settings</p></div>
<p>Please be noted that I have given the container image type as Private.</p>
<h4>Specify Container Requirements</h4>
<p>Here in this step, I am going to select the Public IP address as &#8220;Yes&#8221;, so that I can set the DNS label while configuring. And I will also set the port as 4873.</p>
<div id="attachment_13360" style="width: 534px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/Network-Settings-in-Azure-Container-Instance.png"><img decoding="async" aria-describedby="caption-attachment-13360" class="size-full wp-image-13360" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/Network-Settings-in-Azure-Container-Instance.png" alt="Network Settings in Azure Container Instance" width="524" height="402" srcset="/wp-content/uploads/2018/11/Network-Settings-in-Azure-Container-Instance.png 524w, /wp-content/uploads/2018/11/Network-Settings-in-Azure-Container-Instance-300x230.png 300w, /wp-content/uploads/2018/11/Network-Settings-in-Azure-Container-Instance-400x307.png 400w" sizes="(max-width: 524px) 100vw, 524px" /></a><p id="caption-attachment-13360" class="wp-caption-text">Network Settings in Azure Container Instance</p></div>
<h4>Container Instance</h4>
<p>In this step, you can verify all of your settings, and in the background, Azure will validate the settings and if it is valid, the OK button will be enabled, click OK once it is enabled. It may take some time to build your resource and once it is done you can always go to the overview of your Container Instance and run it with the port 4873. For example, I can see my container in this URL http://sibeeshpassion.westeurope.azurecontainer.io:4873/#/.</p>
<h2>Pushing Your Own Private NPM Package to Docker Private NPM Registry</h2>
<p>Wow!, we have a private Docker NPM registry now. Let&#8217;s just try to push our private NPM package to this registry now. I have created my own NPM package a few days back, if you want to know how, you can always read this article: <a href="https://medium.com/@sibeeshvenu/create-your-own-npm-package-private-or-public-60edc2c42f68">Create Your Own NPM Package — Private or Public</a>. I will open my package in the vscode.</p>
<p>Let&#8217;s add the user before we publish the package.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">npm adduser --registry=http://sibeeshpassion.westeurope.azurecontainer.io:4873/#/</pre>
<p>The above command will ask you for the username and password.</p>
<div id="attachment_13361" style="width: 644px" class="wp-caption aligncenter"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/11/NPM-Publish-with-Private-Registry-AddUser.png"><img decoding="async" aria-describedby="caption-attachment-13361" class="size-full wp-image-13361" src="https://sibeeshpassion.com/wp-content/uploads/2018/11/NPM-Publish-with-Private-Registry-AddUser.png" alt="NPM Publish with Private Registry AddUser" width="634" height="140" srcset="/wp-content/uploads/2018/11/NPM-Publish-with-Private-Registry-AddUser.png 634w, /wp-content/uploads/2018/11/NPM-Publish-with-Private-Registry-AddUser-300x66.png 300w, /wp-content/uploads/2018/11/NPM-Publish-with-Private-Registry-AddUser-400x88.png 400w" sizes="(max-width: 634px) 100vw, 634px" /></a><p id="caption-attachment-13361" class="wp-caption-text">NPM Publish with Private Registry AddUser</p></div>
<p>Now we can run our publish command.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">npm publish dist --registry=http://sibeeshpassion.westeurope.azurecontainer.io:4873/#/</pre>
<p>You can get an output as preceding if the publishing is successful.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">npm notice === Tarball Details ===
npm notice name:          org-npm-package
npm notice version:       1.1.1
npm notice package size:  7.8 kB
npm notice unpacked size: 37.9 kB
npm notice shasum:        f1d8e033bb6d2545502802510258cf9f8bcc9ab3
npm notice integrity:     sha512-3MuplP75D0gpj[...]Z5KFo0DNbzGFw==
npm notice total files:   22
npm notice
+ org-npm-package@1.1.1</pre>
<p>What are you waiting for, just go and see your package in your Docker, I was eagerly waiting for this moment, and I am going to see my package by hitting my container here http://sibeeshpassion.westeurope.azurecontainer.io:4873/#/detail/org-npm-package.</p>
<h2>Using Your Private Package from the Docker Private NPM Registry</h2>
<p>Just run the below command and your private package will be pulled from your private Docker NPM registry.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">npm install org-npm-package --registry=http://sibeeshpassion.westeurope.azurecontainer.io:4873</pre>
<h2><span id="conclusion_1"><span id="conclusion">Conclusion</span></span></h2>
<p>Congratulation, we have successfully created a Docker Private NPM Registry, go ahead and create as many private packages you wish and move those to your Private NPM registry. Thanks a lot for following/reading this article. I really appreciate your time and effort.  In this article, we have learned how to,</p>
<ol>
<li>Create an Azure Container Registry</li>
<li>Create a Local Docker Container</li>
<li>Create Verdaccio image and run it in a local docker container</li>
<li>Push the local Verdaccio image to the Azure Container Registry</li>
<li>Set up the Docker Container Instance using the Azure Container Registry</li>
<li>Pushing the NPM package to the Private Docker NPM registry</li>
<li>Pulling the package from the Private registry</li>
</ol>
<h2><span id="your-turn-what-do-you-think">Your turn. What do you think?</span></h2>
<p>Thanks a lot for reading. I will come back with another post on the same topic very soon. Did I miss anything that you may think which is needed? Could you find this post as useful? Kindly do not forget to share me your feedback.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/having-a-docker-container-as-your-private-npm-registry-the-easy-way/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
