Automating Dockerfile Refactoring to Multi-stage Builds
Dongjin Chen, Wenhua Yang, Minxue Pan, Yu Zhou
摘要
Containerization has become a cornerstone of modern software deployment, yet many projects still ship single-stage Dockerfiles that bundle compilers, build tools, and temporary files into production images, thereby hurting performance and security. Multi-stage builds are recommended, yet uptake appears uneven, plausibly because refactoring legacy Dockerfiles demands nontrivial reasoning about build lifecycles and dependency separation. This paper presents StageCraft, an automated refactoring approach that converts single-stage Dockerfiles into optimized multi-stage builds. StageCraft first performs static analysis to identify the technology stack and to infer build-time and runtime dependencies. It then applies a lightweight gate that estimates the refactoring benefit from a composite of image bloat, structural inefficiency, and security risk, proceeding only when refactoring is warranted. Finally, it synthesizes a multi-stage Dockerfile that isolates build tooling, copies only the artifacts needed at runtime, and applies production hardening. Evaluated on 521 real-world single-stage projects, StageCraft successfully produced working multi-stage Dockerfiles for 60.3% of targets. The resulting images were, on average, 52.2% smaller and contained 50.0% fewer high-risk vulnerabilities than the originals, outperforming baselines. StageCraft lowers the barrier to multi-stage adoption at scale, yielding leaner images with a reduced attack surface and improved maintainability. We release the tool, its knowledge assets, and the evaluation dataset to support reproducibility and future research.
问 Lune
几分钟看清这篇 Paper 的位置,不用再花一下午。
Lune 能读引用它和与它最相关的顶会 Paper,讲清它说了什么、后来怎样、哪里站不住,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
相关 Paper
- Refactorings and Technical Debt in Docker Projects: An Empirical StudyEmna Ksontini, Marouane Kessentini, Thiago do Nascimento Ferreira, Foyzul HassanASE 2021 · 17 次引用
- Shipwright: A Human-in-the-Loop System for Dockerfile RepairJordan Henkel, Denini Silva, Leopoldo Teixeira, Marcelo d'Amorim 等ICSE 2021 · 31 次引用
- Dr. Docker: A Large-Scale Security Measurement of Docker Image EcosystemHequan Shi, Lingyun Ying, Libo Chen, Haixin Duan 等WWW 2025 · 1 次引用
- Empirical Study of the Docker Smells Impact on the Image SizeThomas DurieuxICSE 2024 · 11 次引用
- Automatic Dockerfile Generation with Large Language ModelsJun Lyu, He Zhang, Yusong Yuan, Lanxin Yang 等ICSE 2026
