chore: update docker config

This commit is contained in:
fantasticit 2022-06-28 20:26:30 +08:00
parent a80dc769ce
commit a0c3bf206b
7 changed files with 66 additions and 47 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ tsconfig.tsbuildinfo
scripts/update.sh scripts/update.sh
output output
runtime

View File

@ -1,18 +1,13 @@
FROM node:18-alpine as builder FROM node:18-alpine as builder
COPY . /app/ COPY . /app/
WORKDIR /app WORKDIR /app
ARG EIP=mrdoc.fun
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
RUN npm i -g pm2 @nestjs/cli pnpm RUN npm i -g pm2 @nestjs/cli pnpm
RUN apk --no-cache add bash 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 RUN bash build-output.sh
FROM node:18-alpine as prod FROM node:18-alpine as prod
LABEL maintainer="www.mrdoc.fun"
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/
@ -22,7 +17,7 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositorie
RUN npm config set registry https://registry.npmmirror.com RUN npm config set registry https://registry.npmmirror.com
RUN set -x \ RUN set -x \
&& apk update \ && apk update \
&& apk add --no-cache tzdata redis \ && apk add --no-cache tzdata redis \
&& chmod +x /app/docker/start.sh \ && chmod +x /app/docker/start.sh \
&& npm i -g pm2 @nestjs/cli pnpm \ && npm i -g pm2 @nestjs/cli pnpm \
&& rm -rf /var/cache/apk/* && rm -rf /var/cache/apk/*

View File

@ -37,8 +37,8 @@ server:
db: db:
mysql: mysql:
host: '127.0.0.1' host: '127.0.0.1'
username: 'root' username: 'think'
password: 'root' password: 'think'
database: 'think' database: 'think'
port: 3306 port: 3306
charset: 'utf8mb4' charset: 'utf8mb4'

View File

@ -1,13 +1,13 @@
# 生产环境docker示例配置 # 开发环境配置
client: client:
port: 5001 port: 5001
assetPrefix: '/' assetPrefix: '/'
apiUrl: 'http://localhost:5002/api' apiUrl: 'http://localhost:5002/api'
collaborationUrl: 'ws://localhost:5003/think/wss' collaborationUrl: 'ws://localhost:5003'
# 以下为页面 meta 配置 # 以下为页面 meta 配置
seoAppName: '云策文档' seoAppName: '云策文档'
seoDescription: '云策文档是一款开源知识管理工具。通过独立的知识库空间,结构化地组织在线协作文档,实现知识的积累与沉淀,促进知识的复用与流通。' seoDescription: '云策文档是一款开源知识管理工具。通过独立的知识库空间,结构化地组织在线协作文档,实现知识的积累与沉淀,促进知识的复用与流通。'
seoKeywords: '云策文档,协作,文档,前端面试题,fantasticit,https://github.com/fantasticit/think' seoKeywords: '云策文档,协作,文档,fantasticit,https://github.com/fantasticit/think'
# 预先连接的来源,空格分割(比如图片存储服务器) # 预先连接的来源,空格分割(比如图片存储服务器)
dnsPrefetch: '//wipi.oss-cn-shanghai.aliyuncs.com' dnsPrefetch: '//wipi.oss-cn-shanghai.aliyuncs.com'
# 站点地址http://think.codingit.cn/),一定要设置,否则会出现 cookie、跨域等问题 # 站点地址http://think.codingit.cn/),一定要设置,否则会出现 cookie、跨域等问题
@ -23,22 +23,31 @@ server:
enableRateLimit: true # 是否限流 enableRateLimit: true # 是否限流
rateLimitWindowMs: 60000 # 限流时间 rateLimitWindowMs: 60000 # 限流时间
rateLimitMax: 1000 # 单位限流时间内单个 ip 最大访问数量 rateLimitMax: 1000 # 单位限流时间内单个 ip 最大访问数量
email: # 邮箱服务,参考 http://help.163.com/09/1223/14/5R7P6CJ600753VB8.html?servCode=6010376 获取 SMTP 配置
host: ''
port: 465
user: ''
password: ''
admin:
name: 'sytemadmin' # 注意修改
password: 'sytemadmin' # 注意修改
email: 'sytemadmin@think.com' # 注意修改为真实邮箱地址
# 数据库配置 # 数据库配置
db: db:
mysql: mysql:
host: 'mysql-with-think' host: 'mysql-for-think'
username: 'jonnyan404' username: 'think'
password: 'www.mrdoc.fun' password: 'think'
database: 'think' database: 'think'
port: 3306 port: 3306
charset: 'utf8mb4' charset: 'utf8mb4'
timezone: '+08:00' timezone: '+08:00'
synchronize: true synchronize: true
redis: redis:
host: '127.0.0.1' host: 'redis-for-think'
port: '6379' port: '6379'
password: '' password: 'root'
# oss 文件存储服务 # oss 文件存储服务
oss: oss:

View File

@ -1,44 +1,58 @@
version: "3" version: '3'
services: services:
thinkdoc: think:
build: build:
context: . context: .
args:
EIP: x.x.x.x # api接口IP,必须设置,可以是 IP 或者域名.
image: think image: think
container_name: thinkdoc container_name: think
#restart: always
volumes: volumes:
- /path/to/you/dir/config:/app/config # 请注意修改 /path/to/you/dir 为云策文档配置文件目录. - ./config:/app/config
- /path/to/you/dir/static:/app/packages/server/static # 请注意修改 /path/to/you/dir 为云策文档附件存储目录. - ./runtime/static:/app/packages/server/static
environment: environment:
- TZ=Asia/Shanghai - TZ=Asia/Shanghai
ports: ports:
- "5001-5003:5001-5003" - '5001-5003:5001-5003'
depends_on: depends_on:
- mysql - mysql
- redis
networks:
- think
mysql: mysql:
image: mysql:5.7 image: mysql:5.7
container_name: mysql-with-think restart: always
#restart: always container_name: mysql-for-think
volumes: volumes:
- /path/to/you/dir/mysql:/var/lib/mysql # 请注意修改 /path/to/you/dir 为您要存储mysql数据的目录绝对路径. - ./runtime/mysql:/var/lib/mysql
environment: environment:
- TZ=Asia/Shanghai - TZ=Asia/Shanghai
- MYSQL_ROOT_PASSWORD=Jonnyan404! - MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=think - MYSQL_DATABASE=think
- MYSQL_USER=jonnyan404 - MYSQL_USER=think
- MYSQL_PASSWORD=www.mrdoc.fun - MYSQL_PASSWORD=think
expose: expose:
- "3306" - '3306'
ports: ports:
- "63306:3306" # 如果不需要外部连接mysql,可注释此行+上一行. - '3306:3306'
command: command:
- "--character-set-server=utf8mb4" - '--character-set-server=utf8mb4'
- "--collation-server=utf8mb4_unicode_ci" - '--collation-server=utf8mb4_unicode_ci'
# Volumes for persisting data, see https://docs.docker.com/engine/admin/volumes/volumes/ networks:
#volumes: - think
# thinkdoc-data: redis:
# driver: local image: redis:latest
# mysql-data: restart: always
# driver: local container_name: redis-for-think
command: >
--requirepass root
expose:
- '6379'
ports:
- '6379:6379'
volumes:
- ./runtime/redis:/data
privileged: true
networks:
- think
networks:
think:
driver: bridge

View File

@ -1,14 +1,14 @@
#!/bin/sh #!/bin/sh
### Author:jonnyan404 ### Author:jonnyan404
### date:2022年5月22日 ### date:2022年5月22日
CONFIG_FILE='/app/config/prod.yaml' CONFIG_FILE='/app/config/prod.yaml'
if [ ! -f $CONFIG_FILE ]; then if [ ! -f $CONFIG_FILE ]; then
echo "#####Generating configuration file#####" cp -f /app/config/docker-prod-sample.yaml $CONFIG_FILE
cp /app/docker/prod-sample.yaml $CONFIG_FILE
else else
echo "#####Configuration file already exists#####" echo ""
fi fi
redis-server --daemonize yes
pnpm run pm2 pnpm run pm2
pm2 logs pm2 logs