docker-compose部署gitbook
2021-12-08 本文已影响0人
SailSea
image.png
gitbook 启动 docker-compose.yaml
version: "3.9"
services:
gitbook:
image: fellah/gitbook
ports:
- "5000:4000"
volumes:
- ./gitbook:/srv/gitbook
- ./xxxx_docs/SUMMARY.md:/srv/gitbook/SUMMARY.md
- ./xxxx_docs/README.md:/srv/gitbook/README.md
- ./xxxx_docs/files:/srv/gitbook/files
xxxx_docs是git仓库目录结构为
└── xxxx_docs
├── files
├── README.md
└── SUMMARY.md
/srv/gitbook/book.json:
{
"language": "zh-hans",
"plugins": [
"-sharing",
"-lunr",
"-search",
"-highlight",
"search-pro",
"chapter-fold",
"intopic-toc",
"prism",
"splitter",
"back-to-top-button",
"copy-code-button",
"hide-element",
"insert-logo",
"custom-favicon",
"expandable-chapters",
"lightbox"
],
"pluginsConfig": {
"intopic-toc": {
"label": "本页导航"
},
"prism": {
"css": [
"prismjs/themes/prism-okaidia.css"
]
},
"hide-element": {
"elements": [
".gitbook-link"
]
},
"insert-logo": {
"url": "https://open-iot.worthcloud.net/assets/logo.a7c47629.png",
"style": "background:none;max-height:50px"
},
"favicon": "favicon.ico"
}
}
/root/gitbook目录下的文件说明:
gitbook目录:gitbook服务工作目录(里面包含了gitbook插件配置文件book.json等)
worthcloud_docs目录:文档中心代码目录
docker-compose.yml文件:gitbook服务容器配置文件
up.sh文件:gitbook服务启动/升级脚本(里面包含了文档中心代码仓库路径的配置,文档中心代码更新命令,gitbook服务重启命令)
安装插件:
1、进入gitbook容器:docker exec -it {容器ID} /bin/bash
2、容器内安装gitbook插件:npm install gitbook-plugin-{插件名}
3、退出容器
4、更新 gitbook/book.json 文件的插件列表
5、docker-compose up -d --force-recreate 强制重启服务完成更新
卸载插件:
1、进入gitbook容器:docker exec -it {容器ID} /bin/bash
2、容器内卸载gitbook插件:npm uninstall gitbook-plugin-{插件名}
3、退出容器
4、更新 gitbook/book.json 文件的插件列表
5、docker-compose up -d --force-recreate 强制重启服务完成更新
常用插件:
Splitter:文章的目录栏可以左右拖动,调整宽度。
Search-pro:支持中文搜索插件
Prism:语法高亮
expandable-chapters:左侧目录折叠
lightbox:弹窗浏览图片