Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 238 additions & 0 deletions deploy/trieve-infrastructure.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
---
title: Trieve infrastructure deployment

Check warning on line 2 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L2

Did you really mean 'Trieve'?
description: Complete guide for deploying Trieve infrastructure on AWS using Terraform

Check warning on line 3 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L3

Did you really mean 'Trieve'?
---

This guide covers deploying the complete Trieve infrastructure stack on AWS using Terraform, including recent updates for Sentry monitoring and inference server configuration.

Check warning on line 6 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L6

Did you really mean 'Trieve'?

## Prerequisites

Before starting, ensure you have:
- Terraform CLI installed

Check warning on line 11 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L11

Use 'command-line tool' instead of 'CLI'.
- AWS CLI installed and configured

Check warning on line 12 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L12

Use 'command-line tool' instead of 'CLI'.
- SSH key pair for server access
- Domain name for your deployment

## Initial setup

### Configure AWS credentials

Run `aws configure` and provide your credentials:

```bash
aws configure
```

You'll see a prompt like this:
```
AWS Access Key ID [****************PYVK]: ****PYVK
AWS Secret Access Key [****************duMt]: ****duMt
Default region name [eu-central-1]:
Default output format [None]:
```

To get the ACCESS KEY and SECRET KEY, create an IAM user with admin permissions and generate access keys for CLI usage.

Check warning on line 34 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L34

Spell out 'KEY', if it's unfamiliar to the audience.

Check warning on line 34 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L34

Spell out 'KEY', if it's unfamiliar to the audience.

Check warning on line 34 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L34

Spell out 'IAM', if it's unfamiliar to the audience.

Check warning on line 34 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L34

Use 'administrator' instead of 'admin'.

Check warning on line 34 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L34

Use 'command-line tool' instead of 'CLI'.

### Deploy infrastructure

```bash
terraform init
terraform apply
```

## Server configuration

### SSH access

Check warning on line 45 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L45

'SSH access' should use sentence-style capitalization.

Each server has a `dev` user with SSH key access. Use the `ssh-keymain.pub` key for authentication:

```bash
ssh -i ~/.ssh/arguflow dev@<server_ip>
```

Running `terraform apply` provides the updated IP addresses for all servers.

## Service setup

### Reverse proxy

Configure DNS A records first:
```
A auth.<domain> <reverse_proxy_ip>
A api.<domain> <reverse_proxy_ip>
A redoc.<domain> <reverse_proxy_ip>
A search.<domain> <reverse_proxy_ip>
A chat.<domain> <reverse_proxy_ip>
A dashboard.<domain> <reverse_proxy_ip>
```

Or use a wildcard:
```
A *.<domain> <reverse_proxy_ip>
```

Copy the dashboard SSH key:
```bash
scp -i ssh-keymain ssh-keys/trieve-dashboard dev@<dashboard_ip>:.ssh/id_ed25519
```

Install dependencies and build applications:
```bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
source ~/.bashrc
nvm install --lts
nvm use --lts
npm install -g yarn

git clone https://github.com/devflowinc/trieve
git clone [email protected]:devflowinc/trieve-dashboard

echo "VITE_API_HOST=https://api.<domain>/api" > trieve/chat/.env
echo "VITE_API_HOST=https://api.<domain>/api" > trieve/search/.env
echo "VITE_API_HOST=https://api.<domain>/api" > trieve-dashboard/.env
echo "VITE_CHAT_UI_URL=https://chat.<domain>" >> trieve-dashboard/.env
echo "VITE_SEARCH_UI_URL=https://search.<domain>" >> trieve-dashboard/.env

cd trieve/search && yarn && yarn build
cd ../chat/ && yarn && yarn build
cd ../../trieve-dashboard/ && yarn && yarn build
```

Configure Caddy:

Check warning on line 101 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L101

Did you really mean 'Caddy'?
```bash
sudo systemctl enable --now caddy.service
```

### Keycloak authentication

Check warning on line 106 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L106

Did you really mean 'Keycloak'?

Keycloak provides OIDC authentication. You can skip this if you have an existing OIDC provider.

Check warning on line 108 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L108

Did you really mean 'Keycloak'?

Check warning on line 108 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L108

Spell out 'OIDC', if it's unfamiliar to the audience.

Check warning on line 108 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L108

Spell out 'OIDC', if it's unfamiliar to the audience.

Copy keycloak configuration:

Check warning on line 110 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L110

Did you really mean 'keycloak'?
```bash
scp -r -i ssh-keymain keycloak/ dev@<keycloak_ip>:
```

Create `docker-compose.yml` with updated credentials:
```yaml
version: "3"

services:
keycloak:
image: quay.io/keycloak/keycloak:23.0.7
environment:
- KEYCLOAK_ADMIN=admin
- KEYCLOAK_ADMIN_PASSWORD=<secure_password>
- KC_DB=postgres
- KC_DB_URL=jdbc:postgresql://<db_url>/keycloakdb
- KC_DB_USERNAME=<db_username>
- KC_DB_PASSWORD=<db_password>
- KC_PROXY=edge
- KC_HOSTNAME=auth.<domain>
- PROXY_ADDRESS_FORWARDING=true
entrypoint: "/opt/keycloak/bin/kc.sh start --import-realm"
ports:
- 8080:8080
volumes:
- ./keycloak/realm-export.json:/opt/keycloak/data/import/realm-export.json
- ./keycloak/themes/arguflow:/opt/keycloak/themes/arguflow
```

After first boot:
1. Change realm from `master` to `trieve`
2. Set login theme to `arguflow` in Realm Settings
3. Add redirect URLs in Clients -> vault:
- `https://api.<domain>/*`
- `https://search.<domain>/*`
- `https://chat.<domain>/*`
- `https://dashboard.<domain>/*`

### Inference server

The inference server now includes updated configuration for better performance:

```bash
ssh -i ~/.ssh/arguflow dev@<embeddings_ip>
git clone https://github.com/devflowinc/trieve
cd trieve/embedding-server/
tmux
./run-faster-jina.sh
```

### Qdrant vector database

Check warning on line 161 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L161

Did you really mean 'Qdrant'?

Qdrant is the only stateful service. Format the EBS volume on first setup:

Check warning on line 163 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L163

Did you really mean 'Qdrant'?

Check warning on line 163 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L163

Spell out 'EBS', if it's unfamiliar to the audience.

```bash
sudo mkfs.ext4 /dev/nvme1n1
sudo mount /dev/nvme1n1 /mnt
```

Start Qdrant:

Check warning on line 170 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L170

Did you really mean 'Qdrant'?
```bash
docker run -itd -e QDRANT__SERVICE__API_KEY=<secure_api_key> -p 6333:6333 -p 6334:6334 -v /mnt:/qdrant/storage qdrant/qdrant:v1.7.0
```

### Tika file conversion

Check warning on line 175 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L175

Did you really mean 'Tika'?

Start the Tika server:

Check warning on line 177 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L177

Did you really mean 'Tika'?
```bash
docker run -itd -p 9998:9998 apache/tika:2.9.1.0-full
```

### Main and ingest servers

Check warning on line 182 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L182

Use 'import' or 'load' instead of 'ingest'.

Configure environment variables in `.env`:

```bash
REDIS_URL=redis://<redis_cluster_url>
QDRANT_URL=http://<qdrant_ip>:6334
QDRANT_API_KEY=<qdrant_api_key>
DATABASE_URL=postgres://<user>:<password>@<db_url>:5432/<db_name>
OPENAI_API_KEY=<openai_key>
LLM_API_KEY=<llm_key>
SECRET_KEY=<64_char_secret>
SALT="<secure_salt>"
S3_ENDPOINT=<s3_endpoint>
S3_ACCESS_KEY=<s3_access_key>
S3_SECRET_KEY=<s3_secret_key>
S3_BUCKET=<bucket_name>
TIKA_URL="http://<tika_ip>:9998"
GPU_SERVER_ORIGIN="http://<embeddings_ip>:9999"
BASE_SERVER_URL="https://api.<domain>"
OIDC_CLIENT_SECRET="<keycloak_client_secret>"
OIDC_CLIENT_ID="vault"
OIDC_AUTH_REDIRECT_URL="https://auth.<domain>/realms/trieve/protocol/openid-connect/auth"
OIDC_ISSUER_URL="https://auth.<domain>/realms/trieve"
SENTRY_URL=""
```

## Monitoring with Sentry

Check warning on line 209 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L209

'Monitoring with Sentry' should use sentence-style capitalization.

Recent updates include Sentry integration for error monitoring and performance tracking. Configure the `SENTRY_URL` environment variable in your main and ingest servers to enable monitoring.

Check warning on line 211 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L211

Use 'import' or 'load' instead of 'ingest'.

## Updates

To update services when new versions are released:

Check warning on line 215 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L215

In general, use active voice instead of passive voice ('are released').

```bash
docker compose pull && docker compose down && docker compose up -d
```

For frontend services (dashboard, search, chat), rebuild and redeploy the static assets following the reverse proxy setup steps.

Check warning on line 221 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L221

Use the Oxford comma in 'For frontend services (dashboard, search, chat), rebuild and'.

Check warning on line 221 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L221

Use parentheses judiciously.

## Security considerations

- Change all default passwords
- Use secure API keys for Qdrant

Check warning on line 226 in deploy/trieve-infrastructure.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/trieve-infrastructure.mdx#L226

Did you really mean 'Qdrant'?
- Configure proper firewall rules
- Enable HTTPS with valid certificates
- Regularly update all services
- Monitor logs and set up alerts

## Troubleshooting

- Check service logs: `docker logs <container_name>`
- Verify network connectivity between services
- Ensure all environment variables are properly set
- Check DNS resolution for domain names
- Verify SSL certificates are valid