Skip to content

Commit

Permalink
Docker image add support for other mdbook backends
Browse files Browse the repository at this point in the history
Signed-off-by: Hollow Man <[email protected]>
  • Loading branch information
HollowMan6 committed Apr 9, 2023
1 parent 0131e0e commit 05a81e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ RUN pip3 install --no-cache-dir /mdbook-pdf \
COPY --from=builder /usr/local/cargo/bin/mdbook-pdf /usr/local/bin/mdbook-pdf
COPY --from=builder /usr/local/cargo/bin/mdbook /usr/local/bin/mdbook
WORKDIR /book

# Add other mdbook backend at /mdbook dir
ENV PATH="$PATH:/mdbook"

ENTRYPOINT [ "mdbook", "build" ]
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ title = "An Example"
Finally you can build your book and get the PDF file with `mdbook build` command, your PDF file will be available at `book/pdf/output.pdf`.

## Run with Docker
You can also use this [docker image](https://hub.docker.com/r/hollowman6/mdbook-pdf) if your book doesn't have dependencies other than mdBook.
You can also use this [docker image](https://hub.docker.com/r/hollowman6/mdbook-pdf).

```bash
docker run --rm -v /path/to/book:/book hollowman6/mdbook-pdf
```

If your book have other Rust dependencies, you can install them on your local machine (if using Linux), or if you are not using Linux, download the Linux executables of corresponding architecture to a dir, replace `~/.cargo/bin` with your path.

```bash
docker run --rm -v /path/to/book:/book -v ~/.cargo/bin:/mdbook hollowman6/mdbook-pdf
```

## Configuration
Support customize PDF paper orientation, scale of the webpage rendering, paper width and height, page margins, generated PDF page ranges, whether to display header and footer as well as customize their formats, and more.

Expand Down
8 changes: 7 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,18 @@ title = "An Example"
最后,您可以使用 `mdbook build` 命令生成书籍并获取PDF文件,您的PDF文件将被存放在`book/pdf/output.put`

## 使用 Docker 运行
如果你的书没有 mdBook 以外的依赖项,你也可以使用这个 [docker image](https://hub.docker.com/r/hollowman6/mdbook-pdf)
你也可以使用这个 [docker image](https://hub.docker.com/r/hollowman6/mdbook-pdf)

```bash
docker run --rm -v /path/to/book:/book hollowman6/mdbook-pdf
```

如果你的书有其他 Rust 依赖项,你可以在你的本地机器上安装它们(如果使用 Linux),或者如果你的当前操作系统不是 Linux,将对应架构的 Linux 可执行文件下载到一个目录,用该目录路径替换 `~/.cargo/bin`

```bash
docker run --rm -v /path/to/book:/book -v ~/.cargo/bin:/mdbook hollowman6/mdbook-pdf
```

## 配置
支持自定义PDF纸张方向、页面缩放比例、纸张宽度和高度、页面边距、生成的PDF页面范围、是否显示页眉和页脚以及自定义其格式等。

Expand Down

0 comments on commit 05a81e9

Please sign in to comment.