mirror of https://github.com/fantasticit/think.git
chore: update docker-compose
parent
d1eef7bec3
commit
09986ca5bf
|
@ -13,7 +13,6 @@ FROM node:18-alpine as prod
|
||||||
ENV TZ=Asia/Shanghai
|
ENV TZ=Asia/Shanghai
|
||||||
COPY --from=builder /app/docker/* /app/docker/
|
COPY --from=builder /app/docker/* /app/docker/
|
||||||
COPY --from=builder /app/output/ /app/
|
COPY --from=builder /app/output/ /app/
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
||||||
RUN npm config set registry https://registry.npmmirror.com
|
RUN npm config set registry https://registry.npmmirror.com
|
||||||
|
|
|
@ -10,6 +10,8 @@ services:
|
||||||
- ./runtime/static:/app/packages/server/static
|
- ./runtime/static:/app/packages/server/static
|
||||||
environment:
|
environment:
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
|
expose:
|
||||||
|
- '5001-5003'
|
||||||
ports:
|
ports:
|
||||||
- '5001-5003:5001-5003'
|
- '5001-5003:5001-5003'
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
@ -0,0 +1,178 @@
|
||||||
|
# 使用 docker-compose 进行项目部署
|
||||||
|
|
||||||
|
> 目标:使用 http://dev.think.codingit.cn 访问客户端;使用 http://dev.api.codingit.cn 访问服务端。
|
||||||
|
|
||||||
|
## 1. 新建 config/prod.yaml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# 开发环境配置
|
||||||
|
client:
|
||||||
|
port: 5001
|
||||||
|
assetPrefix: '/'
|
||||||
|
apiUrl: 'http://dev.api.codingit.cn/api'
|
||||||
|
collaborationUrl: 'ws://dev.api.codingit.cn/think/wss'
|
||||||
|
# 以下为页面 meta 配置
|
||||||
|
seoAppName: '云策文档'
|
||||||
|
seoDescription: '云策文档是一款开源知识管理工具。通过独立的知识库空间,结构化地组织在线协作文档,实现知识的积累与沉淀,促进知识的复用与流通。'
|
||||||
|
seoKeywords: '云策文档,协作,文档,fantasticit,https://github.com/fantasticit/think'
|
||||||
|
# 预先连接的来源,空格分割(比如图片存储服务器)
|
||||||
|
dnsPrefetch: '//wipi.oss-cn-shanghai.aliyuncs.com'
|
||||||
|
# 站点地址(如:http://think.codingit.cn/),一定要设置,否则会出现 cookie、跨域等问题
|
||||||
|
siteUrl: 'http://dev.think.codingit.cn'
|
||||||
|
siteDomain: ''
|
||||||
|
|
||||||
|
server:
|
||||||
|
prefix: '/api'
|
||||||
|
port: 5002
|
||||||
|
collaborationPort: 5003
|
||||||
|
maxDocumentVersion: 20 # 最大版本记录数
|
||||||
|
logRetainDays: 3 # 日志保留天数,比如只保留近三天日志
|
||||||
|
enableRateLimit: true # 是否限流
|
||||||
|
rateLimitWindowMs: 60000 # 限流时间
|
||||||
|
rateLimitMax: 1000 # 单位限流时间内单个 ip 最大访问数量
|
||||||
|
email: # 邮箱服务,参考 http://help.163.com/09/1223/14/5R7P6CJ600753VB8.html?servCode=6010376 获取 SMTP 配置
|
||||||
|
host: ''
|
||||||
|
port: 465
|
||||||
|
user: ''
|
||||||
|
password: ''
|
||||||
|
admin:
|
||||||
|
name: 'admin' # 注意修改
|
||||||
|
password: 'admin' # 注意修改
|
||||||
|
email: 'admin@think.com' # 注意修改为真实邮箱地址
|
||||||
|
|
||||||
|
# 数据库配置
|
||||||
|
db:
|
||||||
|
mysql:
|
||||||
|
host: 'mysql-for-think'
|
||||||
|
username: 'think'
|
||||||
|
password: 'think'
|
||||||
|
database: 'think'
|
||||||
|
port: 3306
|
||||||
|
charset: 'utf8mb4'
|
||||||
|
timezone: '+08:00'
|
||||||
|
synchronize: true
|
||||||
|
redis:
|
||||||
|
host: 'redis-for-think'
|
||||||
|
port: '6379'
|
||||||
|
password: 'root'
|
||||||
|
|
||||||
|
# oss 文件存储服务
|
||||||
|
oss:
|
||||||
|
local:
|
||||||
|
enable: true
|
||||||
|
# 线上更改为服务端地址(如:https://api.codingit.cn)
|
||||||
|
server: 'http://dev.api.codingit.cn'
|
||||||
|
# 以下为各厂商 sdk 配置,不要修改字段,填入值即可
|
||||||
|
tencent:
|
||||||
|
enable: false
|
||||||
|
config:
|
||||||
|
SecretId: ''
|
||||||
|
SecretKey: ''
|
||||||
|
Bucket: ''
|
||||||
|
Region: ''
|
||||||
|
aliyun:
|
||||||
|
enable: false
|
||||||
|
config:
|
||||||
|
accessKeyId: ''
|
||||||
|
accessKeySecret: ''
|
||||||
|
bucket: ''
|
||||||
|
https: true
|
||||||
|
region: ''
|
||||||
|
|
||||||
|
# jwt 配置
|
||||||
|
jwt:
|
||||||
|
secretkey: 'zA_Think+KNOWLEDGE+WIKI+DOCUMENTS@2022'
|
||||||
|
expiresIn: '6h'
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. 新建 nginx.conf
|
||||||
|
|
||||||
|
```shell
|
||||||
|
upstream think_client {
|
||||||
|
server 127.0.0.1:5001;
|
||||||
|
keepalive 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
upstream think_server {
|
||||||
|
server 127.0.0.1:5002;
|
||||||
|
keepalive 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
upstream think_wss {
|
||||||
|
server 127.0.0.1:5003;
|
||||||
|
keepalive 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name dev.api.codingit.cn;
|
||||||
|
|
||||||
|
client_max_body_size 100m;
|
||||||
|
|
||||||
|
location /api {
|
||||||
|
proxy_pass http://think_server;
|
||||||
|
proxy_read_timeout 300s;
|
||||||
|
proxy_send_timeout 300s;
|
||||||
|
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
}
|
||||||
|
|
||||||
|
location /think/wss {
|
||||||
|
proxy_pass http://think_wss;
|
||||||
|
proxy_read_timeout 300s;
|
||||||
|
proxy_send_timeout 300s;
|
||||||
|
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
}
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
proxy_pass http://think_server;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name dev.think.codingit.cn;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header X-Nginx-Proxy true;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
proxy_pass http://think_client;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. 构建项目
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cd think
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
4. 可选:配置 hosts
|
||||||
|
|
||||||
|
```shell
|
||||||
|
127.0.0.1 dev.api.codingit.cn
|
||||||
|
127.0.0.1 dev.think.codingit.cn
|
||||||
|
```
|
||||||
|
|
||||||
|
5. 访问
|
||||||
|
|
||||||
|
浏览器访问:http://dev.think.codingit.cn。
|
|
@ -80,9 +80,8 @@ pm2 save
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 首次安装
|
# 首次安装
|
||||||
git clone https://github.com/fantasticit/think.git
|
git clone https://github.com/fantasticit/think.git
|
||||||
cd think
|
cd think
|
||||||
vim docker-compose.yml
|
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
|
||||||
# 二次更新升级
|
# 二次更新升级
|
||||||
|
@ -98,6 +97,8 @@ docker image rm think # 删掉构建的镜像
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
|
更多细节可以查看 [how-to-use-docker.md](./how-to-use-docker.md)。
|
||||||
|
|
||||||
### nginx 配置参考
|
### nginx 配置参考
|
||||||
|
|
||||||
无论以何种方式进行项目部署,项目运行成功后会在 3 个端口启动服务(默认 5001、5002、5003,具体由配置文件决定)。`nginx` 配置参考 <[think/nginx.conf.sample](https://github.com/fantasticit/think/blob/main/nginx.conf.sample)>。
|
无论以何种方式进行项目部署,项目运行成功后会在 3 个端口启动服务(默认 5001、5002、5003,具体由配置文件决定)。`nginx` 配置参考 <[think/nginx.conf.sample](https://github.com/fantasticit/think/blob/main/nginx.conf.sample)>。
|
||||||
|
|
|
@ -14,18 +14,8 @@ upstream think_wss {
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name api.codingit.cn;
|
server_name dev.api.codingit.cn;
|
||||||
rewrite ^(.*)$ https://$host$1 permanent;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 443 ssl http2;
|
|
||||||
server_name api.codingit.cn;
|
|
||||||
|
|
||||||
ssl_certificate /apps/ssl/api.codingit.cn/api.codingit.cn.pem;
|
|
||||||
ssl_certificate_key /apps/ssl/api.codingit.cn/api.codingit.cn.key;
|
|
||||||
ssl_session_timeout 5m;
|
|
||||||
|
|
||||||
client_max_body_size 100m;
|
client_max_body_size 100m;
|
||||||
|
|
||||||
|
@ -56,26 +46,13 @@ server {
|
||||||
}
|
}
|
||||||
|
|
||||||
location /static/ {
|
location /static/ {
|
||||||
gzip_static on;
|
proxy_pass http://think_server;
|
||||||
expires max;
|
|
||||||
add_header Cache-Control public;
|
|
||||||
alias /apps/think/packages/server/static/;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name think.codingit.cn;
|
server_name dev.think.codingit.cn;
|
||||||
rewrite ^(.*)$ https://$host$1 permanent;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 443 ssl http2;
|
|
||||||
server_name think.codingit.cn;
|
|
||||||
|
|
||||||
ssl_certificate /apps/ssl/think.codingit.cn/think.codingit.cn.pem;
|
|
||||||
ssl_certificate_key /apps/ssl/think.codingit.cn/think.codingit.cn.key;
|
|
||||||
ssl_session_timeout 5m;
|
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
@ -89,21 +66,4 @@ server {
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
}
|
}
|
||||||
|
|
||||||
# 静态文件
|
|
||||||
location ^~ /_next {
|
|
||||||
alias /apps/think/packages/client/.next;
|
|
||||||
autoindex on;
|
|
||||||
}
|
|
||||||
|
|
||||||
# next-pwa 生成的静态文件(service-worker.js, workbox-*.js)
|
|
||||||
location ~ /*\.js$ {
|
|
||||||
add_header Content-Type "application/javascript; charset=UTF-8";
|
|
||||||
root /apps/think/packages/client/.next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 自定义流程图编辑器的文件
|
|
||||||
location ~ /*\.(gif|png|jpg|jpeg|xml|txt)$ {
|
|
||||||
root /apps/think/packages/client/.next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,3 +35,7 @@ yarn-error.log*
|
||||||
|
|
||||||
# typescript
|
# typescript
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# service-worker.js
|
||||||
|
/public/service-worker.js
|
||||||
|
/public/workbox-*.js
|
||||||
|
|
|
@ -80,4 +80,6 @@ fs.copySync('./public', './.next', {
|
||||||
return !/diagram.js$/.test(src);
|
return !/diagram.js$/.test(src);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.outputFileSync('./.next/manifest.json', buildManifestJson());
|
fs.outputFileSync('./.next/manifest.json', buildManifestJson());
|
||||||
|
fs.outputFileSync('./public/manifest.json', buildManifestJson());
|
||||||
|
|
|
@ -33,12 +33,9 @@ const nextConfig = semi({
|
||||||
typescript: {
|
typescript: {
|
||||||
ignoreBuildErrors: true,
|
ignoreBuildErrors: true,
|
||||||
},
|
},
|
||||||
compiler: {
|
|
||||||
// removeConsole: process.env.NODE_ENV === 'production',
|
|
||||||
},
|
|
||||||
pwa: {
|
pwa: {
|
||||||
disable: process.env.NODE_ENV !== 'production',
|
disable: process.env.NODE_ENV !== 'production',
|
||||||
dest: '.next',
|
dest: 'public',
|
||||||
sw: 'service-worker.js',
|
sw: 'service-worker.js',
|
||||||
runtimeCaching: pwaRuntimeCaching,
|
runtimeCaching: pwaRuntimeCaching,
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{"name":"云策文档","short_name":"云策文档","display":"standalone","start_url":"/","theme_color":"#ffffff","background_color":"#ffffff","icons":[{"src":"/icon72.png","sizes":"72x72","type":"image/png"},{"src":"/icon96.png","sizes":"96x96","type":"image/png"},{"src":"/icon120.png","sizes":"120x120","type":"image/png"},{"src":"/icon128.png","sizes":"128x128","type":"image/png"},{"src":"/icon144.png","sizes":"144x144","type":"image/png"},{"src":"/icon152.png","sizes":"152x152","type":"image/png"},{"src":"/icon180.png","sizes":"180x180","type":"image/png"},{"src":"/icon192.png","sizes":"192x192","type":"image/png"},{"src":"/icon384.png","sizes":"384x384","type":"image/png"},{"src":"/icon512.png","sizes":"512x512","type":"image/png"},{"src":"/maskable.png","sizes":"192x192","type":"image/png","purpose":"maskable"}]}
|
Loading…
Reference in New Issue