From 05a81e934d14e5f5d7b4142f12ccc33e73b551cb Mon Sep 17 00:00:00 2001 From: Hollow Man Date: Sun, 9 Apr 2023 18:02:26 +0300 Subject: [PATCH] Docker image add support for other mdbook backends Signed-off-by: Hollow Man --- Dockerfile | 4 ++++ README.md | 8 +++++++- README_CN.md | 8 +++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9f7caad..d075f38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] diff --git a/README.md b/README.md index 09ec293..97b97ae 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/README_CN.md b/README_CN.md index 255599f..74de4c5 100644 --- a/README_CN.md +++ b/README_CN.md @@ -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页面范围、是否显示页眉和页脚以及自定义其格式等。