Provision a new CouchDB server.
The script couchdb-setup.sh runs several idempotent curl commands against CouchDB.
- Wait for CouchDB to be ready by querying welcome endpoint in a loop
- Setup the cluster as single node, usind
_cluster_setupAPI - Enable global changes feed and creating the
_global_changesdatabase - Configure
_usersdb security object (and enable it in config) to make public signup possible - Enable and configure CORS
- 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"'Setup CouchDB depends on curl.
You can manually run the script like so:
./couchdb-setup.sh http://admin:admin@localhost:5984Since 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.' })
}
}A Dockerfile installs dependencies, runs the script in a docker container and exists afterwards.