Summary
A spot check of the mosipid namespace on Docker Hub reveals significant image footprint growth in 1.3.x releases compared to 1.2.x predecessors. For instance, artifactory-server reaches ~1.78 GB and authentication-service (v1.3.0) reaches ~1.19 GB compressed—roughly double earlier releases.
This proposal outlines an automated, policy-driven pipeline to audit container images, profile runtime dependencies, eliminate redundant layer creation, and reduce unpacked image sizes by a targeted 60% to 70%.
Key Operational Targets
-
Pod Startup & Autoscaling: Reduce heavy container startup delays during traffic spikes, targeting pod startup from 3–5 minutes down to under 60 seconds.
-
Kubernetes Storage Efficiency: Lower local node-cache storage pressure across Dev, QA, Pre-Prod, and Production clusters where layer caching multiplies disk consumption.
-
Vulnerability Surface Reduction: Shrink the CVE exposure surface by systematically pruning unused OS packages, build toolchains, and interactive shells.
-
Patching Toil Reduction: Streamline ongoing CVE remediation and engineering triage hours through cleaner base image families and shared build workflows.
Proposed Architecture & Workflow
We propose integrating a 6-stage validation pipeline into MOSIP’s shared build workflows (mosip/kattu):
-
Discover: Automated registry scanning and size audits with exact digest and tag recording.
-
Trace: Profiling runtime system calls and classloader paths under load probes.
-
Slim: Stripping unneeded build tools, package caches, and redundant shells.
-
Scan: Comparing CVE surfaces before and after optimization using consistent scanners (e.g., Trivy, Grype).
-
Validate: Automated functional verification leveraging Spring Boot Actuator (
/actuator/health) and MOSIP’s existing test suites (mosip/test-management,mosip/mosip-functional-tests). -
Promote: Environment-gated deployments managed via Helm charts (
mosip/mosip-helm) and install scripts (mosip/mosip-infra).
Proposed Pilot Scope & Initial Targets
To minimize risk, we propose a staged rollout starting with non-transactional and job-based components:
-
First Pilot (
admin-ui):-
Problem: The image stands at ~1.2 GB unpacked because a single
RUNlayer installsnpm,zip,unzip, andwgeton top of Nginx without cleanup, whereas the served Angular site is only 8 MB. -
Solution: Retain only necessary runtime tools (
wget,unzip), use--no-install-recommends, and purge apt lists. Projected reduction: ~85% cut (~175–185 MB) with zero JVM classloading risk.
-
-
Second Pilot (Spring Boot
chownLayer Fix):-
Problem: A recursive
chown -Rcommand running immediately after aCOPYinstruction duplicates jar files as a new layer in 3 out of 9 audited images (e.g.,resident-serviceadds an identical 377 MB layer;kernel-salt-generatorandkernel-notification-serviceexhibit similar duplication). -
Solution: Replace with
COPY --chowndirectives to prevent duplicate layer storage.
-
-
Core Services & Content Architecture:
- Address
artifactory-server(~1.78 GB, driven largely by a single 1.9 GB content layer) and identity-critical engines (id-authentication,id-repository) only after successful Pre-Prod stress and scale testing.
- Address
Technical Risk Mitigations
-
JVM Classloading: Mitigate static stripping risks for Spring Boot, Apache Camel, and Vert.x by executing runtime load-probe tracing and establishing strict reflection allow-lists.
-
Compatibility Verification: Avoid unverified claims by enforcing automated health and API functional suites in Dev and QA prior to promotion.
-
Traceability: Record original digests, trace reports, and slimmed digests for every build to ensure seamless auditability and rollback paths.
Request for Maintainer Feedback
We would love architectural feedback from the community and core maintainers on:
-
Whether maintainers prefer automated post-build minification or upstream lightweight base image adjustments (e.g., distroless or Alpine JRE).
-
Moving chart defaults from mutable tags (like
1.3.0) to immutable SHA-256 digests. -
Endorsement to proceed with a non-intrusive profiling pilot on feature branches of
mosip/kattu,mosip/mosip-helm, andmosip/mosip-infra.
Looking forward to your thoughts and guidance!