:sectnums:
:toc:
:source-highlighter: rouge
:uri-tp-pdf-links: https://gitlab.com/danyill/pdf-hyperlinking-play
环境说明
本Docker容器是原始Asciidoctor Docker容器的高度修改版本,提供一系列适用于CI环境的工具,包括:
- Asciidoctor 2.0.10
- Asciidoctor.js
- Asciidoctor Diagram(集成Graphviz、Vega、Seqdiag、NetworkDiag、Blockdiag,支持多种图表生成)
- Asciidoctor PDF(测试版)
- Asciidoctor EPUB3(alpha版)
- 代码高亮(支持Rouge、CodeRay或Pygments)
- Asciidoctor后端
- Asciidoctor-confluence
- Lazybones(用于Asciidoctor-revealjs)
- Inkscape
- Node 10.x、npm和yard
- 多种定制PDF处理工具(详见{uri-tp-pdf-links}[此处])
使用方法
直接运行以下命令:
[source,bash]
docker run -it -v <你的目录>:/documents/ danyill/docker-asciidoctor
该命令会将你的目录映射到容器内的/documents路径。
启动后,你只需在上述目录中创建AsciiDoc文件,然后运行以下Asciidoctor命令:
[source,bash]
asciidoctor sample.adoc
asciidoctor-pdf sample.adoc
asciidoctor-epub3 sample.adoc
[source,bash]
asciidoctor -r asciidoctor-diagram sample-with-diagram.adoc
asciidoctor-pdf -r asciidoctor-diagram sample-with-diagram.adoc
asciidoctor-epub3 -r asciidoctor-diagram sample-with-diagram.adoc
- 使用Asciidoctor-backends:使用
-T参数指定/asciidoctor-backends或$BACKENDS路径及所需后端,例如:
[source,bash]
asciidoctor -T /asciidoctor-backends/slim/dzslides myFile.adoc
asciidoctor -T $BACKENDS/slim/dzslides myFile.adoc
- 使用asciidoctor-confluence:
[source,bash]
asciidoctor-confluence --host 主机名 --spaceKey 空间键 --title 标题 --username 用户名 --password 密码 sample.adoc
[source,bash]
docker run --rm -v $(pwd):/documents/ danyill/docker-asciidoctor asciidoctor-pdf index.adoc
更新容器
修改后执行以下步骤:
- 在工作目录中构建镜像:
[source,bash]
docker build --tag danyill/docker-asciidoctor:latest .
- 直接从GitHub仓库构建:
[source,bash]
docker build -t danyill/docker-asciidoctor:latest ***:danyill/docker-asciidoctor.git
-
使用docker login登录Docker。
-
推送新镜像:
[source,bash]
docker push danyill/docker-asciidoctor:latest
- 发布版本:
[source,bash]
git tag -m "Release" -s v1.x.x && git push --tags
docker build --tag danyill/docker-asciidoctor:1.x.x .
docker build --tag danyill/asciidoctor:latest .
docker push danyill/docker-asciidoctor:1.x.x
docker push danyill/docker-asciidoctor:latest
错误检查
在容器内运行bash:
[source,bash]
docker run -i -t danyill/docker-asciidoctor bash
如果构建失败,获取上一个工作层的哈希值并进入:
[source,bash]
docker run --rm -it <上一个工作层ID> bash -il
然后运行Dockerfile中的上一条命令并检查日志。