Making Local Development Faster with Caches for NPM & Composer (Part One: NPM)

This is the first post in a two part series detailing how you can use Docker to run local caches of both remote NPM resources and composer packages.

docker pull keyvanfatehi/sinopia

After the image has been pulled down, you can run it and map to a port using the following syntax:

docker run -p 81:4873 keyvanfatehi/sinopia

This will run sinopia and bind the external interface to port 81. There is a fair few configuration options that you can specify, I’d recommend getting a copy of the configuration file then mounting that as a volume.

Next, at the top of the screen, it’ll give you the two commands to make your client version of NPM connect to your new shiny cache, it’ll be something similar to:

Screenshot 2016-03-02 11.42.51

If you run those two commands, it’ll set your client to use your new cache and you’re good to go.

The following links are useful reference for this post:

[https://github.com/rlidwka/sinopia

](https://github.com/rlidwka/sinopia) [https://hub.docker.com/r/keyvanfatehi/sinopia/

](https://hub.docker.com/r/keyvanfatehi/sinopia/) [https://github.com/rlidwka/sinopia#using-private-packages

](https://github.com/rlidwka/sinopia#using-private-packages) https://blog.dylants.com/2014/05/10/creating-a-private-npm-registry-with-sinopia/