Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Setup CouchDB

Provision a new CouchDB server.

The script couchdb-setup.sh runs several idempotent curl commands against CouchDB.

  1. Wait for CouchDB to be ready by querying welcome endpoint in a loop
  2. Setup the cluster as single node, usind _cluster_setup API
  3. Enable global changes feed and creating the _global_changes database
  4. Configure _users db security object (and enable it in config) to make public signup possible
  5. Enable and configure CORS
  6. Increase session timeout

For example, to configure the global changes feed, we issue curl request like this:

curl -XPUT --silent "$COUCHDB_URL/_global_changes"
curl -XPUT --silent "$COUCHDB_URL/_node/nonode@nohost/_config/global_changes/update_db" -d '"true"'

Dependencies

Setup CouchDB depends on curl.

Test

You can manually run the script like so:

./couchdb-setup.sh http://admin:admin@localhost:5984

TODO: Username Validation

Since we use usernames as database names as well as for Git directory names we will need to strengthen username validation. This will be done by creating another design document in the _users database with a validation doc function like this:

function (newDoc, oldDoc, userCtx, secObj) {
  if (!newDoc.name.match(/^[a-z]{3,32}$/)) {
    throw({ forbidden: 'doc.name must consist of 3-32 lowercase letters a-z.' })
  }
}

Docker

A Dockerfile installs dependencies, runs the script in a docker container and exists afterwards.