UPDATE Feb 2, 2014
Don’t bother with any of this. Use sinopia instead! I’ve prepared a docker image for it as well.
This tutorial is my version of this other tutorial.
First off make sure you have a large enough disk drive. You can find out the remote disk size easy like this:
1 | [root@alarmpi ~]# curl http://isaacs.iriscouch.com/registry/ |
data_size
lets us know that at the time of this writing you’ll be safe
with a 250GB SSD, but it’s anyone’s guess when that will be
insufficient. Currently that’s what I’m running.
Install & Configure CouchDB
On Mac OS X
- Use Homebrew to install couchdb:
brew install couchdb
read the
caveats to make it autostart on reboots - Point your browser to the CouchDB configuration page which should now be available at http://127.0.0.1:5984/_utils/index.html
On a Raspberry Pi w/ Arch Linux
- Grab the Arch image from http://www.raspberrypi.org/downloads
- Determine the device path for your SD card with
df
at the terminal. - Unzip and then
dd
the image to path you found:sudo dd bs=4m if=/path/to/img of=/dev/mysd
make sure you point to the card and not
the partition (e.g. /dev/disk1, not /dev/disk1s1) - Insert the SD card, start the Pi, and ssh into it (root/root)
- Format your external drive, ensure it is mountable,
and that your/etc/fstab
is set to
automount it. Uselsblk -f
to discover it. If you need more help check
this ArchWiki Page - Download some packages:
pacman -Sy couchdb
for more info see this ArchWiki Page - Edit
/etc/couchdb/local.ini
and set;bind_address = 127.0.0.1
tobind_address = 0.0.0.0
if you want to access it from another system - Edit
/etc/couchdb/local.ini
and under[couchdb]
add these 2 lines, per your storage location:database_dir = /media/storage/couchdb
andview_index_dir = /media/storage/couchdb
- Give the couchdb daemon permission to write to your external storage:
chown couchdb:daemon /media/storage
- Setup couchdb to autostart after reboot
systemctl enable couchdb
- Start couchdb with
systemctl start couchdb
- Connect to Futon using
your-ip:5984/_utils
CouchDB configuration continued
Now you have CouchDB installed and can access Futon and hopefully the
internet.
From Futon click “Configuration” and find secure_rewrites
and set it to false
Tell CouchDB to replicate continuously from NPM
Open terminal and enter the following to setup continuous replication
from the official npm registry:
1 | curl -X POST http://127.0.0.1:5984/_replicate -d '{"source":"http://isaacs.iriscouch.com/registry/", "target":"registry", "continuous":true, "create_target":true}' -H "Content-Type: application/json" |
Tell CouchDB to stop replicating
In case you ever need it:
1 | curl -X POST http://127.0.0.1:5984/_replicate -d '{"source":"http://isaacs.iriscouch.com/registry/", "target":"registry", "continuous":true, "create_target":true, "cancel":true}' -H "Content-Type: application/json" |
Making sure that it keeps replicating
There’s an unfortunate issue that I’m experiencing with couchdb, but it may
just stop replicating often only after transferring 5-7 GB of
data – a trivial retrigger of the replication with the above command
would cause it to pick up where it left off, so I’ve developed a script.
- Install nodejs
npm install npm-replication-watcher
npm install forever
forever npm-replication-watcher/bin/npm-replication-watcher
For more information check out
npm-replication-watcher
Finalizing the installation
This information can also be found here https://github.com/isaacs/npmjs.org. That link will also explain how to tell npm
to use your new registry.
git clone git://github.com/isaacs/npmjs.org.git
cd npmjs.org
sudo npm install -g couchapp
npm install couchapp
npm install semver
couchapp push registry/app.js http://localhost:5984/registry
couchapp push www/app.js http://localhost:5984/registry
Testing the installation
npm --registry http://localhost:5984/registry/_design/scratch/_rewrite login
npm --registry http://localhost:5984/registry/_design/scratch/_rewrite search