Files
docs/content/self-hosting/configuration/environment-variables.mdx

191 lines
7.3 KiB
Plaintext

import { Callout } from 'nextra/components'
# Environment Variables
Complete reference of all environment variables used by LearnHouse. These are configured in the `.env` file generated by `learnhouse setup`.
<Callout type="info">
Environment variables override any values set in configuration files. The `.env` file is the recommended configuration method.
</Callout>
## General
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_SITE_NAME` | The name of your LearnHouse instance | `LearnHouse` |
| `LEARNHOUSE_SITE_DESCRIPTION` | A short description of your site | `An open-source learning platform` |
| `LEARNHOUSE_CONTACT_EMAIL` | Contact email address displayed on the site | `admin@example.com` |
| `LEARNHOUSE_SELF_HOSTED` | Set to `true` for self-hosted deployments | `true` |
| `LEARNHOUSE_ENV` | Environment name | `production` |
| `LEARNHOUSE_DEVELOPMENT_MODE` | Enable development mode | `false` |
## Hosting
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_DOMAIN` | Your site domain | `learn.example.com` |
| `LEARNHOUSE_SSL` | Enable SSL (`true` or `false`) | `true` |
| `LEARNHOUSE_ALLOWED_ORIGINS` | Comma-separated list of allowed CORS origins | `https://learn.example.com` |
| `LEARNHOUSE_COOKIE_DOMAIN` | Domain used for cookies (prefix with `.` for subdomains) | `.example.com` |
| `LEARNHOUSE_ALLOWED_REGEXP` | Regex pattern for additional allowed origins | `\b((?:https?://)[^\s/$.?#].[^\s]*)\b` |
| `LEARNHOUSE_PORT` | Backend port (default 9000) | `9000` |
## Database
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_SQL_CONNECTION_STRING` | PostgreSQL connection string | `postgresql://learnhouse:learnhouse@db:5432/learnhouse` |
## Redis
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_REDIS_CONNECTION_STRING` | Redis connection string | `redis://redis:6379/learnhouse` |
## Authentication
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_AUTH_JWT_SECRET_KEY` | Secret key for JWT token signing | Generate with `openssl rand -base64 32` |
## Initial Admin
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_INITIAL_ADMIN_EMAIL` | Email for the first admin account | `admin@example.com` |
| `LEARNHOUSE_INITIAL_ADMIN_PASSWORD` | Password for the first admin account | Use a strong password |
## Frontend
| Variable | Description | Example |
|---|---|---|
| `NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG` | Enable multi-organization mode | `false` |
| `NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG` | Default organization slug | `defaultorg` |
| `NEXT_PUBLIC_LEARNHOUSE_API_URL` | Backend API URL (used by the frontend) | `http://localhost/api/v1/` |
| `NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL` | Backend base URL | `http://localhost` |
| `NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN` | Top-level domain for the frontend | `localhost` |
| `NEXT_PUBLIC_LEARNHOUSE_HTTPS` | Whether the frontend uses HTTPS | `false` |
| `NEXT_PUBLIC_LEARNHOUSE_MEDIA_URL` | URL for serving media content | `http://localhost/api/v1/` |
| `NEXT_PUBLIC_UNSPLASH_ACCESS_KEY` | Unsplash API key for stock images | `your-unsplash-key` |
## AI
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_GEMINI_API_KEY` | Google Gemini API key | `AIza...` |
| `LEARNHOUSE_IS_AI_ENABLED` | Enable AI features globally | `true` |
## Email
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_EMAIL_PROVIDER` | Email provider: `resend` or `smtp` | `resend` |
| `LEARNHOUSE_RESEND_API_KEY` | Resend API key (when using `resend` provider) | `re_...` |
| `LEARNHOUSE_SYSTEM_EMAIL_ADDRESS` | System email address (sender address) | `noreply@example.com` |
| `LEARNHOUSE_SMTP_HOST` | SMTP server hostname (when using `smtp` provider) | `smtp.example.com` |
| `LEARNHOUSE_SMTP_PORT` | SMTP server port (default 587) | `587` |
| `LEARNHOUSE_SMTP_USERNAME` | SMTP username | `user@example.com` |
| `LEARNHOUSE_SMTP_PASSWORD` | SMTP password | `your-smtp-password` |
| `LEARNHOUSE_SMTP_USE_TLS` | Enable TLS for SMTP | `true` |
## Content Storage
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_CONTENT_DELIVERY_TYPE` | Storage type: `filesystem` or `s3api` | `filesystem` |
| `LEARNHOUSE_S3_API_BUCKET_NAME` | S3 bucket name (when using `s3api`) | `learnhouse-content` |
| `LEARNHOUSE_S3_API_ENDPOINT_URL` | S3 endpoint URL (when using `s3api`) | `https://s3.amazonaws.com` |
## Collaboration Server
| Variable | Description | Example |
|---|---|---|
| `COLLAB_PORT` | Collaboration server port (default 4000) | `4000` |
| `COLLAB_INTERNAL_KEY` | Internal key for collaboration service auth | `your-collab-key` |
| `LEARNHOUSE_API_URL` | API URL used by the collaboration server | `http://learnhouse-app:9000/api/v1` |
| `LEARNHOUSE_REDIS_URL` | Redis URL used by the collaboration server | `redis://redis:6379` |
## Payments
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_STRIPE_SECRET_KEY` | Stripe secret key | `sk_live_...` |
| `LEARNHOUSE_STRIPE_PUBLISHABLE_KEY` | Stripe publishable key | `pk_live_...` |
| `LEARNHOUSE_STRIPE_WEBHOOK_STANDARD_SECRET` | Stripe webhook signing secret (standard account) | `whsec_...` |
| `LEARNHOUSE_STRIPE_WEBHOOK_CONNECT_SECRET` | Stripe webhook signing secret (Connect) | `whsec_...` |
| `LEARNHOUSE_STRIPE_CLIENT_ID` | Stripe OAuth client ID for Connect | `ca_...` |
## Code Execution
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_JUDGE0_API_URL` | Judge0 API URL for code execution | `https://judge0.example.com` |
| `LEARNHOUSE_JUDGE0_CLIENT_ID` | Judge0 client ID | `your-client-id` |
| `LEARNHOUSE_JUDGE0_CLIENT_SECRET` | Judge0 client secret | `your-client-secret` |
## Analytics
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_TINYBIRD_API_URL` | Tinybird API URL | `https://api.tinybird.co` |
| `LEARNHOUSE_TINYBIRD_INGEST_TOKEN` | Tinybird ingest token | `your-ingest-token` |
| `LEARNHOUSE_TINYBIRD_READ_TOKEN` | Tinybird read token | `your-read-token` |
## Observability
| Variable | Description | Example |
|---|---|---|
| `LEARNHOUSE_SENTRY_DSN` | Sentry DSN for error tracking | `https://abc@sentry.io/123` |
## Full Example
```env filename=".env" copy
# General
LEARNHOUSE_SITE_NAME=LearnHouse
LEARNHOUSE_SITE_DESCRIPTION=An open-source learning platform
LEARNHOUSE_CONTACT_EMAIL=admin@example.com
LEARNHOUSE_SELF_HOSTED=true
LEARNHOUSE_ENV=production
# Hosting
LEARNHOUSE_DOMAIN=learn.example.com
LEARNHOUSE_SSL=true
LEARNHOUSE_ALLOWED_ORIGINS=https://learn.example.com
LEARNHOUSE_COOKIE_DOMAIN=.example.com
LEARNHOUSE_PORT=9000
# Database
LEARNHOUSE_SQL_CONNECTION_STRING=postgresql://learnhouse:learnhouse@db:5432/learnhouse
# Redis
LEARNHOUSE_REDIS_CONNECTION_STRING=redis://redis:6379/learnhouse
# Authentication
LEARNHOUSE_AUTH_JWT_SECRET_KEY=your-generated-jwt-secret
NEXTAUTH_SECRET=your-generated-nextauth-secret
NEXTAUTH_URL=https://learn.example.com/
# Initial Admin
LEARNHOUSE_INITIAL_ADMIN_EMAIL=admin@example.com
LEARNHOUSE_INITIAL_ADMIN_PASSWORD=change-this-password
# Frontend
NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG=false
NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG=defaultorg
NEXT_PUBLIC_LEARNHOUSE_API_URL=http://localhost/api/v1/
NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL=http://localhost
NEXT_PUBLIC_LEARNHOUSE_HTTPS=false
# AI (optional)
LEARNHOUSE_GEMINI_API_KEY=
LEARNHOUSE_IS_AI_ENABLED=false
# Email (optional)
LEARNHOUSE_EMAIL_PROVIDER=resend
LEARNHOUSE_RESEND_API_KEY=
LEARNHOUSE_SYSTEM_EMAIL_ADDRESS=
# Content Storage
LEARNHOUSE_CONTENT_DELIVERY_TYPE=filesystem
```