# Self-host LightRAG

> Graph based retrieval augmented generation server with a web UI and API. Runs on local file storage; point it at a model provider with the LLM and embedding settings.

- Page: https://levelrail.com/templates/lightrag/
- JSON: https://levelrail.com/templates/lightrag.json
- Category: AI
- Licence: MIT (Permissive license)
- Source: https://github.com/HKUDS/LightRAG
- Upstream docs: https://github.com/HKUDS/LightRAG/blob/main/lightrag/api/README.md

## Requirements
- Memory: about 1 GiB
- amd64: unknown, arm64: unknown
- Needs configuration before start: no
- Pinned image tag: v1.5.7

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| lightrag | ghcr.io/hkuds/lightrag | v1.5.7 | 9621 | rag -> /app/data/rag_storage; inputs -> /app/data/inputs |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| lightrag | EMBEDDING_BINDING | preset |
| lightrag | EMBEDDING_BINDING_API_KEY | preset |
| lightrag | EMBEDDING_BINDING_HOST | preset |
| lightrag | EMBEDDING_DIM | preset |
| lightrag | EMBEDDING_MODEL | preset |
| lightrag | HOST | preset |
| lightrag | LIGHTRAG_API_KEY | generated |
| lightrag | LLM_BINDING | preset |
| lightrag | LLM_BINDING_API_KEY | preset |
| lightrag | LLM_BINDING_HOST | preset |
| lightrag | LLM_MODEL | preset |
| lightrag | PORT | preset |

## Deploy

### CLI

```bash
levelrail-cli templates install lightrag --name my-lightrag
```

Add --domain SERVICE=HOST to serve a service on your own domain, for example --domain lightrag=app.example.com.

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  https://levelrail.example.com/api/v1/service-templates/lightrag/install \
  -d '{
    "name": "my-lightrag"
  }'
```

Create a token in the dashboard first. Name, env and domains are the request fields.

## First run
1. Set the LLM and embedding settings for your provider, then open the address to upload documents and query them. The generated API key protects the API.

## Questions

### Can I deploy LightRAG on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list we compared does not have an entry with the same id for LightRAG, so on Dokploy you would use a Docker Compose application with the file from this page. Dokku deploys container images with its own commands, so the pinned image ghcr.io/hkuds/lightrag:v1.5.7 is what you deploy there.

Self-host LightRAG, LightRAG docker compose file, deploy LightRAG on a VPS: this page lists the pinned image, ports, volumes and the commands for each.
