Single-Click Private NPM Repository on Docker using Sinopia and Nginx

TL;DR Just developed a “single-click” Docker file to deploy a private NPM repository using Sinopia and Nginx. Not on the Docker hub yet, but you can pull it from my Github at https://github.com/chris-tomich/sinopia-nginx.

I’ve been using Docker quite a lot the past 2 weeks to simplify Oystr’s deployment and I’ve really come to love it! Whilst I do love the ease at which you can create repeatable and easily transferable deployment environments, I think what has really bought me over is the way in which you are working in a completely isolated environment without having to go to the extent of a virtual machine.

Thanks to my personal enlightenment on the wonders of Docker (and the current “oooh I have a new toy” fanboy obsession I’ve grown), I decided to write a Dockerfile for a Sinopia and Nginx deployment. If you’re not familiar with Sinopia, it’s basically a private NPM repository. It’s not a full repository like the official NPM one (for a start it uses the file system as storage, not Couch DB), but it does a pretty good job at emulating one. You can find out more about it at https://www.npmjs.com/package/sinopia.

I did try to use the two most popular Docker images for Sinopia currently on the Docker hub, but I couldn’t get them working with a single click – and I really wanted a single-click script. So like any good (and impatient) developer, I rolled my own. Hopefully it’ll mean you won’t have to! (although I totally understand if you do 😉 )

You can get the Dockerfile and related files from my Github at https://github.com/chris-tomich/sinopia-nginx and build it for yourself very easily with the following commands –

  1. sudo docker build -t sinopia-nginx .
  2. sudo docker run -p 80:80 –name sinopia -d sinopia-nginx

I’ll write some better documentation over the next week and upgrade it a little, but for now if you’re just wanting a single click Sinopia deployment, this should hopefully suffice. My plan is to upgrade it so that –

  1. The Sinopia config.yaml and the Nginx nginx.conf files are mapped to volumes.
  2. The Sinopia storage is mapped to a volume.
  3. A way to provide Nginx with certificates/keys for SSL and automatic setup of SSL.

Enjoy! 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s