Run your own Unity Package Server (QNAP NAS)

Jul 8, 2023
Package Server
How to set up a verdaccio npm package server in Virtualization Station on your QNAP NAS
In a previous post I showed you how to run your own package server on the Google Cloud, but what if you have a QNAP NAS in your office and want to run it on there?
I explored 2 options:
  • Running verdaccio on Ubuntu 22.04 in Virtualization Station
  • Running verdaccio in a docker container in Container Station
The first approach works beautifully, the second one works only up until the point where the packages are supposed to show up in Unity - I’ll update this post if I ever figure out how to get the container-approach over the finishing line!
Anyway - here’s how I did it!

Unity Package Server in Virtualization Station

As a first step I logged into the QNAP NAS (I have a TS-664-4G) and created a VM in Virtualization Station, where I installed Ubuntu Server 22.04
notion imagenotion image
Next I launched the console of the VM and Installed verdaccio as per step 2 in the other blog post
And here’s what’s different:

Automatically starting verdaccio after server restart

Check the location of verdaccio: $ which verdaccio
notion imagenotion image
$ crontab -e (if it asks for your favourite editor, just pick nano)
add one line to the bottom: @reboot /usr/local/bin/verdaccio (or whatever location you got above)
should look like thisshould look like this
should look like this
CTRL + x to exit, asks if you want to save - you do.
🔄 Restart the VM
Now check if it worked and if it’s actually running: with $ pstree we can see that it’s running and was started by cron (if it’s not there, try to run it manually and you’ll likely see what error is preventing it from running)
verdaccio was started by cronverdaccio was started by cron
verdaccio was started by cron
$ ps aux | grep verdaccio - gives us a filtered list of processes showing only entries with “verdaccio”
notion imagenotion image
we see a process id of 688 in there, so we can do $ sudo tail -f /proc/688/fd/1 to live-capture its stdout output
or we can use $ sudo cat /proc/688/fd/1 | less to pipe all its stdout output into less and review it.

Optional: Local DNS Record

if you’re using a Ubiquiti router like the Dream Machine Pro, then the Ubuntu server should pop up under Topology in Unifi Console.
notion imagenotion image
Click on it to show its details, switch to Settings and assign a local DNS record (like verdaccio.internal). You probably also want to give it a Fixed IP.
notion imagenotion image
It might take a minute or so, but you should now be able to go to http://verdaccio.internal:4873 and see the web interface - but even if you have packages already in there it might say it’s empty.
To solve this open up the config.yaml in nano again cd ~/verdaccio; sudo nano config.yaml and add your URI under listen:
notion imagenotion image
Then restart your VM and it should work!
Then open the VM and do $ export VERDACCIO_PUBLIC_URL=http://verdaccio.internal to save it into the environment variables and restart. And now if you got to http://verdaccio.internal, it should be working!

Run Verdaccio via Docker in Container Station on QNAP NAS

Does not work yet. If you figure out how to make it work, please let me know!
Upgrade to Container Station 3 Beta
Containers > Create
Image: verdaccio/verdaccio:5.9
notion imagenotion image
Advanced Settings > Storage
Remove what’s there and add Bind Mount Host Path and point it at where you want the verdaccio content to live on your NAS.
notion imagenotion image
Make sure that folder exists, make a conf folder inside of it and put the config.yaml in there
make a storage folder inside the conf folder and put packages + .verdaccio-db.json in there (if not starting empty)
Now Create it, watch it start, go into the detailed view - if you click on the port forwarding port it copies the URL into your clipboard
notion imagenotion image
Go to that url and it should all be there! But the IP changes at every restart. We can create a fixed IP address for it like this:
  • Edit Container > Network
  • Add > Network Mode: Bridge > Check Use a static IP address, set it to something > Connect > Apply
notion imagenotion image
Restart and then it should be accessible via its static IP! (You can remove the other network)
⚠️ But I can’t get this one to show up under My Registries in Unity. The one running in a VM with a local DNS record works just fine… No idea why it doesn’t like this one… Might be an issue with having the storage on the NAS drive - but downloading right from the web interface works 😕
shows these errors:
notion imagenotion image

Leave a comment