Skip to content

Commit f37c4c3

Browse files
ydfadmin
and
admin
authored
upgrate dockerfile (#994)
* [docker] try upgrade docker version * [docker] try fix docker file and upgrade calibre to new * [docker] try fix docker file * [github] try upgrade workflow --------- Co-authored-by: admin <[email protected]>
1 parent 886a412 commit f37c4c3

File tree

2 files changed

+25
-49
lines changed

2 files changed

+25
-49
lines changed

.github/workflows/build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ jobs:
3030
- uses: actions/checkout@v3
3131

3232
- name: Set up Go
33-
uses: actions/setup-go@v3
33+
uses: actions/setup-go@v5
3434
with:
35-
go-version: 1.20.0
35+
go-version: 1.24.0
3636

3737
- name: Build
3838
run: |
@@ -43,7 +43,7 @@ jobs:
4343
# run: go test -v ./...
4444

4545
- name: Upload Artifact
46-
uses: actions/upload-artifact@v3
46+
uses: actions/upload-artifact@v4
4747
with:
4848
path: |
4949
conf/**/*

Dockerfile

+22-46
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM amd64/golang:1.18.1 AS build
1+
FROM golang:bookworm AS build
22

33
ARG TAG=0.0.1
44

@@ -30,8 +30,8 @@ ADD simsun.ttc /usr/share/fonts/win/
3030
ADD start.sh /go/src/github.com/mindoc-org/mindoc
3131

3232

33-
# Ubuntu 20.04
34-
FROM ubuntu:focal
33+
# upgrade to the latest
34+
FROM ubuntu:latest
3535

3636
# 切换默认shell为bash
3737
SHELL ["/bin/bash", "-c"]
@@ -52,30 +52,11 @@ COPY --from=build /go/src/github.com/mindoc-org/mindoc/uploads /mindoc/__default
5252

5353
RUN chmod a+r /usr/share/fonts/win/simsun.ttc
5454

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+
7457

7558
# 更新软件包信息
7659
RUN apt-get update
77-
# 安装必要的系统工具
78-
RUN apt install -y apt-transport-https ca-certificates curl wget xz-utils
7960

8061
# 时区设置(如果不设置, calibre依赖的tzdata在安装过程中会要求选择时区)
8162
ENV TZ=Asia/Shanghai
@@ -87,38 +68,33 @@ RUN apt install -y --no-install-recommends tzdata
8768
# 重新配置tzdata软件包,使得时区设置生效
8869
RUN dpkg-reconfigure --frontend noninteractive tzdata
8970

90-
# 安装 calibre 依赖的包
91-
RUN apt install -y libgl-dev libnss3-dev libxcomposite-dev libxrandr-dev libxi-dev libxdamage-dev
9271
# 安装文泉驿字体
93-
RUN apt install -y fonts-wqy-microhei fonts-wqy-zenhei
9472
# 安装中文语言包
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
9674
# 设置默认编码
9775
RUN locale-gen "zh_CN.UTF-8"
9876
RUN update-locale LANG=zh_CN.UTF-8
9977
ENV LANG=zh_CN.UTF-8
10078
ENV LANGUAGE=zh_CN:en
10179
ENV LC_ALL=zh_CN.UTF-8
10280

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 是否可正常使用
11997
RUN ebook-convert --version
120-
# 清理calibre缓存
121-
RUN rm -rf /tmp/calibre-cache
12298

12399
# refer: https://docs.docker.com/engine/reference/builder/#volume
124100
VOLUME ["/mindoc/conf","/mindoc/static","/mindoc/views","/mindoc/uploads","/mindoc/runtime","/mindoc/database"]

0 commit comments

Comments
 (0)