Recently, my company needs to use a private NPM server. I did some research and finally chose verdaccio, an open source and free product. However, the environment setup is a huge trouble. Since it is Linux friendly, but my company only has Windows Server 2012 R2, I have to follow the incorrect official document and Googled a lot, finally it took me nearly 5 hours to install on the server. During these five hours of inhuman torture, there was only one voice in my heart: It would be nice if I used Azure.
I went home and did an experiment for using Azure to build a verdaccio NPM server. It really took only 45 seconds, and I clicked the mouse all the way without looking at any documents. I think that a developer's energy should be spent on the company's business rather than setup environments. This is also the goal that Microsoft and Azure have been working on, liberating developers from the heavy infrastructure work, and letting productivity really be used for business values.
The complexity of Windows Server deployment
This article does not describe how to set up a verdaccio environment on Windows Server, because it does not make much sense except for you to work overtime. I'm not saying that Windows is bad, I like to use it myself, but verdaccio is really not designed for Windows. To install this software on Windows Server, the general steps are as follows:
- Install Node.js, Python, Visual Studio 2019 C++ development load (Can you believe it? Install VS on the server? But trust me, install C++ runtime and compiler alone will not work)
- Install IIS, iisnode (Microsoft's official IIS Node.js support), URL Rewrite
- Create a new directory and put three files,
web.config, and they do not provide direct download, you need to copy the code from the official website, and then execute
- Write a
config.yamlin the website directory, the official document is missing this step
- Create a new website in IIS, point to the directory in step 3, and add the application pool user account to this directory, assign modify and execute permissions
- Open the script execution permission in IIS, the official document is missing this step
- Allow the port of the website in Windows Firewall
Even if you are a skilled worker, this set of steps should be done manually for at least 1 hour. If there are any error in the process, you are likely to work overtime.
Azure save the day
We Chinese say "Without comparison, there is no harm". Let’s take a look at how Azure can get us the verdaccio server within one minute without much effort.
Enter Azure Portal, click + Create a resource, search for Container instances, click Create (5 seconds)
Enter a Container name, select Docker Hub or other registry, enter verdaccio/verdaccio in the Image, selects Linux, click Next: Networking. (20 seconds)
Enter a domain name prefix in Networking, add TCP 4873 port, click Review + create (5 seconds)
Click Create to submit the deployment (1 second)
Wait for 10 seconds, when the deployment of the container instance is complete, click Go to resource
On the container instance welcome page, copy the FQDN to the browser, add :4873 port, and press Enter (4 seconds)
That's it, the total time is 45 seconds.
To prove that this is a truly usable NPM server, we can try create user and publish packages:
On the Azure side, you can easily manage the container instance, such as enter the console:
It takes only 45 seconds to deploy a Docker verdaccio NPM server using the Azure Container Instance service, and there is no need to create any VMs or install a Docker environment. Microsoft Cloud really frees developers from basic tasks and let us spend time on more meaningful works.
Learn more about Azure Container Instance here: https://docs.microsoft.com/en-us/azure/container-instances/