A detailed guide on reducing Docker image sizes for Scala applications from 722 MB to 198 MB using Nix. The approach involves using jre_minimal instead of full JDK, analyzing dependencies with jdeps to include only necessary Java modules, and optimizing Docker image construction with buildEnv to avoid file duplication. The
Table of contents
First attemptMinimal Java Runtime EnvironmentsdockerTools.copyToRoot GotchasComparison with other approachesFinal derivationConclusionSort: