Implementation and Analysis of Container Image Optimization Using Alpine Linux and Multi-Stage Builds - Mochamad Rizal Fachrudin; Arif Saivul Affandi (Teknika, 2025)
Containerization enables isolation within a host, with Docker being a popular tool for packaging applications and their dependencies in container images. However, challenges like slow build processes and bloated image sizes can consume resources, slow down builds, and pose security risks. This study optimizes Docker images by combining the Alpine base image with multi-stage builds, analyzing size, build speed, and security across different combinations and environments to identify and propose the most efficient combination solution. The approach used is a quantitative quasi-experiment with a within-subject design. The sample used was a JavaScript framework, with the main experimental group being the combination of Alpine and multi-stage builds, while the comparison group included combinations of Node and Node-Alpine, both in single-stage and multi-stage configurations, as well as single-stage Alpine. Data was obtained from CI/CD, container registry, and Trivy reports. Analyzed by descriptive analysis, One-Way ANOVA or Kruskal Wallis test, and post-hoc test. The results show that combining multi-stage builds with Alpine is considered best practice because it produces the smallest image size, reducing it by up to 94% compared to single-stage Node. It also achieves the shortest build times across all environments and presents low vulnerability issues. However, it is important to note that while the Alpine multi-stage combination offers the most efficient build times, it experiences a 1.3x increase in duration in low-spec environments.