1
1
mirror of https://github.com/foxsen/archbase.git synced 2026-02-03 02:14:40 +08:00

添加了能够生成编译环境的Dockerfile和相应说明。

This commit is contained in:
Zhang Fuxin
2021-10-31 18:18:21 +08:00
parent 628722f38e
commit 37ccc59e62
2 changed files with 54 additions and 0 deletions

View File

@@ -32,6 +32,18 @@
* [PDF](https://foxsen.github.io/archbase/bookdown.pdf). PDF版下载链接。
* [DOCX](https://foxsen.github.io/archbase/bookdown.docx). Word版下载链接其中目录部分需要手工选择下“更新域”才能显示。
## docker环境
虽然github actions已经能够全自动地完成代码编译和部署不过似乎它的环境不太容易在本地复现。为了方便大家复现我们的工作环境写了一个简单的Dockerfile(参见docker/Dockerfile),它安装了能够完整编译本项目代码的相关软件工具。
使用方法:
* 安装docker环境。
* cd docker && sudo docker build -t bookdown .
* docker run -it bookdown /bin/bash然后在docker环境中可以更新代码编译代码。例如: cd /opt/archbase; git pull; make
有兴趣的读者可以参考这个环境来编写自己的书籍或者其他文档,然后大家可以切磋具体的使用方法和技巧。 我们也都是bookdown新手估计有很多用法有改进的空间期待得到大家的反馈。
## 意见反馈
提供开源版本的一个主要目的是为了更好地收集反馈意见。如果您对本书有任何意见或者建议欢迎与我们联系。您可以利用github的各种交互功能与我们联系提交issue、pull request或者私信作者等。

42
docker/Dockerfile Normal file
View File

@@ -0,0 +1,42 @@
from ubuntu:20.04
# select faster mirror
RUN sed -i -e 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list
RUN DEBIAN_FRONTEND=noninteractive apt-get update
# install necessary packages
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y git r-base-core vim
# they are needed to build r packages via renv::restore()
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libxml2-dev \
libfontconfig1-dev libfreetype-dev libcairo2-dev
RUN Rscript -e "install.packages('renv')"
# use renv to recover r environment
RUN cd /opt && git clone --depth 1 https://github.com/foxsen/archbase && cd archbase
RUN cd /opt/archbase && Rscript -e "renv::restore()"
# install tinytex environment for make pdf
RUN Rscript -e "renv::install('tinytex')"
RUN Rscript -e "tinytex::install_tinytex()"
# install Chinese fonts, flextable need used fonts to calculate table width
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y fonts-noto-cjk
# set Chinese locale
RUN apt-get install -y locales
RUN sed -i -e 's/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen
ENV LC_ALL zh_CN.UTF-8
# install pandoc 2.11
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y wget
RUN wget -c https://github.com/jgm/pandoc/releases/download/2.11.4/pandoc-2.11.4-1-amd64.deb && \
dpkg -i ./pandoc-2.11.4-1-amd64.deb && \
rm -f ./pandoc-2.11.4-1-amd64.deb
RUN export PATH=$PATH:/root/bin && cd /opt/archbase && make pdf
WORKDIR /opt/archbase
ENV PATH="$PATH:/root/bin"