You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
4.9 KiB
Markdown
138 lines
4.9 KiB
Markdown
---
|
|
title: Deploy LobeChat with database on Dokploy
|
|
description: >-
|
|
Learn how to deploy LobeChat with database on Dokploy with ease, including:
|
|
database, authentication and S3 storage service.
|
|
tags:
|
|
- Deploy LobeChat
|
|
- Vercel Deployment
|
|
- OpenAI API Key
|
|
- Custom Domain Binding
|
|
---
|
|
|
|
# Deploying Server Database Version on Dokploy.
|
|
|
|
This article will detail how to deploy the server database version of LobeChat.
|
|
|
|
## 1. Preparation Work
|
|
|
|
### Deploy Dokploy and configure related settings.
|
|
|
|
```shell
|
|
curl -sSL https://dokploy.com/install.sh | sh
|
|
```
|
|
|
|
1. Connect your GitHub to Dokploy in the Settings / Git section according to the prompt.
|
|
|
|

|
|
|
|
2. Enter the Projects interface to create a Project.
|
|
|
|

|
|
|
|
### Configure S3 Storage Service
|
|
|
|
In the server-side database, we need to configure the S3 storage service to store files. For detailed configuration instructions, please refer to the section [Configure S3 Storage Service](https://lobehub.com/docs/self-hosting/server-database/vercel#3-configure-s-3-storage-service) in the Vercel deployment guide。After the configuration is complete, you will obtain the following environment variables:
|
|
|
|
```shell
|
|
S3_ACCESS_KEY_ID=
|
|
S3_SECRET_ACCESS_KEY=
|
|
S3_ENDPOINT=
|
|
S3_BUCKET=
|
|
S3_PUBLIC_DOMAIN=
|
|
S3_ENABLE_PATH_STYLE=
|
|
```
|
|
|
|
### Configure the Clerk authentication service.
|
|
|
|
Obtain the three environment variables: `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY`, `CLERK_SECRET_KEY`, and `CLERK_WEBHOOK_SECRET`. For detailed configuration steps for Clerk, please refer to the section [Configure Authentication Service](https://lobehub.com/docs/self-hosting/server-database/vercel#2-configure-authentication-service) in the Vercel deployment guide.
|
|
|
|
```shell
|
|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
|
|
CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
|
|
CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
|
|
```
|
|
|
|
## 2. Deploying the database on Dokploy
|
|
|
|
Enter the previously created Project, click on Create Service, and select Database. In the Database interface, choose PostgreSQL, then set the database name, user, and password. In the Docker image field, enter `pgvector/pgvector:pg17`, and finally click Create to create the database.
|
|
|
|

|
|
|
|
Enter the created database and set an unused port in External Credentials to allow external access; otherwise, LobeChat will not be able to connect to the database.
|
|
You can view the Postgres database connection URL in External Host, as shown below:
|
|
|
|
```shell
|
|
postgresql://postgres:wAbLxfXSwkxxxxxx@45.577.281.48:5432/postgres
|
|
```
|
|
|
|
Finally, click Deploy to deploy the database.
|
|
|
|

|
|
|
|
## Deploy LobeChat on Dokploy.
|
|
|
|
Click "Create Service", select "Application", and create the LobeChat application.
|
|
|
|

|
|
|
|
Enter the created LobeChat application, select the forked lobe-chat project and branch, and click Save to save.
|
|
|
|

|
|
|
|
Switch to the Environment section, fill in the environment variables, and click Save.
|
|
|
|

|
|
|
|
```shell
|
|
# Environment variables required for building
|
|
NIXPACKS_PKGS="pnpm bun"
|
|
NIXPACKS_INSTALL_CMD="pnpm install"
|
|
NIXPACKS_BUILD_CMD="pnpm run build"
|
|
NIXPACKS_START_CMD="pnpm start"
|
|
|
|
APP_URL=
|
|
|
|
# Set the service mode to server
|
|
NEXT_PUBLIC_SERVICE_MODE=server
|
|
|
|
# Configuration related to Postgres database
|
|
DATABASE_DRIVER=node
|
|
DATABASE_URL=
|
|
|
|
# You can use openssl rand -base64 32 to generate a random 32-character string as a key.
|
|
KEY_VAULTS_SECRET=
|
|
|
|
# Clerk related configuration
|
|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
|
|
CLERK_SECRET_KEY=
|
|
CLERK_WEBHOOK_SECRET=
|
|
|
|
# S3 related configuration
|
|
S3_ACCESS_KEY_ID=
|
|
S3_SECRET_ACCESS_KEY=
|
|
S3_ENDPOINT=
|
|
S3_BUCKET=
|
|
S3_PUBLIC_DOMAIN=
|
|
S3_ENABLE_PATH_STYLE=
|
|
|
|
# OpenAI related configuration
|
|
OPENAI_API_KEY=
|
|
OPENAI_MODEL_LIST=
|
|
OPENAI_PROXY_URL=
|
|
```
|
|
|
|
After adding the environment variables and saving, click Deploy to initiate the deployment. You can check the deployment progress and log information under Deployments.
|
|
|
|

|
|
|
|
After a successful deployment, bind your own domain to your LobeChat application and request a certificate on the Domains page.
|
|
|
|

|
|
|
|
## Check if LobeChat is working properly.
|
|
|
|
Go to your LobeChat website, and if you click on the login button in the upper left corner and the login pop-up appears normally, it means you have configured it successfully. Enjoy it to the fullest!
|
|
|
|

|