CLI Environment Variables
This page covers two things: the environment variables the CLI itself reads, and the layout of the .env file it generates for a Community installation. For what each variable in that file does, and every other variable LearnHouse reads, see the Environment Variables reference.
Variables the CLI reads
| Variable | Description |
|---|---|
LEARNHOUSE_DIR | Installation directory to act on. Same as the global --dir |
LEARNHOUSE_DOCKER_BIN | Docker executable to call instead of dockerPATH.js.mjs.cjs |
LEARNHOUSE_ADMIN_PASSWORD | Admin password for setup--admin-password |
LEARNHOUSE_EXTERNAL_DB | External PostgreSQL connection string for setup--external-db |
LEARNHOUSE_EXTERNAL_REDIS | External Redis connection string for setup--external-redis |
LEARNHOUSE_LICENSE_KEY | Enterprise license key for setup--license |
LEARNHOUSE_CF_API_TOKEN | Cloudflare API token for Enterprise DNS-01 certificates, instead of --cf-api-token |
LEARNHOUSE_NO_UPDATE_CHECK | Any value turns off the check for a newer CLI version |
NO_UPDATE_NOTIFIER | Same as LEARNHOUSE_NO_UPDATE_CHECK |
CI | Any value turns off the update check |
LEARNHOUSE_DEBUG | Any value prints the stack trace when a command fails with an unexpected error |
Passing secrets through the environment keeps them out of the process list and your shell history. When both a flag and its variable are set, the flag wins.
LEARNHOUSE_ADMIN_PASSWORD=secretpass123 npx learnhouse setup --ci --domain example.com --admin-email [email protected]
Generated .env file
setup writes a .env file to the installation directory, readable only by your user. Edit it with npx learnhouse env or by hand, then run npx learnhouse start to apply the change.
The file is grouped into commented sections, in this order:
| Section | Variables written |
|---|---|
| Domain & Hosting | LEARNHOUSE_DOMAINHTTP_PORT |
| Frontend | NEXT_PUBLIC_LEARNHOUSE_API_URLNEXT_PUBLIC_LEARNHOUSE_BACKEND_URLNEXT_PUBLIC_LEARNHOUSE_DOMAINNEXT_PUBLIC_LEARNHOUSE_TOP_DOMAINNEXT_PUBLIC_LEARNHOUSE_MULTI_ORGNEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORGNEXT_PUBLIC_LEARNHOUSE_HTTPS |
| NextAuth | NEXTAUTH_URLNEXTAUTH_SECRETLEARNHOUSE_GOOGLE_CLIENT_IDLEARNHOUSE_GOOGLE_CLIENT_SECRET |
| Backend | LEARNHOUSE_SQL_CONNECTION_STRINGLEARNHOUSE_REDIS_CONNECTION_STRINGLEARNHOUSE_COOKIE_DOMAINLEARNHOUSE_PORT |
| Security | LEARNHOUSE_AUTH_JWT_SECRET_KEYLEARNHOUSE_INITIAL_ADMIN_EMAILLEARNHOUSE_INITIAL_ADMIN_PASSWORDLEARNHOUSE_INITIAL_ORG_NAMELEARNHOUSE_INITIAL_ORG_SLUG |
| Collaboration Server | COLLAB_INTERNAL_KEYLEARNHOUSE_REDIS_URLNEXT_PUBLIC_COLLAB_URL |
| General Settings | LEARNHOUSE_DEVELOPMENT_MODE=FalseLEARNHOUSE_LOGFIRE_ENABLED=False |
| AI Configuration | LEARNHOUSE_IS_AI_ENABLEDLEARNHOUSE_GEMINI_API_KEY |
| Email Configuration | Only when you enable email: LEARNHOUSE_EMAIL_PROVIDERLEARNHOUSE_SYSTEM_EMAIL_ADDRESSLEARNHOUSE_RESEND_API_KEYLEARNHOUSE_SMTP_* |
| Content Delivery | LEARNHOUSE_CONTENT_DELIVERY_TYPEfilesystems3apiLEARNHOUSE_S3_API_BUCKET_NAMELEARNHOUSE_S3_API_ENDPOINT_URL |
| Database Configuration | Only with the in-container database: POSTGRES_USERPOSTGRES_PASSWORDPOSTGRES_DB |
Values the CLI derives for you:
- The public URLs use
https://andwss://when HTTPS is on. They include the port when it is not the default, except when you handle SSL in your own proxy. NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAINis the last two labels of the domain, andLEARNHOUSE_COOKIE_DOMAINis that value with a leading dot (.localhostfor a local install).- With the in-container services, the connection strings point at
db:5432andredis:6379. With external services, they hold the connection strings you entered. NEXTAUTH_SECRET,LEARNHOUSE_AUTH_JWT_SECRET_KEY,COLLAB_INTERNAL_KEYandPOSTGRES_PASSWORDare random. Re-runningsetupon the same installation keeps them.
The generated docker-compose.yml also sets HOSTNAME=0.0.0.0 and LEARNHOUSE_API_URL=http://localhost:9000 for the app container. The setup wizard does not write LEARNHOUSE_SSL; add LEARNHOUSE_SSL=true yourself when you serve LearnHouse over HTTPS, so links the API builds outside a request (for example in background emails) use https://. See SSL & Domain.