Configuration Reference

All configuration lives in a single .env file at the project root. Copy it from .env.example, fill in your secrets, and restart the stack. This page documents every variable.

Generate strong secrets. The bundled installer fills these in for you. If you set them by hand, use a random source:
openssl rand -hex 32   # DJANGO_SECRET_KEY
openssl rand -hex 24   # RAG_API_KEY / WHISPER_API_KEY

Bootstrap an .env

cp .env.example .env
# Edit .env — set DJANGO_SECRET_KEY, POSTGRES_PASSWORD,
# RAG_API_KEY, WHISPER_API_KEY at minimum.
docker compose up -d

Never commit .env to version control.

Database (PostgreSQL)

PostgreSQL stores users, chats, documents, and settings. Runs in the bundled postgres:16-alpine container.

VariableDefaultPurpose
POSTGRES_USERlocalaiDatabase username. Match the one in DATABASE_URL.
POSTGRES_PASSWORDlocalai_devReplace this with a strong password before exposing the host.
POSTGRES_DBlocalaiDatabase name. Match the one in DATABASE_URL.
DATABASE_URLpostgresql://localai:localai_dev@postgres:5432/localaiConnection string Django uses. Keep host as postgres (Docker service name).

Django (REST API)

VariableDefaultPurpose
DJANGO_SECRET_KEYchange-me-in-productionCryptographic key used to sign sessions, JWTs, password reset tokens. Must be unique per install.
DJANGO_DEBUGtrueSet false for production. Disables verbose errors and the debug toolbar.
CORS_ALLOWED_ORIGINShttp://localhost:3000,http://127.0.0.1:3000Comma-separated browser origins permitted to call the API. Add your real frontend URL if not localhost.
BACKEND_URLhttp://django:8000How Next.js reaches Django inside the Docker network. Change only if running Next.js outside Docker.

RAG service (document chat)

FastAPI service that indexes uploaded files and answers questions over them. Reached from Django and the frontend with a shared API key.

VariableDefaultPurpose
RAG_API_KEYdev-rag-key-change-meShared secret. The same value must appear in Django, Next.js, and the RAG container.
RAG_SERVICE_URLhttp://rag:8080Internal URL Django uses to reach the RAG FastAPI endpoint. Service-name only (Docker DNS).
RAG_URLhttp://rag:8080Same target as RAG_SERVICE_URL, but read by the Next.js build.

Ollama (LLM inference)

Ollama serves chat and embedding models. Two ways to wire it up: bundled container (default) or your existing host install.

VariableDefaultPurpose
OLLAMA_BASE_URLhttp://ollama:11434Where RAG and Django send model requests. Service-name URL by default.
OLLAMA_HOSThttp://ollama:11434Override to point at an external Ollama instance.
COMPOSE_PROFILEScontainer-ollamaProfile that enables the bundled Ollama service. Clear it to use host Ollama only.

Use host Ollama instead of the container

If you already run Ollama on your Mac / Linux host, point the stack at it and skip the bundled container:

OLLAMA_HOST=http://host.docker.internal:11434
COMPOSE_PROFILES=

On Linux, replace host.docker.internal with your host LAN IP or use --add-host in compose.

Whisper (speech-to-text)

Offline transcription via faster-whisper. The container caches its models in a named volume.

VariableDefaultPurpose
WHISPER_API_KEYchange-me-in-productionShared secret between Django and the Whisper container.
WHISPER_SERVICE_URLhttp://whisper:8090Internal URL Django uses to reach Whisper.
WHISPER_MODELbaseModel size: tiny · base · small (multilingual), or add .en for English-only and faster CPU inference.
Sizing guide: base ≈ 140 MB on disk, ~1–2 s for a 10 s clip on Apple Silicon CPU. tiny is faster but loses accuracy on noisy audio.

Docker images (release builds)

Used by docker-compose.release.yml when pulling pre-built images instead of building locally.

VariableDefaultPurpose
LOCAL_AI_IMAGE_PREFIXrizwanhameed360sDocker Hub / GHCR namespace where pre-built images live.
LOCAL_AI_IMAGE_TAG1.0.3Pinned image tag for the app services (backend, frontend, rag, updater).
LOCAL_AI_STABLE_TAG1.0.3Tag for the heavier images (Ollama, Whisper) that change less often. Falls back to LOCAL_AI_IMAGE_TAG if unset.

Updater service

Small sidecar that drives "Check for Updates" inside the app. Talks to the host Docker socket so it can pull and restart containers.

VariableDefaultPurpose
UPDATER_SERVICE_URLhttp://updater:8070Internal URL Django uses to proxy update requests.
UPDATER_API_KEYchange-me-in-productionShared secret. Replace.

Ports exposed on the host

Defined in docker-compose.yml. Change the host side (left of the colon) to free a port.

PortServicePurpose
80CaddyReverse proxy → Next.js + Django API by hostname.
5433PostgreSQLExternal access to the DB (mapped to container 5432).
11434OllamaOllama API — useful for tools like ollama list from the host.
8501RAG (Streamlit)Optional standalone document-chat UI.

Change the main app port

If port 80 is taken, remap Caddy. Edit docker-compose.yml:

services:
  caddy:
    ports:
      - "8080:80"   # host:container

Then visit http://local-ai.localhost:8080.

Example .env

A minimal production-ish file with placeholder secrets:

# PostgreSQL
POSTGRES_USER=localai
POSTGRES_PASSWORD=<strong-password>
POSTGRES_DB=localai

# Django
DATABASE_URL=postgresql://localai:<strong-password>@postgres:5432/localai
DJANGO_SECRET_KEY=<openssl rand -hex 32>
DJANGO_DEBUG=false
CORS_ALLOWED_ORIGINS=http://local-ai.localhost,http://api.local-ai.localhost

# RAG
RAG_API_KEY=<openssl rand -hex 24>
RAG_SERVICE_URL=http://rag:8080
RAG_URL=http://rag:8080

# Ollama (bundled)
OLLAMA_BASE_URL=http://ollama:11434
OLLAMA_HOST=http://ollama:11434
COMPOSE_PROFILES=container-ollama

# Whisper
WHISPER_API_KEY=<openssl rand -hex 24>
WHISPER_SERVICE_URL=http://whisper:8090
WHISPER_MODEL=base

# Pre-built images
LOCAL_AI_IMAGE_PREFIX=rizwanhameed360s
LOCAL_AI_IMAGE_TAG=1.0.3
LOCAL_AI_STABLE_TAG=1.0.3

# Updater
UPDATER_SERVICE_URL=http://updater:8070
UPDATER_API_KEY=<openssl rand -hex 24>

Rotating secrets

To replace a leaked or default secret:

  1. Edit the value in .env.
  2. Restart the affected service: docker compose up -d --force-recreate <service>.
  3. For DJANGO_SECRET_KEY: restart django; existing sessions and password-reset tokens are invalidated.
  4. For RAG_API_KEY / WHISPER_API_KEY: restart django, nextjs, and the target service together.
Never store secrets in committed files. If you've accidentally pushed a secret, rotate the value and force the affected service to restart immediately.