Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化Dockerfile,支持真正的跨平台构建镜像 #581

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

wayne-cheng
Copy link
Contributor

@wayne-cheng wayne-cheng commented Aug 16, 2024

项目维护者,你们好。
最近需要在 arm64 架构机器上运行 kkfileview,我尝试通过该项目构建 arm64 架构镜像。
但非常令人沮丧,构建过程相当耗时,而且经常 connect timeout 。
并且我发现原先的 Dockerfile 写得有一些不合理之处,比如清理 apt 缓存文件的命令放到了靠后的单独RUN指令里,这就不会真正地减少镜像体积, 因为这些垃圾文件已经在前面通过RUN指令生成的镜像layer中存在了。
另外,一个简单的 Dockerfile 已经足够同时构建出 x86 和 arm 两种架构的镜像了。也不需要专门写一个 Dockerfile_arm64 文件,这不容易维护。现在的 docker buildx 功能已经相当好用了,我们需要支持它!

因此我重写优化了 kkfileview-jdk 的 Dockerfile 文件。并成功构建出来了 arm64 架构镜像,经测试可以很好的工作。构建过程再也不需要源码编译 libreoffice 这些繁琐的操作。

一些升级点需要注意:
基础镜像使用了 ubuntu:24.04 ,
直接通过 apt install libreoffice 的方式安装了 libreoffice。(对应libreoffice 版本升级到了 24.2.2)
考虑到可能存在的商用字体的版权问题,安装字体的步骤进行了注释和补充说明。
重新写了构建说明文档 README(若你们有需要,我再补充英文的)

Close #580
Close #574

@gitchenjh
Copy link
Member

感谢的PR!英文版的README,最好也补充一下

@wayne-cheng
Copy link
Contributor Author

@gitchenjh 好的,已补充,PTAL!

@wayne-cheng
Copy link
Contributor Author

注意到高版本 ubuntu 已有 nogui 版本的 libreoffice,经过分别构建 x86 和 arm64 架构镜像测试,同样能很好工作。但是镜像大小仅仅缩小了 30~50Mi, 属于聊胜于无的优化吧。

@weiwenying
Copy link

This is a useful improvement

docker/kkfileview-jdk/Dockerfile Outdated Show resolved Hide resolved
docker/kkfileview-jdk/Dockerfile Outdated Show resolved Hide resolved
@gitchenjh gitchenjh merged commit 7825093 into kekingcn:master Aug 22, 2024
1 check passed
@wayne-cheng wayne-cheng deleted the optimize-dockerfile branch August 22, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants