博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
gitbook安装与使用,并使用docker部署
阅读量:4457 次
发布时间:2019-06-08

本文共 3321 字,大约阅读时间需要 11 分钟。

本文简单介绍如何安装并使用gitbook,最后如何使用docker构建书籍镜像。

1. 前置条件

需要Nodejs环境,安装npm,国内用户再安装cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org

2. 安装gitbook

cnpm install -g gitbook-cligitbook -V CLI version: 2.3.2Installing GitBook 3.2.3gitbook@3.2.3 ..\AppData\Local\Temp\tmp-20544doJtj1hfVp40\node_modules\gitbook├── escape-string-regexp@1.0.5├── escape-html@1.0.3 。。。。GitBook version: 3.2.3

3. gitbook使用

3.1 生成目录和图书结构

mkdir docker-startgitbook initwarn: no summary file in this bookinfo: create README.mdinfo: create SUMMARY.mdinfo: initialization is finished

编辑SUMMARY.md,输入:

* [简介](README.md)* [1.Docker入门](chapter1/README.md) - [1.1 什么是Docker](chapter1/section1.md) - [1.2 Docker基本概念](chapter1/section2.md) - [1.3 安装Docker](chapter1/section3.md) - [1.4 使用Docker镜像](chapter1/section4.md) - [1.5 操作容器](chapter1/section5.md) - [1.6 访问仓库](chapter1/section6.md) - [1.6 数据管理](chapter1/section7.md)* [2.使用Docker部署web应用](chapter2/README.md) - [2.1 编写DockerFile](chapter2/section1.md) - [2.2 编写web应用](chapter2/section2.md) - [2.3 构建镜像](chapter2/section3.md) - [2.4 运行web应用](chapter2/section4.md) - [2.5 分享镜像](chapter2/section5.md)* [结束](end/README.md)

再次执行:

gitbook initinfo: create chapter1/README.mdinfo: create chapter1/section1.mdinfo: create chapter1/section2.mdinfo: create chapter1/section3.mdinfo: create chapter1/section4.mdinfo: create chapter1/section5.mdinfo: create chapter1/section6.mdinfo: create chapter1/section7.mdinfo: create chapter2/README.mdinfo: create chapter2/section1.mdinfo: create chapter2/section2.mdinfo: create chapter2/section3.mdinfo: create chapter2/section4.mdinfo: create chapter2/section5.mdinfo: create end/README.mdinfo: create SUMMARY.mdinfo: initialization is finished

3.2 生成图书

使用:

gitbook serve .Live reload server started on port: 35729Press CTRL+C to quit ...info: 7 plugins are installedinfo: loading plugin "livereload"... OKinfo: loading plugin "highlight"... OKinfo: loading plugin "search"... OKinfo: loading plugin "lunr"... OKinfo: loading plugin "sharing"... OKinfo: loading plugin "fontsettings"... OKinfo: loading plugin "theme-default"... OKinfo: found 16 pagesinfo: found 15 asset filesinfo: >> generation finished with success in 4.0s !Starting server ...Serving book on http://localhost:4000

访问 http://localhost:4000 ,就可以看到图书了

enter description here

编辑生成的md,gitbook会自动Restart,

enter description here

在当前目录下,会生成一个_book目录 ,里面是生成的静态html,可以发布到服务器直接使用。

4. 使用docker发布gitbook书籍

首先 将_book目录里的内容拷贝到一个新目录。

然后编写Dockerfile

FROM nginxWORKDIR /usr/share/nginx/htmlADD . /usr/share/nginx/htmlEXPOSE 80

build:

docker build -t docker-start-web .Sending build context to Docker daemon  4.766MBStep 1/4 : FROM nginx ---> 3f8a4339aaddStep 2/4 : WORKDIR /usr/share/nginx/htmlRemoving intermediate container a4232f4b6b62 ---> 91a66299ecadStep 3/4 : ADD . /usr/share/nginx/html ---> 9a9fef80da3bStep 4/4 : EXPOSE 80 ---> Running in 59f2b829aba6Removing intermediate container 59f2b829aba6 ---> b92c92688046Successfully built b92c92688046Successfully tagged docker-start-web:latest

执行:

docker run -p 4000:80 --name docker-start-web -d docker-start-webf91cf4446b3746c665476b3dd214446a941d838fa9a3ad47680190bb08c9aa48

访问服务器ip:4000就可以查看到了。


作者:Jadepeng

出处:jqpeng的技术记事本--
您的支持是对博主最大的鼓励,感谢您的认真阅读。
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

转载于:https://www.cnblogs.com/xiaoqi/p/gitbook-setup-and-usage-publish-with-docker.html

你可能感兴趣的文章
几种常用数据库字段类型查询语句
查看>>
字符全排列
查看>>
提高效率必须改掉的7种习惯
查看>>
Java判断语句中判断条件的执行顺序
查看>>
Windows平台下tomcat+java的web程序持续占cpu问题调试
查看>>
OO第四次博客作业!
查看>>
HDU 吉哥系列故事——完美队形II 騰訊馬拉松初賽第二輪D題
查看>>
c++学习-继承
查看>>
[转]SQL Server 性能调优(io)
查看>>
设计模式学习-每日一记(6.原型模式)
查看>>
不已0开头的数字正则
查看>>
HTML撑起浮动子元素得父元素高度
查看>>
LeetCode--018--四数之和(java)
查看>>
Redis消息队列
查看>>
电商网站架构设计
查看>>
http://jingyan.baidu.com/article/4dc40848e7b69bc8d946f127.html
查看>>
WCF netTcp配置
查看>>
数据类型转换
查看>>
Nodejs学习笔记(2) 阻塞/非阻塞实例 与 Nodejs事件
查看>>
什么是FreeMaker
查看>>