add install-lobechat-db
This commit is contained in:
@@ -598,6 +598,7 @@ enableEmoji = true
|
|||||||
TryHackMe = ""
|
TryHackMe = ""
|
||||||
Douyin = ""
|
Douyin = ""
|
||||||
TikTok = ""
|
TikTok = ""
|
||||||
|
Credly = ""
|
||||||
Phone = ""
|
Phone = ""
|
||||||
Email = "jamesflare1212@gmail.com"
|
Email = "jamesflare1212@gmail.com"
|
||||||
RSS = true
|
RSS = true
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ author:
|
|||||||
link: https://www.jamesflare.com
|
link: https://www.jamesflare.com
|
||||||
email:
|
email:
|
||||||
avatar: /site-logo.avif
|
avatar: /site-logo.avif
|
||||||
description: This blog post introduces a Python programming assignment for analyzing and comparing text documents using natural language processing techniques, such as calculating word length, distinct word ratios, and Jaccard similarity between word sets and pairs.
|
description: This blog post provides a detailed guide on completing Homework 8 for CSCI 1100, focusing on simulating a berry field with bears and tourists using Python classes. It covers the creation of BerryField, Bear, and Tourist classes, and instructions for submitting the assignment.
|
||||||
keywords: ["Python", "Classes", "Simulation", "Homework 8"]
|
keywords: ["Python", "Classes", "Simulation", "Homework 8"]
|
||||||
license:
|
license:
|
||||||
comment: true
|
comment: true
|
||||||
@@ -35,7 +35,7 @@ resources:
|
|||||||
- name: featured-image-preview
|
- name: featured-image-preview
|
||||||
src: featured-image-preview.jpg
|
src: featured-image-preview.jpg
|
||||||
toc: true
|
toc: true
|
||||||
math: true
|
math: false
|
||||||
lightgallery: false
|
lightgallery: false
|
||||||
password:
|
password:
|
||||||
message:
|
message:
|
||||||
@@ -70,7 +70,7 @@ You will need to write at least three classes for this assignment corresponding
|
|||||||
|
|
||||||
### BerryField
|
### BerryField
|
||||||
|
|
||||||
The BerryField class must maintain and manage the location of berries as a square Row X Column grid with (0,0) being the upper left corner and (N-1, N-1) being the lower right corner. Each space holds 0-10 berry units.
|
The `BerryField` class must maintain and manage the location of berries as a square Row X Column grid with (0,0) being the upper left corner and (N-1, N-1) being the lower right corner. Each space holds 0-10 berry units.
|
||||||
|
|
||||||
- The initializer class must, minimally, be able to take in a grid of values (think of our Sudoku lab) and use it to create a berry field with the values contained in the grid.
|
- The initializer class must, minimally, be able to take in a grid of values (think of our Sudoku lab) and use it to create a berry field with the values contained in the grid.
|
||||||
- The string function must, minimally, be able to generate a string of the current state of the berry patch. Each block in the grid must be formatted with the `"{:>4}"` format specifier. If there is a bear at the location, the grid should have a `"B"`; if there is a tourist, the grid should have a `"T"`; and if there is both a bear and a tourist, the grid should have an `"X"`. If there is neither a bear nor a tourist, it should have the number of berries at the location.
|
- The string function must, minimally, be able to generate a string of the current state of the berry patch. Each block in the grid must be formatted with the `"{:>4}"` format specifier. If there is a bear at the location, the grid should have a `"B"`; if there is a tourist, the grid should have a `"T"`; and if there is both a bear and a tourist, the grid should have an `"X"`. If there is neither a bear nor a tourist, it should have the number of berries at the location.
|
||||||
@@ -146,7 +146,7 @@ As you go, report on any tourists or bears that leave or enter the field. Name y
|
|||||||
|
|
||||||
## Supporting Files
|
## Supporting Files
|
||||||
|
|
||||||
{{< link href="HW6.zip" content="HW6.zip" title="Download HW6.zip" download="HW6.zip" card=true >}}
|
{{< link href="HW8.zip" content="HW8.zip" title="Download HW8.zip" download="HW8.zip" card=true >}}
|
||||||
|
|
||||||
## Solution
|
## Solution
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
slug: "excalidraw-full-stack-docker"
|
slug: "excalidraw-full-stack-docker"
|
||||||
title: "Excalidraw Full-Stack Self-Deployment"
|
title: "Deploying a Full-stack Excalidraw Using Docker"
|
||||||
subtitle: ""
|
subtitle: ""
|
||||||
date: 2023-01-13T15:54:36+08:00
|
date: 2023-01-13T15:54:36+08:00
|
||||||
lastmod: 2024-03-11T12:39:36-05:00
|
lastmod: 2024-03-11T12:39:36-05:00
|
||||||
@@ -23,7 +23,8 @@ tags:
|
|||||||
categories:
|
categories:
|
||||||
- Tutorials
|
- Tutorials
|
||||||
- Sharing
|
- Sharing
|
||||||
|
collections:
|
||||||
|
- Docker Compose
|
||||||
hiddenFromHomePage: false
|
hiddenFromHomePage: false
|
||||||
hiddenFromSearch: false
|
hiddenFromSearch: false
|
||||||
|
|
||||||
|
|||||||
371
content/en/posts/docker-compose/lobechat-db/index.md
Normal file
371
content/en/posts/docker-compose/lobechat-db/index.md
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
---
|
||||||
|
title: Use Docker Compose to Deploy the LobeChat Server Database Version
|
||||||
|
subtitle:
|
||||||
|
date: 2024-09-15T04:52:21-04:00
|
||||||
|
slug: install-lobechat-db
|
||||||
|
draft: false
|
||||||
|
author:
|
||||||
|
name: James
|
||||||
|
link: https://www.jamesflare.com
|
||||||
|
email:
|
||||||
|
avatar: /site-logo.avif
|
||||||
|
description: This blog post offers a comprehensive guide on setting up LobeChat DB version, including configuring Logto for authentication, MinIO for S3 storage, and PostgreSQL for the database. It also covers customizing Logto's sign-in experience and enabling various models for LobeChat.
|
||||||
|
keywords: ["LobeChat", "Logto", "MinIO", "PostgreSQL", "Docker", "S3 Storage", "Authentication", "Database Configuration"]
|
||||||
|
license:
|
||||||
|
comment: true
|
||||||
|
weight: 0
|
||||||
|
tags:
|
||||||
|
- Open Source
|
||||||
|
- LobeChat
|
||||||
|
- Docker
|
||||||
|
categories:
|
||||||
|
- Tutorials
|
||||||
|
- Sharing
|
||||||
|
collections:
|
||||||
|
- Docker Compose
|
||||||
|
hiddenFromHomePage: false
|
||||||
|
hiddenFromSearch: false
|
||||||
|
hiddenFromRss: false
|
||||||
|
hiddenFromRelated: false
|
||||||
|
summary: This blog post offers a comprehensive guide on setting up LobeChat DB version, including configuring Logto for authentication, MinIO for S3 storage, and PostgreSQL for the database. It also covers customizing Logto's sign-in experience and enabling various models for LobeChat.
|
||||||
|
resources:
|
||||||
|
- name: featured-image
|
||||||
|
src: featured-image.jpg
|
||||||
|
- name: featured-image-preview
|
||||||
|
src: featured-image-preview.jpg
|
||||||
|
toc: true
|
||||||
|
math: false
|
||||||
|
lightgallery: false
|
||||||
|
password:
|
||||||
|
message:
|
||||||
|
repost:
|
||||||
|
enable: false
|
||||||
|
url:
|
||||||
|
|
||||||
|
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
|
## Before Start
|
||||||
|
|
||||||
|
LobeChat defaults to using IndexedDB to store user data, which means the data is stored locally in the browser. This results in the inability to synchronize data across multiple devices and the risk of data loss. At the same time, LobeChat has a server-side database version that addresses the aforementioned issues and also enables the use of a knowledge base feature.
|
||||||
|
|
||||||
|
However, configuring the LobeChat DB version is not straightforward. It involves several parts: configuring the database, setting up the authentication service, and configuring the S3 storage service [^1].
|
||||||
|
|
||||||
|
[^1]: Refer to the official documentation https://lobehub.com/en/docs/self-hosting/server-database
|
||||||
|
|
||||||
|
## Configuring Logto
|
||||||
|
|
||||||
|
I recommend deploying the Logto service separately, as it may also be used in other projects and can be managed independently.
|
||||||
|
|
||||||
|
First, create a new directory and navigate into it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir logto
|
||||||
|
cd logto
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is my `docker-compose.yaml` file, which you can refer to and modify the relevant parts to suit your own needs:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
|
||||||
|
postgresql:
|
||||||
|
image: postgres:16
|
||||||
|
container_name: logto-postgres
|
||||||
|
volumes:
|
||||||
|
- './data:/var/lib/postgresql/data'
|
||||||
|
environment:
|
||||||
|
- 'POSTGRES_DB=logto'
|
||||||
|
- 'POSTGRES_PASSWORD=logto'
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
logto:
|
||||||
|
image: svhd/logto:latest
|
||||||
|
container_name: logto
|
||||||
|
ports:
|
||||||
|
- '127.0.0.1:3034:3034'
|
||||||
|
- '127.0.0.1:3035:3035'
|
||||||
|
depends_on:
|
||||||
|
postgresql:
|
||||||
|
condition: service_healthy
|
||||||
|
environment:
|
||||||
|
- 'PORT=3034'
|
||||||
|
- 'ADMIN_PORT=3035'
|
||||||
|
- 'TRUST_PROXY_HEADER=1'
|
||||||
|
- 'DB_URL=postgresql://postgres:logto@postgresql:5432/logto'
|
||||||
|
- 'ENDPOINT=https://logto.example.com'
|
||||||
|
- 'ADMIN_ENDPOINT=https://logto-admin.example.com'
|
||||||
|
entrypoint: ['sh', '-c', 'npm run cli db seed -- --swe && npm start']
|
||||||
|
```
|
||||||
|
|
||||||
|
After making the modifications, write them into the `docker-compose.yaml` file. Then, run the container:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Remember to configure the reverse proxy correctly. This proxy must support HTTPS because Logto's various APIs must run in a secure environment, otherwise, errors will occur [^2]. Moreover, simply having HTTPS is not enough; you must also set the value of the `X-Forwarded-Proto` header to `https` to inform Logto that the user is accessing via HTTPS. I use Nginx as the reverse proxy service, and the following configuration can be referenced. Remember to modify the content according to your situation (e.g., `proxy_pass`).
|
||||||
|
|
||||||
|
[^2]: Discussion on errors https://github.com/logto-io/logto/issues/4279
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto https;
|
||||||
|
|
||||||
|
proxy_pass http://127.0.0.1:3034;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Additionally, this is just a small part of the configuration. If you are manually crafting the Nginx configuration file rather than managing it through a graphical tool like Nginx Proxy Manager, you will need to complete the other parts yourself. Do not simply copy and paste. In other words, if you are using Nginx Proxy Manager, you can directly copy the modified `proxy_pass` into the corresponding reverse proxy's Advanced configuration box.
|
||||||
|
|
||||||
|
Afterward, you can visit the ADMIN_ENDPOINT to complete registration and configuration (the first registered account will automatically become an administrator). Remember to add an Application (in preparation for the installation of the LobeChat DB version), and the type can be selected as Next.js (App Router). There are several key parameters that should not be written incorrectly (replace the domain name with your own LobeChat DB version instance):
|
||||||
|
|
||||||
|
- `Redirect URIs` write `https://lobe.example.com/api/auth/callback/logto`
|
||||||
|
- `Post sign-out redirect URIs` write `https://lobe.example.com/`
|
||||||
|
- `CORS allowed origins` write `https://lobe.example.com`
|
||||||
|
|
||||||
|
There are three parameters that we will use later in the configuration of the LobeChat DB version: Issuer endpoint, App ID, and App secrets (this needs to be added). You can take note of them.
|
||||||
|
|
||||||
|
You can also visit the user ENDPOINT's `/demo-app` path to test login, registration, and other functions to see if they are working properly. If everything is OK, then Logto is fine, and you can proceed with the following tasks.
|
||||||
|
|
||||||
|
## Configuring MinIO
|
||||||
|
|
||||||
|
I also recommend deploying MinIO separately, as it can be used for other projects.
|
||||||
|
|
||||||
|
Create a directory and navigate into it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir minio
|
||||||
|
cd minio
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is my `docker-compose.yaml` file, which you can refer to:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
|
||||||
|
minio:
|
||||||
|
image: quay.io/minio/minio
|
||||||
|
container_name: minio
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- MINIO_DOMAIN=minio.example.com
|
||||||
|
- MINIO_SERVER_URL=https://minio.example.com
|
||||||
|
- MINIO_BROWSER_REDIRECT_URL=https://console.minio.example.com
|
||||||
|
- MINIO_ROOT_USER=xxxx #change it
|
||||||
|
- MINIO_ROOT_PASSWORD=xxxxx #change it
|
||||||
|
ports:
|
||||||
|
- "9000:9000"
|
||||||
|
- "9090:9090"
|
||||||
|
volumes:
|
||||||
|
- ./data:/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 20s
|
||||||
|
retries: 3
|
||||||
|
command: server /data --console-address ":9090"
|
||||||
|
```
|
||||||
|
|
||||||
|
After making the modifications, write them into the `docker-compose.yaml` file. Then, run the container:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, log in to your MinIO instance from your MINIO_BROWSER_REDIRECT_URL, create a Bucket, and name it `lobe` as an example. If you change it to something else, remember to modify the corresponding configuration files.
|
||||||
|
|
||||||
|
In the Access Policy, choose Custom and fill in a configuration similar to the following (using `lobe` as the Bucket name):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Version": "2012-10-17",
|
||||||
|
"Statement": [
|
||||||
|
{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Principal": {
|
||||||
|
"AWS": [
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Action": [
|
||||||
|
"s3:GetBucketLocation"
|
||||||
|
],
|
||||||
|
"Resource": [
|
||||||
|
"arn:aws:s3:::lobe"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Principal": {
|
||||||
|
"AWS": [
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Action": [
|
||||||
|
"s3:ListBucket"
|
||||||
|
],
|
||||||
|
"Resource": [
|
||||||
|
"arn:aws:s3:::lobe"
|
||||||
|
],
|
||||||
|
"Condition": {
|
||||||
|
"StringEquals": {
|
||||||
|
"s3:prefix": [
|
||||||
|
"files/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Principal": {
|
||||||
|
"AWS": [
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Action": [
|
||||||
|
"s3:DeleteObject",
|
||||||
|
"s3:GetObject",
|
||||||
|
"s3:PutObject"
|
||||||
|
],
|
||||||
|
"Resource": [
|
||||||
|
"arn:aws:s3:::lobe/files/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, go to Access Keys and create a token. Please save the values here, as they will be used in the subsequent configuration of the LobeChat DB version.
|
||||||
|
|
||||||
|
## Configuring the LobeChat DB Version
|
||||||
|
|
||||||
|
Next, we will start configuring the LobeChat DB version. First, create a directory and navigate into it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir lobe-db
|
||||||
|
cd lobe-db
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is the `docker-compose.yaml` configuration file I use. Remember to modify it to your values:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
|
||||||
|
postgresql:
|
||||||
|
image: pgvector/pgvector:pg16
|
||||||
|
container_name: lobe-postgres
|
||||||
|
volumes:
|
||||||
|
- './data:/var/lib/postgresql/data'
|
||||||
|
environment:
|
||||||
|
- 'POSTGRES_DB=lobe-db'
|
||||||
|
- 'POSTGRES_PASSWORD=lobe-db'
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
lobe:
|
||||||
|
image: lobehub/lobe-chat-database
|
||||||
|
container_name: lobe-database
|
||||||
|
ports:
|
||||||
|
- 127.0.0.1:3033:3210
|
||||||
|
depends_on:
|
||||||
|
postgresql:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
environment:
|
||||||
|
- 'APP_URL=https://lobe-db.example.com'
|
||||||
|
- 'NEXT_AUTH_SSO_PROVIDERS=logto'
|
||||||
|
- 'KEY_VAULTS_SECRET=NIdSgLKmeFhWmTuQKQYzn99oYk64aY0JTSssZuiWR8A=' #generate using `openssl rand -base64 32`
|
||||||
|
- 'NEXT_AUTH_SECRET=+IHNVxT2qZpA8J+vnvuwA5Daqz4UFFJOahK6z/GsNIo=' #generate using `openssl rand -base64 32`
|
||||||
|
- 'NEXTAUTH_URL=https://lobe.example.com/api/auth'
|
||||||
|
- 'LOGTO_ISSUER=https://logto.example.com/oidc' #Issuer endpoint
|
||||||
|
- 'LOGTO_CLIENT_ID=xxxx' #App ID
|
||||||
|
- 'LOGTO_CLIENT_SECRET=xxxx' #App secrets
|
||||||
|
- 'DATABASE_URL=postgresql://postgres:lobe-db@postgresql:5432/lobe-db'
|
||||||
|
- 'POSTGRES_PASSWORD=lobe-db'
|
||||||
|
- 'LOBE_DB_NAME=lobe-db'
|
||||||
|
- 'S3_ENDPOINT=https://minio.example.com'
|
||||||
|
- 'S3_BUCKET=lobe'
|
||||||
|
- 'S3_PUBLIC_DOMAIN=https://minio.example.com'
|
||||||
|
- 'S3_ACCESS_KEY_ID=xxxxx'
|
||||||
|
- 'S3_SECRET_ACCESS_KEY=xxxxxx'
|
||||||
|
- 'S3_ENABLE_PATH_STYLE=1'
|
||||||
|
- 'OPENAI_API_KEY=sk-xxxxxx' #your OpenAI API Key
|
||||||
|
- 'OPENAI_PROXY_URL=https://api.openai.com/v1'
|
||||||
|
- 'OPENAI_MODEL_LIST=-all,+gpt-4o,+gpt-4o-mini,+claude-3-5-sonnet-20240620,+deepseek-chat,+o1-preview,+o1-mini' #change on your own needs, see https://lobehub.com/zh/docs/self-hosting/environment-variables/model-provider#openai-model-list
|
||||||
|
restart: always
|
||||||
|
```
|
||||||
|
|
||||||
|
For security reasons, `KEY_VAULTS_SECRET` and `NEXT_AUTH_SECRET` need to be a random 32-character string, which can be generated by running the command `openssl rand -base64 32`.
|
||||||
|
|
||||||
|
Then, change the domain names in the environment variables to your own. In addition, there are several Logto values, which are related as follows:
|
||||||
|
|
||||||
|
- `Issuer endpoint` corresponds to `LOGTO_ISSUER`
|
||||||
|
- `App ID` corresponds to `LOGTO_CLIENT_ID`
|
||||||
|
- `App secrets` corresponds to `LOGTO_CLIENT_SECRET`
|
||||||
|
|
||||||
|
These can all be found on the created Application page.
|
||||||
|
|
||||||
|
Regarding the S3 configuration, remember to modify it, such as `S3_ENDPOINT`, `S3_BUCKET`, `S3_PUBLIC_DOMAIN`, `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY`. As for `S3_ENABLE_PATH_STYLE`, it is generally `1`. If your S3 provider uses virtual-host, change it to `0`.
|
||||||
|
|
||||||
|
{{< admonition type=question title="What is the difference between path-style and virtual-host?" open=true >}}
|
||||||
|
path-style and virtual-host are different ways to access buckets and objects in S3, with different URL structures and domain name resolutions.
|
||||||
|
|
||||||
|
Assuming the S3 provider's domain is s3.example.net, the bucket is mybucket, and the object is config.env, the specific differences are as follows:
|
||||||
|
|
||||||
|
- path-style: s3.example.net/mybucket/config.env
|
||||||
|
- virtual-host: mybucket.s3.example.net/config.env
|
||||||
|
{{< /admonition >}}
|
||||||
|
|
||||||
|
Finally, configure your API-related content (optional), which is exemplified in my configuration for using OpenAI. If you do not configure it on the server side, users will need to fill it in themselves on the frontend.
|
||||||
|
|
||||||
|
After making the modifications, write them into the `docker-compose.yaml` file. Then, run the container:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
In theory, you should now be able to access and use the LobeChat DB version. If you need to deploy it in a production environment, please carefully check to ensure there are no security issues. If you have any questions, feel free to comment.
|
||||||
|
|
||||||
|
## Extended Content
|
||||||
|
|
||||||
|
### Customizing Logto Login/Registration Options
|
||||||
|
|
||||||
|
In the Logto management page, you can see a Sign-in experience, where there are various customization options, such as enabling registration, disabling registration, and using social media SSO. The default Sign-up identifier is Username. I recommend changing it to Email address after configuring SMTP in Connectors, otherwise, users will not be able to retrieve their passwords via email, and forgetting the password will be problematic.
|
||||||
|
|
||||||
|
### Enabling Dark Mode for Logto Login/Registration Pages
|
||||||
|
|
||||||
|
In the Logto management page, you can see a Sign-in experience, where checking Enable dark mode will enable dark mode.
|
||||||
|
|
||||||
|
### Enabling GitHub Login/Registration Options for Logto
|
||||||
|
|
||||||
|
In the Logto management page, you can see a Connectors, where you can add GitHub in the Social connectors, and the same applies to others.
|
||||||
|
|
||||||
|
### Configuring More Models
|
||||||
|
|
||||||
|
LobeChat supports many models, and you can set different environment variables to start them. You can refer to the official documentation [LobeChat Model Service Providers - Environment Variables and Configuration](https://lobehub.com/en/docs/self-hosting/environment-variables/model-provider) for the configuration options and explanations of `OPENAI_MODEL_LIST`. Of course, there are also options for other model providers, such as DeepSeek.
|
||||||
|
|
||||||
|
Of course, you can also obtain the Model List through the API on the frontend and then select the required models.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- [Deploying Server-Side Database for LobeChat](https://lobehub.com/en/docs/self-hosting/server-database)
|
||||||
|
- [bug: use docker deploy logto v1.6 will always redirect to /unknown-session #4279](https://github.com/logto-io/logto/issues/4279)
|
||||||
|
- [Deployment | Logto docs #reverse-proxy](https://docs.logto.io/docs/recipes/deployment/#reverse-proxy)
|
||||||
|
- [Deploying LobeChat Server Database with Docker Compose](https://lobehub.com/en/docs/self-hosting/server-database/docker-compose)
|
||||||
|
- [LobeChat Model Service Providers - Environment Variables and Configuration #openai-model-list](https://lobehub.com/en/docs/self-hosting/environment-variables/model-provider#openai-model-list)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: Migrate Umami Docker From One Server to Another
|
title: Migrate the Docker-deployed Umami From One Server to Another.
|
||||||
subtitle:
|
subtitle:
|
||||||
date: 2024-03-11T18:03:39-04:00
|
date: 2024-03-11T18:03:39-04:00
|
||||||
slug: umami-docker-migration
|
slug: umami-docker-migration
|
||||||
@@ -15,12 +15,14 @@ license:
|
|||||||
comment: true
|
comment: true
|
||||||
weight: 0
|
weight: 0
|
||||||
tags:
|
tags:
|
||||||
- PostgreSQL
|
- PostgreSQL
|
||||||
- Open Source
|
- Open Source
|
||||||
- Docker
|
- Docker
|
||||||
- Umami
|
- Umami
|
||||||
categories:
|
categories:
|
||||||
- Tutorials
|
- Tutorials
|
||||||
|
collections:
|
||||||
|
- Docker Compose
|
||||||
hiddenFromHomePage: false
|
hiddenFromHomePage: false
|
||||||
hiddenFromSearch: false
|
hiddenFromSearch: false
|
||||||
hiddenFromRss: false
|
hiddenFromRss: false
|
||||||
|
|||||||
BIN
content/zh-cn/posts/csci-1100/hw-8/HW8.zip
Normal file
BIN
content/zh-cn/posts/csci-1100/hw-8/HW8.zip
Normal file
Binary file not shown.
154
content/zh-cn/posts/csci-1100/hw-8/index.md
Normal file
154
content/zh-cn/posts/csci-1100/hw-8/index.md
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
---
|
||||||
|
title: CSCI 1100 - 作业 8 - 熊、浆果与游客重聚:类
|
||||||
|
subtitle:
|
||||||
|
date: 2024-09-13T15:36:47-04:00
|
||||||
|
slug: csci-1100-hw-8
|
||||||
|
draft: false
|
||||||
|
author:
|
||||||
|
name: James
|
||||||
|
link: https://www.jamesflare.com
|
||||||
|
email:
|
||||||
|
avatar: /site-logo.avif
|
||||||
|
description: 这篇博客文章提供了关于完成 CSCI 1100 课程作业 8 的详细指南,重点介绍了如何使用 Python 类模拟一个有熊和游客的莓果田。它涵盖了 BerryField、Bear 和 Tourist 类的创建,以及提交作业的说明。
|
||||||
|
keywords: ["Python", "类", "模拟"]
|
||||||
|
license:
|
||||||
|
comment: true
|
||||||
|
weight: 0
|
||||||
|
tags:
|
||||||
|
- CSCI 1100
|
||||||
|
- 作业
|
||||||
|
- RPI
|
||||||
|
- Python
|
||||||
|
- 编程
|
||||||
|
categories:
|
||||||
|
- 编程语言
|
||||||
|
collections:
|
||||||
|
- CSCI 1100
|
||||||
|
hiddenFromHomePage: false
|
||||||
|
hiddenFromSearch: false
|
||||||
|
hiddenFromRss: false
|
||||||
|
hiddenFromRelated: false
|
||||||
|
summary: 这篇博客文章提供了关于完成 CSCI 1100 课程作业 8 的详细指南,重点介绍了如何使用 Python 类模拟一个有熊和游客的莓果田。它涵盖了 BerryField、Bear 和 Tourist 类的创建,以及提交作业的说明。
|
||||||
|
resources:
|
||||||
|
- name: featured-image
|
||||||
|
src: featured-image.jpg
|
||||||
|
- name: featured-image-preview
|
||||||
|
src: featured-image-preview.jpg
|
||||||
|
toc: true
|
||||||
|
math: false
|
||||||
|
lightgallery: false
|
||||||
|
password:
|
||||||
|
message:
|
||||||
|
repost:
|
||||||
|
enable: false
|
||||||
|
url:
|
||||||
|
|
||||||
|
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
|
## 概述
|
||||||
|
|
||||||
|
这份作业占你总作业成绩的100分,截止日期是2024年4月18日星期四晚上11:59:59。它分为三个部分。前两部分分值不高,甚至可能不计分。它们主要是为了给你提供信息,帮助你调试解决方案。请下载 `hw8_files.zip` 并将其解压到你的HW8目录中。你会在每个部分中找到数据文件和示例输出。
|
||||||
|
|
||||||
|
本次作业的目标是使用类进行编程。你将被要求编写一个模拟引擎,并使用类来封装数据和功能。你将有许多设计选择要做。虽然我们之前做过模拟,但这次会更复杂。特别重要的是,你要慢慢开始,构建一个适用于简单情况的程序,测试它,然后增加复杂性。我们将提供难度递增的测试用例。确保你慢慢开发并彻底测试。
|
||||||
|
|
||||||
|
## 提交说明
|
||||||
|
|
||||||
|
在这份作业中,你将首次向Submitty提交多个文件,这些文件共同组成一个程序。请仔细遵循以下说明。
|
||||||
|
|
||||||
|
每个部分(第一部分、第二部分和第三部分)都需要你编写一个主程序:`hw8_part1.py`、`hw8_part2.py` 和 `hw8_part3.py`。除了主文件外,你还必须为每个部分提交三个模块,每个模块封装一个类。第一个是名为 `BerryField.py` 的文件,包含你的 `BerryField` 类;第二个是名为 `Bear.py` 的文件,包含你的 `Bear` 类;第三个是名为 `Tourist.py` 的文件,包含你的 `Tourist` 类。
|
||||||
|
|
||||||
|
一如既往,确保你遵循程序结构指南。你将根据良好的程序结构和程序正确性进行评分。
|
||||||
|
|
||||||
|
同样要记住,我们将继续测试作业的相似性。因此,请遵循我们关于可接受合作水平的指南。如果你需要复习,可以从课程材料中的资源部分下载指南。我们对此非常认真,必要时会毫不犹豫地施加处罚。
|
||||||
|
|
||||||
|
## 开始
|
||||||
|
|
||||||
|
你需要为本次作业编写至少三个类,分别对应于 `BerryField`、`Bear` 和 `Tourist`。我们将给你很大的自由来组织这三个类,但每个类必须至少有一个初始化方法和一个字符串方法。其他方法由你决定。每个类描述如下。
|
||||||
|
|
||||||
|
### BerryField
|
||||||
|
|
||||||
|
`BerryField` 类必须维护和管理浆果的位置,作为一个方形行 X 列的网格,(0,0) 是左上角,(N-1, N-1) 是右下角。每个空间包含 0-10 个浆果单位。
|
||||||
|
|
||||||
|
- 初始化类必须至少能够接收一个值网格(想想我们的数独实验),并使用它创建一个包含网格中值的浆果田。
|
||||||
|
- 字符串函数必须至少能够生成当前浆果田状态的字符串。网格中的每个块必须使用 `"{:>4}"` 格式说明符进行格式化。如果该位置有熊,网格应显示 `"B"`;如果有游客,网格应显示 `"T"`;如果既有熊又有游客,网格应显示 `"X"`。如果既没有熊也没有游客,它应显示该位置的浆果数量。
|
||||||
|
- 浆果会生长。`BerryField` 类必须提供一种方法来生长浆果田。当浆果生长时,任何值为 `1 <= 浆果数量 < 10` 的位置将增加一个浆果。
|
||||||
|
- 浆果也会扩散。任何没有浆果且与有10个浆果的位置相邻的位置,在生长操作期间将获得1个浆果。
|
||||||
|
|
||||||
|
### Bear
|
||||||
|
|
||||||
|
每只熊都有一个位置和一个它们正在行走的方向。熊也非常饥饿。在你的程序中,你必须管理两组熊。第一组是当前在田野中行走的熊。第二组是等待进入田野的熊队列。
|
||||||
|
|
||||||
|
- 初始化类必须至少能够接收行和列位置以及行进方向。
|
||||||
|
- 字符串函数必须至少能够打印出熊的位置、行进方向以及熊是否在睡觉。
|
||||||
|
- 熊可以向 `北 (N)`、`南 (S)`、`东 (E)`、`西 (W)`、`东北 (NE)`、`西北 (NW)`、`东南 (SE)` 或 `西南 (SW)` 行走。一旦熊开始向某个方向行走,它永远不会转弯。
|
||||||
|
- 熊总是饥饿的。每回合,除非同一位置有游客,否则熊会吃掉该空间中所有可用的浆果,然后沿着当前方向移动到下一个空间。这种情况会持续到当前回合结束,直到熊吃了30个浆果或遇到游客。
|
||||||
|
- 对于熊和游客在同一位置的特殊情况,熊不会吃任何浆果,但游客会神秘消失,熊会睡三回合。
|
||||||
|
- 一旦熊到达田野的边界(其行或列变为-1或N),它就不再在田野中行走,不再需要考虑。
|
||||||
|
|
||||||
|
### Tourist
|
||||||
|
|
||||||
|
每个游客都有一个位置。与熊一样,你必须维护当前在田野中的游客列表和等待进入田野的游客队列。
|
||||||
|
|
||||||
|
- 初始化类必须至少能够接收行和列位置。
|
||||||
|
- 如果熊在游客当前位置的4个单位内,游客会看到熊。
|
||||||
|
- 字符串函数必须至少能够打印出游客的位置以及自上次看到熊以来经过的回合数。
|
||||||
|
- 游客会站着观看。他们不会移动,但如果以下情况发生,他们会离开田野:
|
||||||
|
1. 三回合内没有看到熊;他们会感到无聊并回家。
|
||||||
|
2. 他们同时看到三只熊;他们会感到害怕并回家。
|
||||||
|
3. 一只熊撞到他们;他们会神秘消失,不再出现在田野中。
|
||||||
|
|
||||||
|
## 执行
|
||||||
|
|
||||||
|
记得从Submitty的课程材料部分获取 `hw8_files_F19.zip`。它包含两个示例输入文件和你的程序的预期输出。
|
||||||
|
|
||||||
|
对于这份作业,初始化你的类和程序所需的所有数据都可以在JSON文件中找到。你的每个部分都应该首先询问JSON文件的名称,读取文件,然后根据读取的数据创建所需的对象。以下代码将帮助你完成这一过程。
|
||||||
|
|
||||||
|
```python
|
||||||
|
f = open("bears_and_berries_1.json")
|
||||||
|
data = json.loads(f.read())
|
||||||
|
print(data["berry_field"])
|
||||||
|
print(data["active_bears"])
|
||||||
|
print(data["reserve_bears"])
|
||||||
|
print(data["active_tourists"])
|
||||||
|
print(data["reserve_tourists"])
|
||||||
|
```
|
||||||
|
|
||||||
|
你会看到,田野是一个列表的列表,其中每个 `[row][column]` 值是该位置的浆果数量;`"active_bears"` 和 `"reserve_bears"` 条目是定义熊的三元组 `(row, column, direction)` 的列表;`"active_tourists"` 和 `"reserve_tourists"` 条目是定义游客的二元组 `(row, column)` 的列表。
|
||||||
|
|
||||||
|
## 第一部分
|
||||||
|
|
||||||
|
在第一部分中,读取JSON文件,创建你的对象,然后简单地报告模拟的初始状态,打印出浆果田、活跃的熊和活跃的游客。将你的程序命名为 `hw8_part1.py`,并连同你开发的三个类一起提交。
|
||||||
|
|
||||||
|
## 第二部分
|
||||||
|
|
||||||
|
在第二部分中,首先读取JSON文件,创建你的对象,再次打印出模拟的初始状态。然后运行五回合的模拟,步骤如下:
|
||||||
|
|
||||||
|
- 生长浆果
|
||||||
|
- 移动熊
|
||||||
|
- 检查游客
|
||||||
|
- 打印出模拟状态
|
||||||
|
|
||||||
|
不要担心备用熊或备用游客进入田野,但要报告任何离开的游客或熊。将你的程序命名为 `hw8_part2.py`,并连同你开发的三个类一起提交。
|
||||||
|
|
||||||
|
## 第三部分
|
||||||
|
|
||||||
|
在第三部分中,做你在第二部分中所做的一切,但做以下更改:
|
||||||
|
|
||||||
|
- 在检查游客后,如果备用队列中仍有熊且至少有500个浆果,将下一只备用熊添加到活跃熊中。
|
||||||
|
- 然后,如果备用队列中仍有游客且至少有一只活跃的熊,将下一只备用游客添加到田野中。
|
||||||
|
- 不要在5回合后停止,而是运行直到田野中没有更多的熊且备用列表中没有更多的熊,或者田野中没有更多的熊且没有更多的浆果。
|
||||||
|
- 最后,不要每回合报告状态,而是每5回合报告一次,并在模拟结束时再次报告。
|
||||||
|
|
||||||
|
在过程中,报告任何离开或进入田野的游客或熊。将你的程序命名为 `hw8_part3.py`,并连同你开发的三个类一起提交。
|
||||||
|
|
||||||
|
## 支持文件
|
||||||
|
|
||||||
|
{{< link href="HW8.zip" content="HW8.zip" title="下载 HW8.zip" download="HW8.zip" card=true >}}
|
||||||
|
|
||||||
|
## 解决方案
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> 我没有在这份作业中获得满分,所以我没发布解决方案。我可能会重做以获得满分解决方案。之后,我会在这里添加它。
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
slug: "excalidraw-full-stack-docker"
|
slug: "excalidraw-full-stack-docker"
|
||||||
title: "Excalidraw 全栈自部署教程"
|
title: "使用Docker部署全栈Excalidraw"
|
||||||
subtitle: ""
|
subtitle: ""
|
||||||
date: 2023-01-13T15:54:36+08:00
|
date: 2023-01-13T15:54:36+08:00
|
||||||
lastmod: 2024-03-11T12:39:36-05:00
|
lastmod: 2024-03-11T12:39:36-05:00
|
||||||
@@ -14,25 +14,23 @@ description: 本文为你提供了一份使用 Docker Compose 部署完整 Excal
|
|||||||
license: ""
|
license: ""
|
||||||
comment: true
|
comment: true
|
||||||
weight: 0
|
weight: 0
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- Excalidraw
|
- Excalidraw
|
||||||
- 开源软件
|
- 开源软件
|
||||||
- Docker
|
- Docker
|
||||||
categories:
|
categories:
|
||||||
- 教程
|
- 教程
|
||||||
- 资源分享
|
- 资源分享
|
||||||
|
collections:
|
||||||
|
- Docker Compose
|
||||||
hiddenFromHomePage: false
|
hiddenFromHomePage: false
|
||||||
hiddenFromSearch: false
|
hiddenFromSearch: false
|
||||||
|
|
||||||
summary: 通过本文,你将学会使用 Docker Compose 一键部署拥有前端界面、数据存储和多人协作等全部功能的 Excalidraw 技术栈,快速搭建一个可以私有使用、分享协作的 Excalidraw 部署。
|
summary: 通过本文,你将学会使用 Docker Compose 一键部署拥有前端界面、数据存储和多人协作等全部功能的 Excalidraw 技术栈,快速搭建一个可以私有使用、分享协作的 Excalidraw 部署。
|
||||||
resources:
|
resources:
|
||||||
- name: featured-image
|
- name: featured-image
|
||||||
src: featured-image.jpg
|
src: featured-image.jpg
|
||||||
- name: featured-image-preview
|
- name: featured-image-preview
|
||||||
src: featured-image-preview.jpg
|
src: featured-image-preview.jpg
|
||||||
|
|
||||||
toc:
|
toc:
|
||||||
enable: true
|
enable: true
|
||||||
math:
|
math:
|
||||||
@@ -40,7 +38,6 @@ math:
|
|||||||
lightgallery: true
|
lightgallery: true
|
||||||
seo:
|
seo:
|
||||||
images: []
|
images: []
|
||||||
|
|
||||||
repost:
|
repost:
|
||||||
enable: false
|
enable: false
|
||||||
url:
|
url:
|
||||||
|
|||||||
371
content/zh-cn/posts/docker-compose/lobechat-db/index.md
Normal file
371
content/zh-cn/posts/docker-compose/lobechat-db/index.md
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
---
|
||||||
|
title: 使用Docker Compose部署LobeChat服务端数据库版本
|
||||||
|
subtitle:
|
||||||
|
date: 2024-09-15T04:52:21-04:00
|
||||||
|
slug: install-lobechat-db
|
||||||
|
draft: false
|
||||||
|
author:
|
||||||
|
name: James
|
||||||
|
link: https://www.jamesflare.com
|
||||||
|
email:
|
||||||
|
avatar: /site-logo.avif
|
||||||
|
description: 这篇博客文章提供了关于设置 LobeChat DB 版本的全面指南,包括配置 Logto 进行身份验证、使用 MinIO 进行 S3 存储以及使用 PostgreSQL 作为数据库。它还涵盖了自定义 Logto 的登录体验和启用 LobeChat 的各种模型。
|
||||||
|
keywords: ["LobeChat", "Logto", "MinIO", "PostgreSQL", "Docker", "S3 存储", "身份验证", "数据库配置"]
|
||||||
|
license:
|
||||||
|
comment: true
|
||||||
|
weight: 0
|
||||||
|
tags:
|
||||||
|
- 开源软件
|
||||||
|
- Docker
|
||||||
|
- LobeChat
|
||||||
|
categories:
|
||||||
|
- 教程
|
||||||
|
- 资源分享
|
||||||
|
collections:
|
||||||
|
- Docker Compose
|
||||||
|
hiddenFromHomePage: false
|
||||||
|
hiddenFromSearch: false
|
||||||
|
hiddenFromRss: false
|
||||||
|
hiddenFromRelated: false
|
||||||
|
summary: 这篇博客文章提供了关于设置 LobeChat DB 版本的全面指南,包括配置 Logto 进行身份验证、使用 MinIO 进行 S3 存储以及使用 PostgreSQL 作为数据库。它还涵盖了自定义 Logto 的登录体验和启用 LobeChat 的各种模型。
|
||||||
|
resources:
|
||||||
|
- name: featured-image
|
||||||
|
src: featured-image.jpg
|
||||||
|
- name: featured-image-preview
|
||||||
|
src: featured-image-preview.jpg
|
||||||
|
toc: true
|
||||||
|
math: false
|
||||||
|
lightgallery: false
|
||||||
|
password:
|
||||||
|
message:
|
||||||
|
repost:
|
||||||
|
enable: false
|
||||||
|
url:
|
||||||
|
|
||||||
|
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
|
## 前言
|
||||||
|
|
||||||
|
LobeChat默认使用IndexedDB储存用户数据,换句话说就是数据储存在浏览器本地,这样就导致没法在多个设备间同步,而且有丢失的风险。与此同时,LobeChat有服务端数据库版本,它解决了上述问题的同时,还可以使用知识库功能。
|
||||||
|
|
||||||
|
不过要配置LobeChat DB版就没那么简单了,总体有这几部分:配置数据库,配置身份验证服务,配置S3存储服务[^1]。
|
||||||
|
|
||||||
|
[^1]: 参考官方文档 https://lobehub.com/zh/docs/self-hosting/server-database
|
||||||
|
|
||||||
|
## 配置Logto
|
||||||
|
|
||||||
|
我推荐单独部署Logto服务,这样也许还能用在别的项目上,可以分开管理。
|
||||||
|
|
||||||
|
首先新建一个目录,并进入
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir logto
|
||||||
|
cd logto
|
||||||
|
```
|
||||||
|
|
||||||
|
这是我的`docker-compose.yaml`文件,可以参考一下,把相应的部分改成你自己的即可。
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
|
||||||
|
postgresql:
|
||||||
|
image: postgres:16
|
||||||
|
container_name: logto-postgres
|
||||||
|
volumes:
|
||||||
|
- './data:/var/lib/postgresql/data'
|
||||||
|
environment:
|
||||||
|
- 'POSTGRES_DB=logto'
|
||||||
|
- 'POSTGRES_PASSWORD=logto'
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
logto:
|
||||||
|
image: svhd/logto:latest
|
||||||
|
container_name: logto
|
||||||
|
ports:
|
||||||
|
- '127.0.0.1:3034:3034'
|
||||||
|
- '127.0.0.1:3035:3035'
|
||||||
|
depends_on:
|
||||||
|
postgresql:
|
||||||
|
condition: service_healthy
|
||||||
|
environment:
|
||||||
|
- 'PORT=3034'
|
||||||
|
- 'ADMIN_PORT=3035'
|
||||||
|
- 'TRUST_PROXY_HEADER=1'
|
||||||
|
- 'DB_URL=postgresql://postgres:logto@postgresql:5432/logto'
|
||||||
|
- 'ENDPOINT=https://logto.example.com'
|
||||||
|
- 'ADMIN_ENDPOINT=https://logto-admin.example.com'
|
||||||
|
entrypoint: ['sh', '-c', 'npm run cli db seed -- --swe && npm start']
|
||||||
|
```
|
||||||
|
|
||||||
|
修改完后写入`docker-compose.yaml`文件。然后运行容器
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
然后记得正确配置反向代理,这个代理必须支持HTTPS,因为Logto的各项API必须跑在安全的环境下,不然就会报错[^2]。而且反向代理光有HTTPS还不行,还得把`X-Forwarded-Proto`标头的值设置成`https`来告诉Logto用户访问用的是HTTPS。我用的Nginx作为反代服务,以下配置可供参考,记得把内容按你的情况进行修改(比如`proxy_pass`)。
|
||||||
|
|
||||||
|
[^2]: 有关报错的讨论 https://github.com/logto-io/logto/issues/4279
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto https;
|
||||||
|
|
||||||
|
proxy_pass http://127.0.0.1:3034;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
还有,这是一小部分配置,如果你是完全手搓的Nginx配置文件,不是通过Nginx Proxy Manger这样的图形化工具管理的。那么你还要自行补齐其它部分,可别直接抄了。换句话说,如果你用的Nginx Proxy Manger,那么你可以在把`proxy_pass`修改后直接抄到对应反代的Advanced配置框里。
|
||||||
|
|
||||||
|
之后你可以访问ADMIN_ENDPOINT完成注册以及配置(首个注册的账户将自动成为管理员),记得添加一个Application(为LobeChat DB版的安装做准备),类型可以选Next.js (App Router)。有几个关键参数别写错了(把域名改成你自己的LobeChat DB版实例的)
|
||||||
|
|
||||||
|
- `Redirect URIs` 写 `https://lobe.example.com/api/auth/callback/logto`
|
||||||
|
- `Post sign-out redirect URIs` 写 `https://lobe.example.com/`
|
||||||
|
- `CORS allowed origins` 写 `https://lobe.example.com`
|
||||||
|
|
||||||
|
有三个参数是我们待会配置LobeChat DB版要用到的:Issuer endpoint,App ID,App secrets(这个要添加一个)。可以留意一下。
|
||||||
|
|
||||||
|
你还可以访问用户ENDPOINT的`/demo-app`路径测试登录,注册等功能是否正常。如果一切OK,那么Logto就没问题了,可以开始下面的工作了。
|
||||||
|
|
||||||
|
## 配置MinIO
|
||||||
|
|
||||||
|
我也推荐你单独部署MinIO,这样可以用于其它项目。
|
||||||
|
|
||||||
|
创建目录并进入
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir minio
|
||||||
|
cd minio
|
||||||
|
```
|
||||||
|
|
||||||
|
以下是我的`docker-compose.yaml`文件,可供参考
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
|
||||||
|
minio:
|
||||||
|
image: quay.io/minio/minio
|
||||||
|
container_name: minio
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- MINIO_DOMAIN=minio.example.com
|
||||||
|
- MINIO_SERVER_URL=https://minio.example.com
|
||||||
|
- MINIO_BROWSER_REDIRECT_URL=https://console.minio.example.com
|
||||||
|
- MINIO_ROOT_USER=xxxx #change it
|
||||||
|
- MINIO_ROOT_PASSWORD=xxxxx #change it
|
||||||
|
ports:
|
||||||
|
- "9000:9000"
|
||||||
|
- "9090:9090"
|
||||||
|
volumes:
|
||||||
|
- ./data:/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 20s
|
||||||
|
retries: 3
|
||||||
|
command: server /data --console-address ":9090"
|
||||||
|
```
|
||||||
|
|
||||||
|
修改完后写入`docker-compose.yaml`文件。然后运行容器
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
之后从你的MINIO_BROWSER_REDIRECT_URL登入你的MinIO实例,创建一个Bucket,名字这里以`lobe`为例,如果你改成别的,相应的配置文件记得修改。
|
||||||
|
|
||||||
|
在Access Policy里选择自定义,然后填入类似下面的配置文件(Bucket名以`lobe`为例)
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Version": "2012-10-17",
|
||||||
|
"Statement": [
|
||||||
|
{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Principal": {
|
||||||
|
"AWS": [
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Action": [
|
||||||
|
"s3:GetBucketLocation"
|
||||||
|
],
|
||||||
|
"Resource": [
|
||||||
|
"arn:aws:s3:::lobe"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Principal": {
|
||||||
|
"AWS": [
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Action": [
|
||||||
|
"s3:ListBucket"
|
||||||
|
],
|
||||||
|
"Resource": [
|
||||||
|
"arn:aws:s3:::lobe"
|
||||||
|
],
|
||||||
|
"Condition": {
|
||||||
|
"StringEquals": {
|
||||||
|
"s3:prefix": [
|
||||||
|
"files/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Principal": {
|
||||||
|
"AWS": [
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Action": [
|
||||||
|
"s3:DeleteObject",
|
||||||
|
"s3:GetObject",
|
||||||
|
"s3:PutObject"
|
||||||
|
],
|
||||||
|
"Resource": [
|
||||||
|
"arn:aws:s3:::lobe/files/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
然后去Access Keys里创建一个令牌,这里的值请保存好,它们会在后面的LobeChat DB版的配置里用到。
|
||||||
|
|
||||||
|
## 配置LobeChat DB版
|
||||||
|
|
||||||
|
接下来我们开始配置LobeChat DB版,首先创建一个目录并进入
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir lobe-db
|
||||||
|
cd lobe-db
|
||||||
|
```
|
||||||
|
|
||||||
|
以下是我用的`docker-compose.yaml`配置文件,记得修改成你的值。
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
|
||||||
|
postgresql:
|
||||||
|
image: pgvector/pgvector:pg16
|
||||||
|
container_name: lobe-postgres
|
||||||
|
volumes:
|
||||||
|
- './data:/var/lib/postgresql/data'
|
||||||
|
environment:
|
||||||
|
- 'POSTGRES_DB=lobe-db'
|
||||||
|
- 'POSTGRES_PASSWORD=lobe-db'
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
lobe:
|
||||||
|
image: lobehub/lobe-chat-database
|
||||||
|
container_name: lobe-database
|
||||||
|
ports:
|
||||||
|
- 127.0.0.1:3033:3210
|
||||||
|
depends_on:
|
||||||
|
postgresql:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
environment:
|
||||||
|
- 'APP_URL=https://lobe-db.example.com'
|
||||||
|
- 'NEXT_AUTH_SSO_PROVIDERS=logto'
|
||||||
|
- 'KEY_VAULTS_SECRET=NIdSgLKmeFhWmTuQKQYzn99oYk64aY0JTSssZuiWR8A=' #generate using `openssl rand -base64 32`
|
||||||
|
- 'NEXT_AUTH_SECRET=+IHNVxT2qZpA8J+vnvuwA5Daqz4UFFJOahK6z/GsNIo=' #generate using `openssl rand -base64 32`
|
||||||
|
- 'NEXTAUTH_URL=https://lobe.example.com/api/auth'
|
||||||
|
- 'LOGTO_ISSUER=https://logto.example.com/oidc' #Issuer endpoint
|
||||||
|
- 'LOGTO_CLIENT_ID=xxxx' #App ID
|
||||||
|
- 'LOGTO_CLIENT_SECRET=xxxx' #App secrets
|
||||||
|
- 'DATABASE_URL=postgresql://postgres:lobe-db@postgresql:5432/lobe-db'
|
||||||
|
- 'POSTGRES_PASSWORD=lobe-db'
|
||||||
|
- 'LOBE_DB_NAME=lobe-db'
|
||||||
|
- 'S3_ENDPOINT=https://minio.example.com'
|
||||||
|
- 'S3_BUCKET=lobe'
|
||||||
|
- 'S3_PUBLIC_DOMAIN=https://minio.example.com'
|
||||||
|
- 'S3_ACCESS_KEY_ID=xxxxx'
|
||||||
|
- 'S3_SECRET_ACCESS_KEY=xxxxxx'
|
||||||
|
- 'S3_ENABLE_PATH_STYLE=1'
|
||||||
|
- 'OPENAI_API_KEY=sk-xxxxxx' #your OpenAI API Key
|
||||||
|
- 'OPENAI_PROXY_URL=https://api.openai.com/v1'
|
||||||
|
- 'OPENAI_MODEL_LIST=-all,+gpt-4o,+gpt-4o-mini,+claude-3-5-sonnet-20240620,+deepseek-chat,+o1-preview,+o1-mini' #change on your own needs, see https://lobehub.com/zh/docs/self-hosting/environment-variables/model-provider#openai-model-list
|
||||||
|
restart: always
|
||||||
|
```
|
||||||
|
|
||||||
|
为了安全性,`KEY_VAULTS_SECRET`和`NEXT_AUTH_SECRET`需要是一个随机的32位字符串,可以运行命令`openssl rand -base64 32`生成。
|
||||||
|
|
||||||
|
然后把环境变量中的域名改成你自己的,除此之外还有几个Logto的值,它们的关系如下:
|
||||||
|
|
||||||
|
- `Issuer endpoint`对应`LOGTO_ISSUER`
|
||||||
|
- `App ID`对应`LOGTO_CLIENT_ID`
|
||||||
|
- `App secrets`对应`LOGTO_CLIENT_SECRET`
|
||||||
|
|
||||||
|
都可以在创建的Application页面中找到。
|
||||||
|
|
||||||
|
有关S3的配置,也记得修改,比如`S3_ENDPOINT`,`S3_BUCKET`,`S3_PUBLIC_DOMAIN`,`S3_ACCESS_KEY_ID`,`S3_SECRET_ACCESS_KEY`。至于`S3_ENABLE_PATH_STYLE`,一般情况下都是`1`,如果你的S3供应商用的是virtual-host,那就改成`0`。
|
||||||
|
|
||||||
|
{{< admonition type=question title=path-style和virtual-host有什么区别? open=true >}}
|
||||||
|
path-style和virtual-host在S3中是访问bucket和object的不同方式,URL的结构和域名解析不太一样
|
||||||
|
|
||||||
|
假设S3服务商的域名是s3.example.net,bucket为mybucket,object为config.env,具体区别如下:
|
||||||
|
|
||||||
|
- path-style: s3.example.net/mybucket/config.env
|
||||||
|
- virtual-host: mybucket.s3.example.net/config.env
|
||||||
|
{{< /admonition >}}
|
||||||
|
|
||||||
|
最后配置你的API相关内容(可选),我的配置里按使用OpenAI的情况举例。如果你不在服务端配置,那么用户需要在前端自己填写。
|
||||||
|
|
||||||
|
修改完后写入`docker-compose.yaml`文件。然后运行容器
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
理论上你就可以访问LobeChat DB版使用了。如果需要投入生产环境,请仔细检查,确保没什么安全问题。有疑问的话欢迎评论。
|
||||||
|
|
||||||
|
## 扩展内容
|
||||||
|
|
||||||
|
### 自定义Logto登录/注册选择
|
||||||
|
|
||||||
|
在Logto的管理页面可以看到有一个Sign-in experience,在里面有各个自定义选项,比如开启注册,关闭注册,使用社交媒体的SSO。默认的Sign-up identifier是Username,我推荐在Connectors里配置好SMTP后改成Email address,不然的话用户没办法通过邮件找回密码,忘了密码就完了。
|
||||||
|
|
||||||
|
### 开启Logto登录/注册页面的深色模式
|
||||||
|
|
||||||
|
在Logto的管理页面可以看到有一个Sign-in experience,勾选里面的Enable dark mode就开启了深色模式。
|
||||||
|
|
||||||
|
### 开启Logto的GitHub登录/注册选项
|
||||||
|
|
||||||
|
在Logto的管理页面可以看到有一个Connectors,在Social connectors里添加GitHub即可,其它的也同理。
|
||||||
|
|
||||||
|
### 配置更多模型
|
||||||
|
|
||||||
|
LobeChat支持很多很多模型,你可以设置不同的环境变量以启动,可以看看官方文档 [LobeChat 模型服务商相关环境变量配置指南](https://lobehub.com/zh/docs/self-hosting/environment-variables/model-provider) 中对`OPENAI_MODEL_LIST`的配置选项以及说明。当然也有其它模型供应商的选项,比如DeepSeek等。
|
||||||
|
|
||||||
|
当然,你可以可以在前端通过API获取Model List,然后选择需要的模型。
|
||||||
|
|
||||||
|
## 参考内容
|
||||||
|
|
||||||
|
- [使用服务端数据库部署 - 配置数据库、身份验证服务和 S3 存储服务](https://lobehub.com/zh/docs/self-hosting/server-database)
|
||||||
|
- [bug: use docker deploy logto v1.6 will always redirect to /unknown-session #4279](https://github.com/logto-io/logto/issues/4279)
|
||||||
|
- [Deployment | Logto docs #reverse-proxy](https://docs.logto.io/docs/recipes/deployment/#reverse-proxy)
|
||||||
|
- [通过 Docker Compose 部署 LobeChat](https://lobehub.com/zh/docs/self-hosting/server-database/docker-compose)
|
||||||
|
- [LobeChat 模型服务商相关环境变量配置指南 #openai-model-list](https://lobehub.com/zh/docs/self-hosting/environment-variables/model-provider#openai-model-list)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: 将 Umami Docker 从一台服务器迁移到另一台服务器
|
title: 将Docker部署的Umami从一台服务器迁移到另一台服务器
|
||||||
subtitle:
|
subtitle:
|
||||||
date: 2024-03-11T18:03:39-04:00
|
date: 2024-03-11T18:03:39-04:00
|
||||||
slug: umami-docker-migration
|
slug: umami-docker-migration
|
||||||
@@ -14,12 +14,14 @@ license:
|
|||||||
comment: true
|
comment: true
|
||||||
weight: 0
|
weight: 0
|
||||||
tags:
|
tags:
|
||||||
- PostgreSQL
|
- PostgreSQL
|
||||||
- 开源
|
- 开源
|
||||||
- Docker
|
- Docker
|
||||||
- Umami
|
- Umami
|
||||||
categories:
|
categories:
|
||||||
- 教程
|
- 教程
|
||||||
|
collections:
|
||||||
|
- Docker Compose
|
||||||
hiddenFromHomePage: false
|
hiddenFromHomePage: false
|
||||||
hiddenFromSearch: false
|
hiddenFromSearch: false
|
||||||
hiddenFromRss: false
|
hiddenFromRss: false
|
||||||
|
|||||||
Binary file not shown.
Submodule themes/FixIt updated: 849d7d486d...9d0518eb85
Reference in New Issue
Block a user