Deploying a Lobechat App
Introduction
Lobechat is an open-source, extensible chat platform designed for privacy, flexibility, and ease of use. It supports real-time messaging, multiple authentication methods, and a modern web interface. This guide explains how to deploy a Lobechat application on Klutch.sh using a Dockerfile for a streamlined, production-ready setup.
Prerequisites
- A Klutch.sh account (sign up here)
- A GitHub repository for your Lobechat Docker setup
- Basic knowledge of Docker and Git
- A database (MongoDB or PostgreSQL) provisioned separately (see next section)
1. Provision a Database
Lobechat requires a database to store chat data. You can use either MongoDB or PostgreSQL. Follow the appropriate Klutch.sh database tutorial to provision your instance:
Once your database is ready, note the connection string for use in your environment variables.
1. Prepare Your Lobechat Project
Clone the official Lobechat repository or create your own:
git clone https://github.com/lobehub/lobechat.gitcd lobechat
2. Sample Dockerfile
Here’s a basic Dockerfile for Lobechat (adapt as needed for your version):
FROM node:20-alpine
WORKDIR /app
# Copy source codeCOPY . .
# Install dependenciesRUN npm install --production
# Build the app (if required)# RUN npm run build
# Expose the default portEXPOSE 3210
# Start the appCMD ["npm", "start"]
3. Configure Environment Variables
Set the required environment variables in your Klutch.sh app settings. Common variables include:
DATABASE_URL
(connection string for your database)PORT
(set to 3210 or your preferred port)- Any other variables required by your Lobechat configuration
Refer to the Lobechat documentation for a full list of supported environment variables.
4. Deploy to Klutch.sh
- Push your code (including Dockerfile) to your GitHub repository.
- In the Klutch.sh dashboard, create a new app and connect your repository.
- Set the build context and Dockerfile path if different from the root.
- Set the app port to
3210
(or the port exposed in your Dockerfile). - Add the required environment variables.
- Click “Create” to deploy. Klutch.sh will build and run your Lobechat container.
5. Post-Deployment
- Access your Lobechat instance using the provided Klutch.sh URL.
- Configure your chat platform as needed via the web interface.
- (Optional) Connect a custom domain via the Klutch.sh dashboard.