1
- FROM amd64/ golang:1.18.1 AS build
1
+ FROM golang:bookworm AS build
2
2
3
3
ARG TAG=0.0.1
4
4
@@ -30,8 +30,8 @@ ADD simsun.ttc /usr/share/fonts/win/
30
30
ADD start.sh /go/src/github.com/mindoc-org/mindoc
31
31
32
32
33
- # Ubuntu 20.04
34
- FROM ubuntu:focal
33
+ # upgrade to the latest
34
+ FROM ubuntu:latest
35
35
36
36
# 切换默认shell为bash
37
37
SHELL ["/bin/bash" , "-c" ]
@@ -52,30 +52,11 @@ COPY --from=build /go/src/github.com/mindoc-org/mindoc/uploads /mindoc/__default
52
52
53
53
RUN chmod a+r /usr/share/fonts/win/simsun.ttc
54
54
55
- # 备份原有源
56
- RUN mv /etc/apt/sources.list /etc/apt/sources.list-backup
57
- # 最小化源,缩短apt update时间(ca-certificates必须先安装才支持换aliyun源)
58
- RUN echo 'deb http://archive.ubuntu.com/ubuntu/ focal main restricted' > /etc/apt/sources.list
59
- RUN apt-get update
60
- RUN apt install -y ca-certificates
61
- # 更换aliyun源(echo多行内容不能以#开头,会被docker误判为注释行,所以采用\n#开头)
62
- RUN echo $'\
63
- deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse\
64
- \n # deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse\n \
65
- deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse\
66
- \n # deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse\n \
67
- deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse\
68
- \n # deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse\n \
69
- deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse\
70
- \n # deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse\n \
71
- deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse\
72
- \n # deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse' \
73
- > /etc/apt/sources.list
55
+ RUN sed -i "s/archive.ubuntu.com/mirrors.aliyun.com/g" /etc/apt/sources.list /etc/apt/sources.list.d/*
56
+
74
57
75
58
# 更新软件包信息
76
59
RUN apt-get update
77
- # 安装必要的系统工具
78
- RUN apt install -y apt-transport-https ca-certificates curl wget xz-utils
79
60
80
61
# 时区设置(如果不设置, calibre依赖的tzdata在安装过程中会要求选择时区)
81
62
ENV TZ=Asia/Shanghai
@@ -87,38 +68,33 @@ RUN apt install -y --no-install-recommends tzdata
87
68
# 重新配置tzdata软件包,使得时区设置生效
88
69
RUN dpkg-reconfigure --frontend noninteractive tzdata
89
70
90
- # 安装 calibre 依赖的包
91
- RUN apt install -y libgl-dev libnss3-dev libxcomposite-dev libxrandr-dev libxi-dev libxdamage-dev
92
71
# 安装文泉驿字体
93
- RUN apt install -y fonts-wqy-microhei fonts-wqy-zenhei
94
72
# 安装中文语言包
95
- RUN apt-get install -y locales language-pack-zh-hans language-pack-zh-hans-base
73
+ RUN apt install -y fonts-wqy-microhei fonts-wqy-zenhei locales language-pack-zh-hans-base
96
74
# 设置默认编码
97
75
RUN locale-gen "zh_CN.UTF-8"
98
76
RUN update-locale LANG=zh_CN.UTF-8
99
77
ENV LANG=zh_CN.UTF-8
100
78
ENV LANGUAGE=zh_CN:en
101
79
ENV LC_ALL=zh_CN.UTF-8
102
80
103
- # 安装- calibre
104
- # RUN apt-get install -y calibre # 此种方式安装省事,但会安装很多额外不需要的软件包,导致体积过大
105
- RUN mkdir -p /tmp/calibre-cache
106
- # 强制使用 5.44.0 版本(5.x的最新版本)
107
- RUN wget -O /tmp/calibre-cache/calibre-x86_64.txz -c https://download. calibre-ebook.com/5.44.0/calibre-5.44.0-x86_64.txz
108
- # 注: 调试阶段,下载alibre-5.44.0- x86_64.txz到本地(使用 python -m http.server),加速构建
109
- # RUN wget -O /tmp/calibre-cache/calibre-x86_64.txz -c http://10.96.8.252:8000/ calibre-5.44.0-x86_64.txz
110
- # 解压
111
- RUN mkdir -p /opt/calibre
112
- # RUN tar --extract --file=/tmp/calibre-cache/calibre-x86_64.txz --directory /opt/calibre
113
- RUN tar xJof /tmp/calibre-cache/calibre-x86_64.txz -C /opt/calibre
114
- ENV PATH=$PATH: /opt/calibre
115
- # 设置calibre相关环境变量
116
- ENV QTWEBENGINE_CHROMIUM_FLAGS= "--no-sandbox "
117
- ENV QT_QPA_PLATFORM= 'offscreen'
118
- # 测试 calibre 可正常使用
81
+ # 安装必要依赖、下载、解压 calibre 并清理缓存
82
+ RUN apt-get install -y --no-install-recommends \
83
+ libgl-dev libnss3-dev libxcomposite-dev libxrandr-dev libxi-dev libxdamage-dev \
84
+ wget xz-utils && \
85
+ mkdir -p /tmp/calibre-cache /opt/ calibre && \
86
+ wget -O /tmp/calibre-cache/calibre-x86_64.txz -c https://download.calibre-ebook.com/7.26.0/calibre-7.26.0- x86_64.txz && \
87
+ tar xJof /tmp/calibre-cache/calibre-x86_64.txz -C /opt/ calibre && \
88
+ rm -rf /tmp/calibre-cache && \
89
+ apt-get clean && rm -rf /var/lib/apt/lists/*
90
+
91
+ # 设置环境变量
92
+ ENV PATH=" /opt/calibre:$PATH" \
93
+ QTWEBENGINE_CHROMIUM_FLAGS= "--no-sandbox" \
94
+ QT_QPA_PLATFORM= "offscreen "
95
+
96
+ # 测试 calibre 是否可正常使用
119
97
RUN ebook-convert --version
120
- # 清理calibre缓存
121
- RUN rm -rf /tmp/calibre-cache
122
98
123
99
# refer: https://docs.docker.com/engine/reference/builder/#volume
124
100
VOLUME ["/mindoc/conf" ,"/mindoc/static" ,"/mindoc/views" ,"/mindoc/uploads" ,"/mindoc/runtime" ,"/mindoc/database" ]
0 commit comments