Make it (a tiny bit) easier to run your own collab (#9557)

* Allow creating channels when seeding
* Allow configuring a custom `SEED_PATH`
* Seed the database when creating/migrating it so you don't need a
  separate step for this.

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-03-20 21:00:02 -06:00 committed by GitHub
parent 1062c5bd26
commit ac4c6c60f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 246 additions and 177 deletions

View file

@ -12,21 +12,19 @@ script/bootstrap
This script will set up the `zed` Postgres database, and populate it with some users. It requires internet access, because it fetches some users from the GitHub API.
The script will create several _admin_ users, who you'll sign in as by default when developing locally. The GitHub logins for these default admin users are specified in this file:
The script will seed the database with various content defined by:
```
cat crates/collab/.admins.default.json
cat crates/collab/seed.default.json
```
To use a different set of admin users, you can create a file called `.admins.json` in the same directory:
To use a different set of admin users, you can create your own version of that json file and export the `SEED_PATH` environment variable. Note that the usernames listed in the admins list currently must correspond to valid Github users.
```
cat > crates/collab/.admins.json <<JSON
[
"your-github-login",
"another-github-login"
]
JSON
```json
{
"admins": ["admin1", "admin2"],
"channels": ["zed"]
}
```
## Testing collaborative features locally
@ -34,13 +32,37 @@ JSON
In one terminal, run Zed's collaboration server and the `livekit` dev server:
```
foreman start
```
In a second terminal, run two or more instances of Zed.
```
script/zed-local -2
```
This script starts one to four instances of Zed, depending on the `-2`, `-3` or `-4` flags. Each instance will be connected to the local `collab` server, signed in as a different user from `.admins.json` or `.admins.default.json`.
## Running a local collab server
If you want to run your own version of the zed collaboration service, you can, but note that this is still under development, and there is no good support for authentication nor extensions.
Configuration is done through environment variables. By default it will read the configuration from [`.env.toml`](../../crates/collab/.env.toml) and you should use that as a guide for setting this up.
By default Zed assumes that the DATABASE_URL is a Postgres database, but you can make it use Sqlite by compiling with `--features sqlite` and using a sqlite DATABASE_URL with `?mode=rwc`.
To authenticate you must first configure the server by creating a seed.json file that contains at a minimum your github handle. This will be used to create the user on demand.
```json
{
"admins": ["nathansobo"]
}
```
By default the collab server will seed the database when first creating it, but if you want to add more users you can explicitly reseed them with `SEED_PATH=./seed.json cargo run -p collab seed`
Then when running the zed client you must specify two environment variables, `ZED_ADMIN_API_TOKEN` (which should match the value of `API_TOKEN` in .env.toml) and `ZED_IMPERSONATE` (which should match one of the users in your seed.json)