惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
Latest news
Latest news
Help Net Security
Help Net Security
S
Security Affairs
Webroot Blog
Webroot Blog
The Hacker News
The Hacker News
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
Forbes - Security
Forbes - Security
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Help Net Security
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
Cyberwarzone
Cyberwarzone
The Last Watchdog
The Last Watchdog
S
Securelist
N
News and Events Feed by Topic
S
Secure Thoughts
F
Fortinet All Blogs
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
量子位
M
MIT News - Artificial intelligence
F
Full Disclosure
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
P
Privacy International News Feed
L
LangChain Blog
Know Your Adversary
Know Your Adversary
C
CERT Recently Published Vulnerability Notes

Hunsh's Blog

生成个人的 Github PR List 如何选择合适的加密手段 Nginx SNI Proxy 如何优雅导入 k8s.io/kubernetes Make Go mod and Git to use specify .netrc 使用 buildkit 进行多架构构建并提取产物 如何修改镜像 layer(以 sourcemap-less grafana 为例) acme.sh 自动化 Google CA 申请证书 微信小程序嵌入任意公众号文章 k8s && bazel 项目从 go1.20 升级 go1.21 go serve http and https on same port typecho 迁移到 hexo 实现 hexo 文章和资源在同一目录下 golang mitm 遇到的问题 流式数据专用的 mine-type Golang 正向代理对于 Host 的处理 (RFC 7230) 分享 MacOS 的一些系统fix脚本(dns、sleep) prometheus rate/increase/delta/sum等函数不符合预期或出现小数的原理 [油猴脚本] USTB Everywhere 为校外访问添加访问任意网站的能力
多架构镜像的体积优化
2024-05-05 · via Hunsh's Blog

因为 bazel 用的多,然后也深入阅读并贡献过 rules_oci,所以我对镜像结构和内容的异常会比较敏感。

其实是在弄 sourcemap-less grafana
的时候发现的。

grafana 的镜像当中有前端部分也有后端部分,后端是 go 二进制。我当时在看 blobs 列表的时候就发现不对,有三个蛮大的 blob 的 size 一致。然后就去看了下内容,是前端构建产物。

于是我提了这个 issue grafana/grafana#83079

其实三份前端产物都是一模一样的,那么为什么他们会成为三个 blobs 没有复用呢(如果使用 rules_oci 这完全是不可思议的)。

原因蛮有意思的。

文件确实一样,都是 Dockerfile 当中使用 COPY --from 或者 ADD 从同一个前端构建源拿到的。但是他们的时间不一致。然后所有目录/文件的时间都记录在了 tar 当中,所以 sha256 不一致。

由于多架构的构建速度不一致,ADD 进去的时间不一致,导致父目录时间不一致。

当 buildkit 将 tar 内容写入 /path/to/target,会隐式得导致这个目录 mtime 发生变化(这并不是 buildkit 期望的,但是确实发生了)。

为了避免这个问题,可以使用 buildkit >= 13.0,使用 SOURCE_DATE_EPOCH 对新的 layer 的 mtime 进行统一修改(虽然这会导致 tar 的 mtime 丢失,但是是目前唯一的解法)

我提了一个 issue 在 moby/moby#47438