Skip to content

sumaiazaman/librechat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LibreChat Docker Deployment

A production-ready Docker deployment of LibreChat - an open-source AI chat platform that supports multiple LLM providers including OpenAI, Anthropic, Google, and local models via Ollama.

πŸš€ Features

  • Multi-Provider Support: OpenAI (GPT-4, GPT-3.5), Anthropic (Claude), Google (Gemini), and Ollama (local LLMs)
  • Docker-Based: Easy deployment with Docker Compose
  • MongoDB Integration: Persistent data storage
  • Secure: JWT authentication, encrypted API key storage
  • User Management: Built-in registration and authentication system
  • Self-Hosted: Full control over your data and privacy

πŸ“‹ Prerequisites

  • Docker (version 20.10 or higher)
  • Docker Compose (version 2.0 or higher)
  • At least one API key from supported LLM providers (optional for Ollama)

πŸ› οΈ Installation

1. Clone or Download This Repository

  git clone git@github.com:sumaiazaman/librechat.git
  cd librechat

2. Configure Environment Variables

Copy the example environment file and edit it with your settings:

  cp .env.example .env

Edit .env and configure the following:

Required Settings

  # Generate secure secrets (use: openssl rand -hex 32)
  JWT_SECRET=your-secure-jwt-secret
  JWT_REFRESH_SECRET=your-secure-refresh-secret
  SESSION_SECRET=your-secure-session-secret
  CREDS_KEY=your-32-byte-creds-key
  CREDS_IV=your-16-byte-creds-iv

API Keys (at least one required)

  OPENAI_API_KEY=sk-your-openai-key
  ANTHROPIC_API_KEY=sk-ant-your-anthropic-key
  GOOGLE_KEY=your-google-key

3. Generate Secure Secrets

Use OpenSSL to generate secure random strings:

# For JWT and session secrets (32 bytes)
openssl rand -hex 32

# For credentials key (32 bytes)
openssl rand -hex 32

# For credentials IV (16 bytes)
openssl rand -hex 16

4. Start the Application

  docker-compose up -d

5. Access LibreChat

Open your browser and navigate to:

http://localhost:3080

πŸ“– Usage

Starting the Application

  docker-compose up -d

Stopping the Application

  docker-compose down

Viewing Logs

# All services
docker-compose logs -f

# LibreChat only
docker-compose logs -f librechat

# MongoDB only
docker-compose logs -f mongodb

Restarting After Configuration Changes

  docker-compose restart

Updating to Latest Version

  docker-compose pull
  docker-compose up -d

πŸ”§ Configuration

Environment Variables

Variable Description Required Default
NODE_ENV Application environment Yes production
PORT Application port Yes 3080
MONGO_URI MongoDB connection string Yes mongodb://mongodb:27017/librechat
JWT_SECRET JWT signing secret Yes -
JWT_REFRESH_SECRET JWT refresh token secret Yes -
SESSION_SECRET Session encryption secret Yes -
CREDS_KEY API key encryption key Yes -
CREDS_IV API key encryption IV Yes -
ALLOW_REGISTRATION Enable user registration No true
OPENAI_API_KEY OpenAI API key No -
ANTHROPIC_API_KEY Anthropic API key No -
GOOGLE_KEY Google API key No -

Disabling User Registration

To disable new user registration after creating your account:

# In .env file
ALLOW_REGISTRATION=false

Then restart:

  docker-compose restart

πŸ—„οΈ Data Persistence

MongoDB data is persisted in a Docker volume named mongo_data. This ensures your conversations and settings are preserved across container restarts.

Backup Database

  docker-compose exec mongodb mongodump --out /data/backup
  docker cp librechat_mongodb:/data/backup ./backup

Restore Database

  docker cp ./backup librechat_mongodb:/data/backup
  docker-compose exec mongodb mongorestore /data/backup

πŸ”’ Security Best Practices

  1. Never commit .env file - It contains sensitive secrets
  2. Use strong, random secrets - Generate with openssl rand -hex 32
  3. Disable registration - Set ALLOW_REGISTRATION=false after creating your account
  4. Use HTTPS in production - Set up a reverse proxy (nginx, Caddy, Traefik)
  5. Regular updates - Keep LibreChat and MongoDB images updated
  6. Firewall rules - Restrict access to port 3080 if needed

πŸ› Troubleshooting

Container won't start

# Check logs
docker-compose logs

# Verify .env file exists and is configured
cat .env

Can't connect to MongoDB

# Ensure MongoDB is running
docker-compose ps

# Check MongoDB logs
docker-compose logs mongodb

Port 3080 already in use

Edit docker-compose.yml and change the port mapping:

ports:
  - "8080:3080"  # Use port 8080 instead

πŸ“š Additional Resources

πŸ“„ License

This deployment configuration is provided as-is. LibreChat is licensed under the MIT License.

🀝 Contributing

Feel free to submit issues and enhancement requests!


Note: This is a Docker deployment configuration for LibreChat. For the main LibreChat project, visit github.com/danny-avila/LibreChat.

About

Docker Compose setup to run LibreChat locally with MongoDB, environment-based configuration, and optional LLM integrations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors