From de0ae30ed3e228a5de5220f2da2268bbea0be2af Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 16:43:42 +0800 Subject: [PATCH 01/14] Create prod-sample.yaml --- config/prod-sample.yaml | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 config/prod-sample.yaml diff --git a/config/prod-sample.yaml b/config/prod-sample.yaml new file mode 100644 index 0000000..d00250f --- /dev/null +++ b/config/prod-sample.yaml @@ -0,0 +1,49 @@ +# 生产环境docker示例配置 +client: + port: 5001 + assetPrefix: '/' + apiUrl: 'http://localhost:5002/api' + collaborationUrl: 'ws://localhost:5003' + # 以下为页面 meta 配置 + seoAppName: '云策文档' + seoDescription: '云策文档是一款开源知识管理工具。通过独立的知识库空间,结构化地组织在线协作文档,实现知识的积累与沉淀,促进知识的复用与流通。' + seoKeywords: '云策文档,协作,文档,前端面试题,fantasticit,https://github.com/fantasticit/think' + # 预先连接的来源,空格分割(比如图片存储服务器) + dnsPrefetch: '//wipi.oss-cn-shanghai.aliyuncs.com' + +server: + prefix: '/api' + port: 5002 + collaborationPort: 5003 + maxDocumentVersion: 20 # 最大版本记录数 + logRetainDays: 3 # 日志保留天数,比如只保留近三天日志 + +# 数据库配置 +db: + mysql: + host: 'mysql-with-think' + username: 'jonnyan404' + password: 'www.mrdoc.fun' + database: 'think' + port: 3306 + charset: 'utf8mb4' + timezone: '+08:00' + synchronize: true + redis: + host: '127.0.0.1' + port: '6379' + password: '' + +# oss 文件存储服务 +oss: + aliyun: + accessKeyId: '' + accessKeySecret: '' + bucket: '' + https: true + region: '' + +# jwt 配置 +jwt: + secretkey: 'zA_Think+KNOWLEDGE+WIKI+DOCUMENTS@2022' + expiresIn: '6h' From 9767383690d6d7a85ccda63b332e32e633217c6b Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 16:49:31 +0800 Subject: [PATCH 02/14] Create Dockerfile --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1 @@ + From b1828426388c96463bb41c165cf36d2a4b1baa39 Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 16:50:54 +0800 Subject: [PATCH 03/14] Delete prod-sample.yaml --- config/prod-sample.yaml | 49 ----------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 config/prod-sample.yaml diff --git a/config/prod-sample.yaml b/config/prod-sample.yaml deleted file mode 100644 index d00250f..0000000 --- a/config/prod-sample.yaml +++ /dev/null @@ -1,49 +0,0 @@ -# 生产环境docker示例配置 -client: - port: 5001 - assetPrefix: '/' - apiUrl: 'http://localhost:5002/api' - collaborationUrl: 'ws://localhost:5003' - # 以下为页面 meta 配置 - seoAppName: '云策文档' - seoDescription: '云策文档是一款开源知识管理工具。通过独立的知识库空间,结构化地组织在线协作文档,实现知识的积累与沉淀,促进知识的复用与流通。' - seoKeywords: '云策文档,协作,文档,前端面试题,fantasticit,https://github.com/fantasticit/think' - # 预先连接的来源,空格分割(比如图片存储服务器) - dnsPrefetch: '//wipi.oss-cn-shanghai.aliyuncs.com' - -server: - prefix: '/api' - port: 5002 - collaborationPort: 5003 - maxDocumentVersion: 20 # 最大版本记录数 - logRetainDays: 3 # 日志保留天数,比如只保留近三天日志 - -# 数据库配置 -db: - mysql: - host: 'mysql-with-think' - username: 'jonnyan404' - password: 'www.mrdoc.fun' - database: 'think' - port: 3306 - charset: 'utf8mb4' - timezone: '+08:00' - synchronize: true - redis: - host: '127.0.0.1' - port: '6379' - password: '' - -# oss 文件存储服务 -oss: - aliyun: - accessKeyId: '' - accessKeySecret: '' - bucket: '' - https: true - region: '' - -# jwt 配置 -jwt: - secretkey: 'zA_Think+KNOWLEDGE+WIKI+DOCUMENTS@2022' - expiresIn: '6h' From 20bdbd09e033d968434bb80e9b3f5a2e144c41ec Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 16:51:32 +0800 Subject: [PATCH 04/14] Create prod-sample.yaml --- docker/prod-sample.yaml | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 docker/prod-sample.yaml diff --git a/docker/prod-sample.yaml b/docker/prod-sample.yaml new file mode 100644 index 0000000..d00250f --- /dev/null +++ b/docker/prod-sample.yaml @@ -0,0 +1,49 @@ +# 生产环境docker示例配置 +client: + port: 5001 + assetPrefix: '/' + apiUrl: 'http://localhost:5002/api' + collaborationUrl: 'ws://localhost:5003' + # 以下为页面 meta 配置 + seoAppName: '云策文档' + seoDescription: '云策文档是一款开源知识管理工具。通过独立的知识库空间,结构化地组织在线协作文档,实现知识的积累与沉淀,促进知识的复用与流通。' + seoKeywords: '云策文档,协作,文档,前端面试题,fantasticit,https://github.com/fantasticit/think' + # 预先连接的来源,空格分割(比如图片存储服务器) + dnsPrefetch: '//wipi.oss-cn-shanghai.aliyuncs.com' + +server: + prefix: '/api' + port: 5002 + collaborationPort: 5003 + maxDocumentVersion: 20 # 最大版本记录数 + logRetainDays: 3 # 日志保留天数,比如只保留近三天日志 + +# 数据库配置 +db: + mysql: + host: 'mysql-with-think' + username: 'jonnyan404' + password: 'www.mrdoc.fun' + database: 'think' + port: 3306 + charset: 'utf8mb4' + timezone: '+08:00' + synchronize: true + redis: + host: '127.0.0.1' + port: '6379' + password: '' + +# oss 文件存储服务 +oss: + aliyun: + accessKeyId: '' + accessKeySecret: '' + bucket: '' + https: true + region: '' + +# jwt 配置 +jwt: + secretkey: 'zA_Think+KNOWLEDGE+WIKI+DOCUMENTS@2022' + expiresIn: '6h' From 4f7989296c2e77c98fc911619243d3476b34a45b Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 17:00:37 +0800 Subject: [PATCH 05/14] Update Dockerfile --- docker/Dockerfile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 8b13789..5712cea 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1 +1,25 @@ +FROM node:18-alpine as builder +COPY .. /app/ +WORKDIR /app +ARG EIP=mrdoc.fun +RUN apk --no-cache add bash +RUN sed -i "s/localhost/$EIP/g" /app/docker/prod-sample.yaml +RUN cp -f /app/docker/prod-sample.yaml /app/config/prod.yaml +RUN bash build-output.sh + +FROM node:18-alpine as prod +LABEL maintainer="www.mrdoc.fun" +ENV TZ=Asia/Shanghai +COPY . /app/docker/ +COPY --from=builder /app/think/output/ /app/ + +WORKDIR /app + +RUN set -x \ + && apk add --no-cache tzdata redis \ + && chmod +x /app/docker/start.sh \ + && npm i -g pm2 @nestjs/cli pnpm \ + && rm -rf /var/cache/apk/* + +ENTRYPOINT sh /app/docker/start.sh From 45a6424ccca9e1adf7ee4bff3a046f3ffedb4d11 Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 17:03:29 +0800 Subject: [PATCH 06/14] Create start.sh --- docker/start.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docker/start.sh diff --git a/docker/start.sh b/docker/start.sh new file mode 100644 index 0000000..60c3e2f --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,14 @@ +#!/bin/sh +### Author:jonnyan404 +### date:2022年5月22日 +CONFIG_FILE='/app/config/prod.yaml' + +if [ ! -f $CONFIG_FILE ]; then + echo "#####Generating configuration file#####" + cp /app/docker/prod-sample.yaml $CONFIG_FILE +else + echo "#####Configuration file already exists#####" +fi +redis-server --daemonize yes +pnpm run pm2 +pm2 logs From 8262f83210f1b70cd549c3cafdf562ab9553297e Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 17:19:53 +0800 Subject: [PATCH 07/14] Create docker-compose.yml --- docker/docker-compose.yml | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docker/docker-compose.yml diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..1e6b860 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,43 @@ +version: "3" +services: + mrdoc: + build: + context: think + args: + EIP: x.x.x.x # api接口IP,必须设置,可以是 IP 或者域名. + image: think + container_name: thinkdoc + #restart: always + volumes: + - /path/to/you/dir/config:/app/config # 请注意修改 /path/to/you/dir 为云策文档配置文件目录. + environment: + - TZ=Asia/Shanghai + ports: + - "5001-5003:5001-5003" + depends_on: + - mysql + mysql: + image: mysql:5.7 + container_name: mysql-with-think + #restart: always + volumes: + - /path/to/you/dir:/var/lib/mysql # 请注意修改 /path/to/you/dir 为您要存储mysql数据的目录绝对路径. + environment: + - TZ=Asia/Shanghai + - MYSQL_ROOT_PASSWORD=Jonnyan404! + - MYSQL_DATABASE=think + - MYSQL_USER=jonnyan404 + - MYSQL_PASSWORD=www.mrdoc.fun + expose: + - "3306" + ports: + - "63306:3306" # 如果不需要外部连接mysql,可注释此行+上一行. + command: + - "--character-set-server=utf8mb4" + - "--collation-server=utf8mb4_unicode_ci" +# Volumes for persisting data, see https://docs.docker.com/engine/admin/volumes/volumes/ +#volumes: +# thinkdoc-data: +# driver: local +# mysql-data: +# driver: local From 0785234a3e3d1e1d9c634756be1e69917e62979f Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 17:25:15 +0800 Subject: [PATCH 08/14] Update docker-compose.yml --- docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 1e6b860..fb35cfc 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -2,7 +2,7 @@ version: "3" services: mrdoc: build: - context: think + context: . args: EIP: x.x.x.x # api接口IP,必须设置,可以是 IP 或者域名. image: think From 1780ab71052f0dccabac629084eff4d44462e48a Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 18:01:49 +0800 Subject: [PATCH 09/14] Delete Dockerfile --- docker/Dockerfile | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 5712cea..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -FROM node:18-alpine as builder -COPY .. /app/ -WORKDIR /app -ARG EIP=mrdoc.fun -RUN apk --no-cache add bash -RUN sed -i "s/localhost/$EIP/g" /app/docker/prod-sample.yaml -RUN cp -f /app/docker/prod-sample.yaml /app/config/prod.yaml -RUN bash build-output.sh - - -FROM node:18-alpine as prod -LABEL maintainer="www.mrdoc.fun" -ENV TZ=Asia/Shanghai -COPY . /app/docker/ -COPY --from=builder /app/think/output/ /app/ - -WORKDIR /app - -RUN set -x \ - && apk add --no-cache tzdata redis \ - && chmod +x /app/docker/start.sh \ - && npm i -g pm2 @nestjs/cli pnpm \ - && rm -rf /var/cache/apk/* - -ENTRYPOINT sh /app/docker/start.sh From 8a8d3767422b89404a33dcb5d9b4436f2c42c2ea Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 18:01:59 +0800 Subject: [PATCH 10/14] Delete docker-compose.yml --- docker/docker-compose.yml | 43 --------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 docker/docker-compose.yml diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml deleted file mode 100644 index fb35cfc..0000000 --- a/docker/docker-compose.yml +++ /dev/null @@ -1,43 +0,0 @@ -version: "3" -services: - mrdoc: - build: - context: . - args: - EIP: x.x.x.x # api接口IP,必须设置,可以是 IP 或者域名. - image: think - container_name: thinkdoc - #restart: always - volumes: - - /path/to/you/dir/config:/app/config # 请注意修改 /path/to/you/dir 为云策文档配置文件目录. - environment: - - TZ=Asia/Shanghai - ports: - - "5001-5003:5001-5003" - depends_on: - - mysql - mysql: - image: mysql:5.7 - container_name: mysql-with-think - #restart: always - volumes: - - /path/to/you/dir:/var/lib/mysql # 请注意修改 /path/to/you/dir 为您要存储mysql数据的目录绝对路径. - environment: - - TZ=Asia/Shanghai - - MYSQL_ROOT_PASSWORD=Jonnyan404! - - MYSQL_DATABASE=think - - MYSQL_USER=jonnyan404 - - MYSQL_PASSWORD=www.mrdoc.fun - expose: - - "3306" - ports: - - "63306:3306" # 如果不需要外部连接mysql,可注释此行+上一行. - command: - - "--character-set-server=utf8mb4" - - "--collation-server=utf8mb4_unicode_ci" -# Volumes for persisting data, see https://docs.docker.com/engine/admin/volumes/volumes/ -#volumes: -# thinkdoc-data: -# driver: local -# mysql-data: -# driver: local From 62fe048db51bb3e303b0dd46d5e814674c22288f Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 18:03:56 +0800 Subject: [PATCH 11/14] Create docker-compose.yml --- docker-compose.yml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6788c9c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,43 @@ +version: "3" +services: + thinkdoc: + build: + context: . + args: + EIP: x.x.x.x # api接口IP,必须设置,可以是 IP 或者域名. + image: think + container_name: thinkdoc + #restart: always + volumes: + - /path/to/you/dir/config:/app/config # 请注意修改 /path/to/you/dir 为云策文档配置文件目录. + environment: + - TZ=Asia/Shanghai + ports: + - "5001-5003:5001-5003" + depends_on: + - mysql + mysql: + image: mysql:5.7 + container_name: mysql-with-think + #restart: always + volumes: + - /path/to/you/dir:/var/lib/mysql # 请注意修改 /path/to/you/dir 为您要存储mysql数据的目录绝对路径. + environment: + - TZ=Asia/Shanghai + - MYSQL_ROOT_PASSWORD=Jonnyan404! + - MYSQL_DATABASE=think + - MYSQL_USER=jonnyan404 + - MYSQL_PASSWORD=www.mrdoc.fun + expose: + - "3306" + ports: + - "63306:3306" # 如果不需要外部连接mysql,可注释此行+上一行. + command: + - "--character-set-server=utf8mb4" + - "--collation-server=utf8mb4_unicode_ci" +# Volumes for persisting data, see https://docs.docker.com/engine/admin/volumes/volumes/ +#volumes: +# thinkdoc-data: +# driver: local +# mysql-data: +# driver: local From 1445678f4ec8a10c1f37e1cf76e619788f47767c Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 18:04:58 +0800 Subject: [PATCH 12/14] Create Dockerfile --- Dockerfile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3bd6622 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM node:18-alpine as builder +COPY . /app/ +WORKDIR /app +ARG EIP=mrdoc.fun +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories +RUN npm config set registry http://registry.npm.taobao.org/ +RUN npm i -g pm2 @nestjs/cli pnpm +RUN apk --no-cache add bash +RUN sed -i "s/localhost/$EIP/g" /app/docker/prod-sample.yaml +RUN cp -f /app/docker/prod-sample.yaml /app/config/prod.yaml +RUN bash build-output.sh + + +FROM node:18-alpine as prod +LABEL maintainer="www.mrdoc.fun" +ENV TZ=Asia/Shanghai +COPY --from=builder /app/docker/* /app/docker/ +COPY --from=builder /app/output/ /app/ + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories +RUN npm config set registry http://registry.npm.taobao.org/ +RUN set -x \ + && apk update \ + && apk add --no-cache tzdata redis \ + && chmod +x /app/docker/start.sh \ + && npm i -g pm2 @nestjs/cli pnpm \ + && rm -rf /var/cache/apk/* + +ENTRYPOINT sh /app/docker/start.sh From 5b1e1a6599ac428db5b85f70a183d0fc1fa705cd Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 18:55:03 +0800 Subject: [PATCH 13/14] Update README.md --- README.md | 142 +++++++++++++++++++----------------------------------- 1 file changed, 49 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index e320523..a5fc56d 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Think 是一款开源知识管理工具。通过独立的知识库空间,结 ![协作](http://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-20/YN67GM4VQMBTZFZ88TYQ8X/image.png) ![收藏](http://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-20/YN67GM4VQMBTZFZ88TYPHX/image.png) -## 项目运行 +## 项目结构 本项目依赖 pnpm 使用 monorepo 形式进行代码组织,分包如下: @@ -35,26 +35,25 @@ Think 是一款开源知识管理工具。通过独立的知识库空间,结 - `@think/server`:服务端 - `@think/client`:客户端 -### pnpm +## 项目依赖 -项目依赖 pnpm,请安装后运行(`npm i -g pnpm`)。 +- nodejs ≥ 16.5 +- pnpm +- pm2 +- mysql ≥ 5.7 +- redis (可选) -### 数据库 +依赖安装命令: `npm i -g pm2 @nestjs/cli pnpm` + + +#### 数据库 首先安装 `MySQL`,推荐使用 docker 进行安装。 ```bash docker image pull mysql:5.7 # m1 的 mac 可以用:docker image pull --platform linux/x86_64 mysql:5.7 -docker run -d --restart=always --name think -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7 -``` - -然后在 `MySQL` 中创建数据库。 - -```bash -docker container exec -it think bash; -mysql -u root -p; -CREATE DATABASE `think` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +docker run -d --restart=always --name think -p 3306:3306 -e MYSQL_DATABASE=think -e MYSQL_ROOT_PASSWORD=root mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci ``` #### 可选:Redis @@ -66,102 +65,59 @@ docker pull redis:latest docker run --name think-redis -p 6379:6379 -d redis --appendonly yes --requirepass "root" ``` -### 本地运行 +## Docker-compose 一键构建安装 -首先,clone 项目。 +- 实测腾讯轻量云 2C4G 机器构建需 8 分钟左右 -```bash -git clone --depth=1 https://github.com/fantasticit/think.git your-project-name +**请注意修改 `docker-compose.yml` 中的 `EIP` 参数,否则无法正常使用!!!** + + +``` +# 首次安装 +git clone https://github.com/fantasticit/think.git +cd think +docker-compose up -d + +#二次更新升级 +cd think +git pull +docker-compose build +docker-compose up -d ``` -然后,安装项目依赖。 +然后访问 `http://ip:5001` 即可. + + + +## 手动安装教程 + +- 前台页面地址:`http://localhost:5001` +- 服务接口地址:`http://localhost:5002` +- 协作接口地址:`http://localhost:5003` + +如需修改配置,开发环境编辑 `config/dev.yaml`。生产环境编辑 `config/prod.yaml` (如没有,可复制开发环境的配置修改即可.) + +### 本地源代码运行(开发环境) + ```bash +git clone https://github.com/fantasticit/think.git +cd think pnpm install -``` - -- 启动项目 - -```bash pnpm run dev ``` -- 前台页面地址:`http://localhost:5001`。 -- 服务接口地址:`http://localhost:5002`。 -- 协作接口地址:`http://localhost:5003`。 +然后访问 `http://ip:5001` 即可. -如需修改配置,可在 `config/dev.yaml` 中进行配置。 -### 配置文件 -默认加载 `config/dev.yaml` 中的配置(生产环境使用 `config/prod.yaml` )。 - -```yaml -# 开发环境配置 -# 开发环境配置 -client: - port: 5001 - assetPrefix: '/' - apiUrl: 'http://localhost:5002/api' - collaborationUrl: 'ws://localhost:5003' - # 以下为页面 meta 配置 - seoAppName: '云策文档' - seoDescription: '云策文档是一款开源知识管理工具。通过独立的知识库空间,结构化地组织在线协作文档,实现知识的积累与沉淀,促进知识的复用与流通。' - seoKeywords: '云策文档,协作,文档,前端面试题,fantasticit,https://github.com/fantasticit/think' - # 预先连接的来源,空格分割(比如图片存储服务器) - dnsPrefetch: '//wipi.oss-cn-shanghai.aliyuncs.com' - -server: - prefix: '/api' - port: 5002 - collaborationPort: 5003 - maxDocumentVersion: 20 # 最大版本记录数 - logRetainDays: 3 # 日志保留天数,比如只保留近三天日志 - -# 数据库配置 -db: - mysql: - host: '127.0.0.1' - username: 'root' - password: 'root' - database: 'think' - port: 3306 - charset: 'utf8mb4' - timezone: '+08:00' - synchronize: true - redis: - host: '127.0.0.1' - port: '6379' - password: 'root' - -# oss 文件存储服务 -oss: - aliyun: - accessKeyId: '' - accessKeySecret: '' - bucket: '' - https: true - region: '' - -# jwt 配置 -jwt: - secretkey: 'zA_Think+KNOWLEDGE+WIKI+DOCUMENTS@2022' - expiresIn: '6h' -``` - -### 项目部署 +### 本地源代码运行(生产环境) 生产环境部署的脚本如下: ```bash - -node -v -npm -v - -npm config set registry http://registry.npmjs.org - -npm i -g pm2 @nestjs/cli pnpm - +git clone https://github.com/fantasticit/think.git +cd think pnpm install pnpm run build pnpm run pm2 @@ -170,7 +126,7 @@ pm2 startup pm2 save ``` -### nginx 配置 +### nginx 配置参考 采用反向代理进行 `nginx` 配置,**同时设置 `proxy_set_header X-Real-IP $remote_addr;` 以便服务端获取到真实 ip 地址**。 From 6d8d1e73d2deeda7d26693b18282d6fcb53fc23e Mon Sep 17 00:00:00 2001 From: jonny <475634114@qq.com> Date: Sun, 22 May 2022 19:00:25 +0800 Subject: [PATCH 14/14] Update docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6788c9c..9aa83d3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,7 @@ services: container_name: mysql-with-think #restart: always volumes: - - /path/to/you/dir:/var/lib/mysql # 请注意修改 /path/to/you/dir 为您要存储mysql数据的目录绝对路径. + - /path/to/you/dir/mysql:/var/lib/mysql # 请注意修改 /path/to/you/dir 为您要存储mysql数据的目录绝对路径. environment: - TZ=Asia/Shanghai - MYSQL_ROOT_PASSWORD=Jonnyan404!