|
2 | 2 |
|
3 | 3 | Utility CLI + API that ingests docs into Supabase and exposes OpenAI-compatible chat completions, MCP endpoints, and ingestion endpoints. |
4 | 4 |
|
5 | | -## Local workflow |
6 | | - |
7 | | -1. Copy `.env.example` to `.env` and fill in the Supabase + LLM details plus a `MIMIR_SERVER_API_KEY`, which every HTTP call must send in the `x-api-key` header (or `Authorization: Bearer <key>`). Run `npm run generate-apikey` any time you want the project to mint a new random key and write it into your `.env` file. |
8 | | -2. Bootstrap the database schema (runs `psql src/supabase/setup.sql`): |
| 5 | +## Quick Start |
9 | 6 |
|
| 7 | +1. **Configure environment:** |
10 | 8 | ```bash |
11 | | - make setup-db DB_URL=postgresql://user@host:5432/db DB_PASSWORD=secret |
| 9 | + cp .env.example .env |
| 10 | + # Edit .env with your Supabase + LLM credentials |
12 | 11 | ``` |
13 | 12 |
|
14 | | -3. Start the API (automatically re-runs `setup-db` beforehand): |
| 13 | +2. **Generate API key:** |
| 14 | + ```bash |
| 15 | + npm run generate-apikey |
| 16 | + ``` |
15 | 17 |
|
| 18 | +3. **Start the server:** |
16 | 19 | ```bash |
17 | 20 | make server |
18 | 21 | ``` |
19 | 22 |
|
20 | | -4. Kick off ingestion on demand: |
| 23 | + The server automatically: |
| 24 | + - Loads your `.env` configuration |
| 25 | + - Bootstraps the database schema (if `DATABASE_URL` is set) |
| 26 | + - Starts the API on port 3000 |
21 | 27 |
|
| 28 | +4. **Trigger ingestion:** |
22 | 29 | ```bash |
23 | 30 | npm run ingest:cli |
24 | 31 | ``` |
25 | 32 |
|
26 | | - Or with a custom .env file: |
| 33 | +## Local Development |
27 | 34 |
|
28 | | - ```bash |
29 | | - npm run ingest:cli -- --config /path/to/custom.env |
30 | | - ``` |
| 35 | +### Database Setup |
| 36 | + |
| 37 | +The database schema is automatically initialized when you run `make server` if you provide database credentials in your `.env` file. You have two options: |
31 | 38 |
|
32 | | -## Docker workflow |
| 39 | +**Option 1: Automatic (Recommended)** |
| 40 | +Add your Supabase database password to `.env`: |
| 41 | +```bash |
| 42 | +MIMIR_SUPABASE_DB_PASSWORD=your_db_password |
| 43 | +``` |
| 44 | +The system will automatically construct the `DATABASE_URL` from your `MIMIR_SUPABASE_URL`. |
| 45 | + |
| 46 | +**Option 2: Manual DATABASE_URL** |
| 47 | +Provide the full database URL in `.env`: |
| 48 | +```bash |
| 49 | +DATABASE_URL=postgresql://postgres: [email protected]:5432/postgres |
| 50 | +``` |
33 | 51 |
|
34 | | -The repository includes a Node 20–based image for CI/CD and for developers who prefer not to install Node locally. |
| 52 | +### Manual Database Setup |
35 | 53 |
|
| 54 | +If you need to run the schema setup manually: |
36 | 55 | ```bash |
37 | | -make docker-build IMAGE_NAME=mimir-rag:local |
38 | | -make docker-run IMAGE_NAME=mimir-rag:local \ |
39 | | - CONFIG_PATH=./.env \ |
40 | | - DB_URL=postgresql://user@host:5432/db \ |
41 | | - DB_PASSWORD=secret \ |
42 | | - PORT=3000 |
| 56 | +make setup-db DB_URL=postgresql://user@host:5432/db DB_PASSWORD=secret |
43 | 57 | ``` |
44 | 58 |
|
45 | | -`docker-run` binds your local `.env` file into `/app/.env`, forwards the chosen port, and passes any database credentials so the container can reach Supabase. |
46 | | -When `DATABASE_URL` (or `DB_URL`) is provided, the container's entrypoint automatically runs `src/supabase/setup.sql` |
47 | | -before starting the server, mirroring the local `make setup-db` behavior. |
| 59 | +## Docker Deployment |
| 60 | + |
| 61 | +The repository includes a Node 20–based Alpine Linux image (~302MB) optimized for CI/CD and production deployments. |
| 62 | + |
| 63 | +### One-Line Setup |
| 64 | + |
| 65 | +**Build and run with your `.env` file:** |
| 66 | +```bash |
| 67 | +make docker-run-build |
| 68 | +``` |
| 69 | + |
| 70 | +That's it! The container automatically: |
| 71 | +- Loads all configuration from your `.env` file |
| 72 | +- Sets up the database schema (no manual psql commands needed) |
| 73 | +- Starts the server on port 3000 |
| 74 | + |
| 75 | +### Customization |
| 76 | + |
| 77 | +**Use a different port:** |
| 78 | +```bash |
| 79 | +make docker-run-build PORT=8080 |
| 80 | +``` |
| 81 | + |
| 82 | +**Use a different config file:** |
| 83 | +```bash |
| 84 | +make docker-run-build CONFIG_PATH=.env.production |
| 85 | +``` |
| 86 | + |
| 87 | +**Custom image name:** |
| 88 | +```bash |
| 89 | +make docker-run-build IMAGE_NAME=mimir:v1.0 |
| 90 | +``` |
| 91 | + |
| 92 | +### Separate Build and Run |
| 93 | + |
| 94 | +If you prefer to build and run separately: |
| 95 | + |
| 96 | +**Build:** |
| 97 | +```bash |
| 98 | +make docker-build |
| 99 | +``` |
| 100 | + |
| 101 | +**Run:** |
| 102 | +```bash |
| 103 | +make docker-run |
| 104 | +``` |
| 105 | + |
| 106 | +### Manual Docker Commands |
| 107 | + |
| 108 | +**Build:** |
| 109 | +```bash |
| 110 | +docker build -t mimir-rag:local . |
| 111 | +``` |
| 112 | + |
| 113 | +**Run:** |
| 114 | +```bash |
| 115 | +docker run --rm \ |
| 116 | + -p 3000:3000 \ |
| 117 | + -v $(pwd)/.env:/app/.env:ro \ |
| 118 | + mimir-rag:local |
| 119 | +``` |
| 120 | + |
| 121 | +### How It Works |
| 122 | + |
| 123 | +The Docker container: |
| 124 | +1. Mounts your `.env` file to `/app/.env` (read-only) |
| 125 | +2. Automatically loads all environment variables from `.env` |
| 126 | +3. Auto-constructs `DATABASE_URL` from `MIMIR_SUPABASE_URL` + `MIMIR_SUPABASE_DB_PASSWORD` (if not already set) |
| 127 | +4. Runs the database schema setup SQL automatically |
| 128 | +5. Starts the server |
| 129 | + |
| 130 | +**No manual database setup required!** Just add your database password to `.env` and everything else is automatic. |
48 | 131 |
|
49 | 132 | ## Configuration |
50 | 133 |
|
|
0 commit comments