Skip to content

Commit

Permalink
docs: Add self-hosting guide
Browse files Browse the repository at this point in the history
  • Loading branch information
vrite-io[bot] authored Sep 13, 2023
1 parent cddc5b9 commit 42d1f7b
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 77 deletions.
88 changes: 88 additions & 0 deletions apps/docs/src/content/docs/self-hosting/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
To properly host Vrite, you first have to configure a couple of environment variables. This guide aims to give you an overview of the available options.

## Security

Providing a strong `SECRET` is important, as it’s the value used to encrypt JSON Web Tokens. You can generate one from the terminal with:

```bash
openssl rand -base64 32
```

## Cookies

The optional `COOKIE_DOMAIN` variable is used to set the `Domain` attribute for session cookies. If you make your Vrite services accessible at different subdomains (e.g. _api.vrite.io_, _app.vrite.io_, etc.) it’s important to set `COOKIE_DOMAIN` to your **top domain**, like _vrite.io_, for the necessary cookies to be accessible to all services.

## Email

Vrite uses email to handle registrations, magic link logins, and important verification messages. You have to configure email to be able to sign into your Vrite instance.

There are two email configuration options available:

- **SMTP** — sends emails through SMTP, compatible with most email providers;
- **SendGrid** — sends emails through SendGrid API;

For both, configure the `SENDER_EMAIL` and `SENDGER_NAME` variables.

Then, depending on the option you choose, configure the following:

```
# Email (SMTP)
SMTP_HOST=
SMTP_PORT=
SMTP_USER=
SMTP_PASS=
SMTP_SECURE=
# Email (SendGrid)
SENDGRID_API_KEY=
```

## S3

Vrite stores uploaded images using the S3. For local development, can use the S3 configuration provided in `.env.example` file, for connecting to [MinIO](https://min.io/) as set up in the `docker-compose.yml` file.

For production, make sure to either secure and properly configure your MinIO instance, or use an S3-compatible service — pretty much all should work.

## GitHub OAuth2

If you want to add _Sign in with GitHub_ option to your authentication page, make sure to provide the `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` variables. Follow [the official guide](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app) to acquire the values.

When the variables are not provided, the GitHub sign-in will be disabled.

## GitHub App

To enable Git sync and synchronize your content from your GitHub repo, you’ll have to provide credentials for your GitHub App. To obtain them, follow [the official guide](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) and then fill out the variables:

```
# GitHub App (optional - GitHub Git sync)
GITHUB_APP_ID=
GITHUB_APP_PRIVATE_KEY=
GITHUB_APP_CLIENT_ID=
GITHUB_APP_CLIENT_SECRET=
```

When the variables are not provided, the Git sync feature will be disabled.

## Weaviate

Vrite uses [Weaviate](https://weaviate.io/) to power its built-in semantic search. To enable it, you’ll have to provide `WEAVIATE_URL` and `WEAVIATE_API_KEY` variables, for Vrite to connect to your Weaviate instance.

Your Weaviate instance has to be properly configured to work with Vrite:

- It has to have [API Key authentication](https://weaviate.io/developers/weaviate/configuration/authentication#api-key) enabled;
- It has to have a default vectorizer module set;
- If the vectorizer isn’t `text2vec-openai` or OpenAI isn’t configured in Vrite, you have to provide proper configuration right inside your Weaviate instance, for the default vectorizer to work;

You can use the `weaviate` service from `docker-compose.yml` as a reference for basic setup with OpenAI vectorizer.

> **Important!** Currently, you have to configure Weaviate before you create your first Vrite Workspace, as each Workspace creates a [new tenant](https://weaviate.io/developers/weaviate/manage-data/multi-tenancy) in Weaviate. This means you can’t retroactively add Weaviate to your Vrite instance, for the time being.
When the variables are not provided, the search and AI question-answering features will be disabled.

## OpenAI

To enable AI question-answering, you have to configure both Weaviate and OpenAI. For the latter, you have to provide `OPENAI_API_KEY` and `OPENAI_ORGANIZATION` variables. You can find them in your [OpenAI dashboard](https://platform.openai.com/docs/api-reference/authentication).

The `OPENAI_API_KEY` will be automatically forwarded to your Weaviate instance to simplify the use of `text2vec-openai` vectorizer.

When the variables are not provided, the AI question-answering feature will be disabled.
81 changes: 4 additions & 77 deletions apps/docs/src/content/docs/self-hosting/docker.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Vrite aims to provide the best and most accessible technical writing experience. To do so, we provide both a ready, [easy-to-use “Vrite Cloud” instance](https://app.vrite.io/), as well as an option for you to **self-host Vrite** on your own servers.

The recommended way self-host Vrite is with [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/) - both of which you need to have installed on your machine.
The recommended way to self-host Vrite is with [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/) - both of which you need to have installed on your machine.

Start by cloning the Vrite repository and preparing the `docker.env` file:

Expand All @@ -10,89 +10,16 @@ git clone https://github.com/vriteio/vrite
cd vrite

cp .env.example docker.env

```

Then, open the `docker.env` file and fill in the environment variables. You can refer to the **Configuration** section below for more information on configuration.
Then, open the `docker.env` file and fill in the environment variables. You can refer to the [Configuration](/self-hosting/configuration) section for more information on the available options.

When you’re done, you can start Vrite with:

```bash
docker-compose up
```

## Configuration

Vrite monorepo is based on [Turborepo](https://turbo.build/repo). Among its most important dependencies are:

- [TypeScript](https://www.typescriptlang.org/) — the language the entirety of Vrite is written in;
- [Solid.js](https://solidjs.com/) — really fast UI framework powering nearly all of Vrite’s frontends;
- [Fastify](https://www.fastify.io/) — low-overhead Node.js web framework powering all of Vrite’s services;
- [tRPC](https://trpc.io/) — allows for fast development of end-to-end typesafe API for Vrite;
- [Tiptap](https://tiptap.dev/) & [ProseMirror](https://prosemirror.net/) — powerful Rich Text Editor (RTE) framework and toolkit powering Vrite editor;
- [Y.js](https://github.com/yjs/yjs) & [HocusPocus](https://hocuspocus.dev/) — libraries powering real-time collaboration in Vrite;
- [Monaco Editor](https://microsoft.github.io/monaco-editor/) — code editor providing VS Code-like experience for everything code in Vrite;
- [Astro](https://astro.build/) — great Static Site Generator (SSG) powering Vrite landing page and docs;

The following is the current project structure:

- `/packages` — contains code shared by apps or packages meant for separate publication;
- `/backend` — (`@vrite/backend`) backend code shared by all services;
- `/components` — (`@vrite/component`) basic, primitive UI components shared by multiple frontend UI apps;
- `/editor` — (`@vrite/editor`) contains custom and re-exported extensions for the Vrite editor (also used on the backend for JSON output processing)
- `/extensions` — (`@vrite/extensions`) contains all of Vrite’s official Extensions;
- `/scripts` — (`@vrite/script`) internal scripts for building and developing various packages and services;
- `/sdk/javascript` — (`@vrite/sdk`) Vrite’s JavaScript SDK;
- `/apps` — contains all the frontends and services of Vrite
- `/backend/api` — (`@vrite/api`) the REST API service;
- `/backend/collaboration` — (`@vrite/collaboration`) the real-time collaboration service;
- `/backend/core` — (`@vrite/core`) the main service hosting the app and internal API;
- `/backend/extensions` — (`@vrite/extensions-backend`) the service dedicated to handling Vrite Extensions functions;
- `/docs` — (`@vrite/docs`) the Vrite documentation;
- `/landing-page` — (`@vrite/landing-page`) the Vrite landing page;
- `/web` — (`@vrite/web`) the main Vrite app;

You can start a development server for all projects in the monorepo from the root using `pnpm dev` or for just a specific one using the `--filter` flag (e.g. `pnpm dev --filter @vrite/docs`). The same is applicable for `build` and `start` commands.

Not all packages projects provide all commands,

## Environment Variables

Most environment variables are meant to be configured at the root of the monorepo. To create your own `.env` file, you can follow the `.env.example`:

```
# Database
MONGO_URL=
REDIS_URL=
DATABASE=
# Security
SECRET=
# Domains
TOP_DOMAIN=
CALLBACK_DOMAIN=
# Serve
HOST=
# Email
SENDGRID_API_KEY=
SENDGRID_EMAIL_VERIFICATION_TEMPLATE_ID=
SENDGRID_MAGIC_LINK_TEMPLATE_ID=
SENDGRID_PASSWORD_CHANGE_VERIFICATION_TEMPLATE_ID=
SENDGRID_WORKSPACE_INVITE_TEMPLATE_ID=
SENDGRID_EMAIL_CHANGE_VERIFICATION_TEMPLATE_ID=
EMAIL=
SENDER_NAME=
# S3
S3_BUCKET=
S3_ENDPOINT=
S3_REGION=
S3_ACCESS_KEY=
S3_SECRET_KEY=
# GitHub OAuth2
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
# Frontend
PUBLIC_COLLAB_HOST=
PUBLIC_APP_HOST=
PUBLIC_API_HOST=
```

Right now Vrite depends on [MongoDB](https://www.mongodb.com/), [Redis](https://redis.com/), S3 storage, and [SendGrid](https://sendgrid.com/) to function. We hope to make some of these dependencies, like the mailing service, more flexible in the future.
> **Important!** Currently, when self-hosting, Vrite extensions aren’t available, as the Vrite Extension System isn’t ready yet. We’ll enable later on.

0 comments on commit 42d1f7b

Please sign in to comment.