Skip to content

Commit

Permalink
📝 docs: improve docker-compose (lobehub#3661)
Browse files Browse the repository at this point in the history
* improve docker-compose

* improve docs

* improve docs

* improve docs
  • Loading branch information
arvinxx authored Aug 29, 2024
1 parent e936bfd commit 1f9eb04
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 178 deletions.
50 changes: 24 additions & 26 deletions docker-compose/local/.env.example
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
# LobeChat domain
APP_URL=https://localhost:3210
# Logto secret
LOGTO_CLIENT_ID=
LOGTO_CLIENT_SECRET=

# Postgres related, which are the necessary environment variables for DB
# Key used to encrypt sensitive information; can be generated using openssl rand -base64 32
KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ=
# Postgres database connection string
# Format: postgres://username:password@host:port/dbname; if your pg instance is a Docker container, use the container name
DATABASE_URL=postgresql://postgres:uWNZugjBqixf8dxC@postgresql:5432/postgres

# NEXT_AUTH related; can use auth0, Azure AD, GitHub, Authentik, Zitadel, Logto, etc. If you have other integration requests, feel free to submit a PR.
# Here we take Logto as an example
NEXT_AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg
NEXT_AUTH_SSO_PROVIDERS=logto
NEXTAUTH_URL=http://localhost:3210/api/auth
LOGTO_CLIENT_ID=YOUR_LOGTO_CLIENT_ID
LOGTO_CLIENT_SECRET=YOUR_LOGTO_CLIENT_SECRET
LOGTO_ISSUER=http://localhost:3001/oidc
# Note: If you have ACCESS_CODE, be sure to clear it. We use NEXT_AUTH as the only authentication source.
# Proxy, if you need it (e.g., if you use GitHub as an authentication service provider)
# MinIO S3 configuration
MINIO_ROOT_USER=YOUR_MINIO_USER
MINIO_ROOT_PASSWORD=YOUR_MINIO_PASSWORD

# 在下方配置 minio 中添加的桶
MINIO_LOBE_BUCKET=lobe
S3_ACCESS_KEY_ID=
S3_SECRET_ACCESS_KEY=

# Proxy, if you need it
# HTTP_PROXY=http://localhost:7890
# HTTPS_PROXY=http://localhost:7890

# MinIO S3 configuration
S3_ACCESS_KEY_ID=YOUR_S3_ACCESS_KEY_ID # Invalid until manually created in MinIO UI
S3_SECRET_ACCESS_KEY=YOUR_S3_SECRET_ACCESS_KEY # Invalid until manually created in MinIO UI
S3_ENDPOINT=http://localhost:9000
S3_BUCKET=lobe # Invalid until manually created in MinIO UI
S3_ENDPOINT=http://localhost:9000
S3_ENABLE_PATH_STYLE=1

# Other environment variables, as needed. You can refer to the environment variables configuration for the client version, making sure not to have ACCESS_CODE.
# OPEANAI_API_KEY=sk-xxxx
# OPENAI_PROXY_URL=https://api.openai.com/v1
# OPENAI_MODEL_LIST=...


# ----- Other config -----
# if no special requirements, no need to change
LOBE_PORT=3210
LOGTO_PORT=3001
MINIO_PORT=9000

# Postgres related, which are the necessary environment variables for DB
LOBE_DB_NAME=lobechat
POSTGRES_PASSWORD=uWNZugjBqixf8dxC
50 changes: 24 additions & 26 deletions docker-compose/local/.env.zh-CN.example
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
# LobeChat 域名
APP_URL=https://localhost:3210
# Logto secret
LOGTO_CLIENT_ID=
LOGTO_CLIENT_SECRET=

# MinIO S3 配置
MINIO_ROOT_USER=YOUR_MINIO_USER
MINIO_ROOT_PASSWORD=YOUR_MINIO_PASSWORD

# 在下方配置 minio 中添加的桶
MINIO_LOBE_BUCKET=lobe
S3_ACCESS_KEY_ID=
S3_SECRET_ACCESS_KEY=


# Postgres 相关,也即 DB 必须的环境变量
# 用于加密敏感信息的密钥,可以使用 openssl rand -base64 32 生成
KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ=
# Postgres 数据库连接字符串
# 格式:postgres://username:password@host:port/dbname,如果你的 pg 实例与 LobeChat 服务在同一 Docker 网络中,可以使用容器名作为 host
DATABASE_URL=postgresql://postgres:uWNZugjBqixf8dxC@localhost:5432/postgres

# NEXT_AUTH 相关,可以使用 auth0、Azure AD、GitHub、Authentik、Zitadel、Logto 等,如有其他接入诉求欢迎提 PR
# 这里以 Logto 为例
NEXT_AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg
NEXT_AUTH_SSO_PROVIDERS=logto
NEXTAUTH_URL=http://localhost:3210/api/auth
LOGTO_CLIENT_ID=YOUR_LOGTO_CLIENT_ID
LOGTO_CLIENT_SECRET=YOUR_LOGTO_CLIENT_SECRET
LOGTO_ISSUER=http://localhost:3001/oidc
# 注:如果你有 ACCESS_CODE,请务必清空,我们以 NEXT_AUTH 作为唯一鉴权来源
# Proxy,如果你需要的话(比如你使用 GitHub 作为鉴权服务提供商)
# HTTP_PROXY=http://localhost:7890
# HTTPS_PROXY=http://localhost:7890

# MinIO S3 配置
S3_ACCESS_KEY_ID=YOUR_S3_ACCESS_KEY_ID # 直到在 MinIO UI 中手动创建之前都是无效的
S3_SECRET_ACCESS_KEY=YOUR_S3_SECRET_ACCESS_KEY # 直到在 MinIO UI 中手动创建之前都是无效的
S3_ENDPOINT=http://localhost:9000
S3_BUCKET=lobe # 直到在 MinIO UI 中手动创建之前都是无效的
S3_PUBLIC_DOMAIN=http://localhost:9000
S3_ENABLE_PATH_STYLE=1

# 其他环境变量,视需求而定,可以参照客户端版本的环境变量配置,注意不要有 ACCESS_CODE
# OPEANAI_API_KEY=sk-xxxx
# OPENAI_PROXY_URL=https://api.openai.com/v1
# OPENAI_MODEL_LIST=...


# ----- 相关配置 start -----
# 如没有特殊需要不用更改
LOBE_PORT=3210
LOGTO_PORT=3001
MINIO_PORT=9000

# Postgres 相关,也即 DB 必须的环境变量
LOBE_DB_NAME=lobechat
POSTGRES_PASSWORD=uWNZugjBqixf8dxC
72 changes: 55 additions & 17 deletions docker-compose/local/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,92 @@
services:
network-service:
image: alpine
container_name: lobe-network
ports:
- '${MINIO_PORT}:${MINIO_PORT}' # MinIO API
- '9001:9001' # MinIO Console
- '${LOGTO_PORT}:${LOGTO_PORT}' # Logto
- '3002:3002' # Logto Admin
- '${LOBE_PORT}:3210' # LobeChat
command: tail -f /dev/null
networks:
- lobe-network

postgresql:
image: pgvector/pgvector:pg16
container_name: lobe-postgres
network_mode: 'host'
ports:
- "5432:5432"
volumes:
- './data:/var/lib/postgresql/data'
environment:
- 'POSTGRES_DB=lobe'
- 'POSTGRES_PASSWORD=uWNZugjBqixf8dxC'
- 'POSTGRES_DB=${LOBE_DB_NAME}'
- 'POSTGRES_PASSWORD=${POSTGRES_PASSWORD}'
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 5s
timeout: 5s
retries: 5
restart: always
networks:
- lobe-network

minio:
image: minio/minio
container_name: lobe-minio
network_mode: 'host'
network_mode: 'service:network-service'
volumes:
- './s3_data:/etc/minio/data'
environment:
- 'MINIO_ROOT_USER=YOUR_MINIO_USER'
- 'MINIO_ROOT_PASSWORD=YOUR_MINIO_PASSWORD'
- 'MINIO_DOMAIN=localhost:9000'
- 'MINIO_API_CORS_ALLOW_ORIGIN=http://localhost:3210'
- 'MINIO_ROOT_USER=${MINIO_ROOT_USER}'
- 'MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD}'
- 'MINIO_API_CORS_ALLOW_ORIGIN=http://localhost:${LOBE_PORT}'
restart: always
command: >
server /etc/minio/data --address ":9000" --console-address ":9001"
server /etc/minio/data --address ":${MINIO_PORT}" --console-address ":9001"
logto:
image: svhd/logto
container_name: lobe-logto
network_mode: 'host'
network_mode: 'service:network-service'
depends_on:
postgresql:
condition: service_healthy
environment:
- 'TRUST_PROXY_HEADER=1'
- 'DB_URL=postgresql://postgres:uWNZugjBqixf8dxC@localhost:5432/logto'
- 'ENDPOINT=http://localhost:3001'
- 'PORT=${LOGTO_PORT}'
- 'DB_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgresql:5432/logto'
- 'ENDPOINT=http://localhost:${LOGTO_PORT}'
- 'ADMIN_ENDPOINT=http://localhost:3002'
entrypoint: ['sh', '-c', 'npm run cli db seed -- --swe && npm start']


lobe:
image: lobehub/lobe-chat-database
container_name: lobe-database
network_mode: 'host'
network_mode: 'service:network-service'
depends_on:
- postgresql
- minio
- logto
postgresql:
condition: service_healthy
network-service:
condition: service_started
minio:
condition: service_started
logto:
condition: service_started

environment:
- 'APP_URL=http://localhost:3210'
- 'NEXT_AUTH_SSO_PROVIDERS=logto'
- 'KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ='
- 'NEXT_AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg'
- 'NEXTAUTH_URL=http://localhost:${LOBE_PORT}/api/auth'
- 'LOGTO_ISSUER=http://localhost:${LOGTO_PORT}/oidc'
- 'DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgresql:5432/${LOBE_DB_NAME}'
- 'S3_ENDPOINT=http://localhost:${MINIO_PORT}'
- 'S3_BUCKET=${MINIO_LOBE_BUCKET}'
- 'S3_PUBLIC_DOMAIN=http://localhost:${MINIO_PORT}'
- 'S3_ENABLE_PATH_STYLE=1'
env_file:
- .env
restart: always
Expand All @@ -62,3 +96,7 @@ volumes:
driver: local
s3_data:
driver: local

networks:
lobe-network:
driver: bridge
Loading

0 comments on commit 1f9eb04

Please sign in to comment.