Table of contents

Instances

TODO it’s still a work in progress that needs to be completed.

A single cozy-stack can manage several instances. Requests to different instances are identified through the Host HTTP Header, any reverse proxy placed in front of the cozy-stack should forward this header.

To simplify development, a dev instance name is used when no Host Header is provided. This behaviour will be kept when the stack is started in dev mode but will be blocked in production environment.

Exemple:

Creation

An instance is created on the command line:

$ cozy-stack instances add <domain>

With some possible additional options

It registers the instance in a global couchdb database global/instances

{
    "hostname": "example.cozycloud.cc",
    "dbprefix": "example-clozycloud-cc/",
    "fsroot": "/var/lib/cozy/example.cozycloud.cc/fs/"
}

and creates the proper databases ($PREFIX/$DOCTYPE) for these doctypes:

Then, it creates the following indexes for these doctypes :

Then, it creates some directories:

The ids are forced to known values: even if these directories are moved or renamed, they can still be found for the permissions.

The names are localized: If a locale is provided through the CLI, the directories will be created with names in this locale. Otherwise, theses directories will be created in english and renamed to localized name the first time the locale is set (during onboarding).

Then it creates the basic settings

Settings are created as named id in the $PREFIX/io.cozy.settings database. During onboarding, the fields will be prefilled with these value if they were provided.

Finally, applications from the --apps CLI option are installed.


Renaming

An instance is renamed through the command line.

$ cozy-stack instances rename <olddomain> <newdomain>

Renaming an instance only change the HostName in global/instances base.


Destroying

An instance is destroyed through the command line. A confirmation is asked from the CLI user unless the –yes flag is passed

$ cozy-stack instances destroy <domain>