-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize Docker image layering #1677
Comments
Hi @dwickern That's indeed very wasteful. I remember vaguely that this was solved at one point, but apparently not 😢 I assume this can be fixed by re-ordering the sbt-native-packager/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala Lines 188 to 271 in 03f8a0e
|
It's actually sbt-native-packager/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala Lines 108 to 140 in 03f8a0e
#1425 made some improvements before. The layering is pretty good for most applications. The issue is Play Framework outputs additional jars besides the default |
The default layering is not great for Play Framework applications. Here I create a fresh app and print the layers:
The biggest issue is that application artifacts are put in the same layer as libraryDependencies. The library dependencies are 43MB for this play-scala-seed app and much larger for any real application. Dependencies change less frequently compared to application code so we should be able to cache them across builds.
Current layers
Here's how the layers are currently structured:
Layer 1
conf/application.ini
if usingUniversal / javaOptions
conf/
)Layer 2
libraryDependencies
LauncherJarPlugin
-assets.jar
and-sans-externalized.jar
jarsLayer 3
JlinkPlugin
Layer 4
ClasspathJarPlugin
Final layer (
layerId = None
)Docker / sourceDirectory
includeDocumentationInBinary := true
(default true)Proposed layers
At minimum we should move the project artifacts out from layer 2.
Config files shouldn't be the bottom layer. They are only a few KB so it doesn't matter to cache them.
Should jlink files be layered below libraryDependencies? I would guess they change less frequently but I don't use jlink 🤷
The text was updated successfully, but these errors were encountered: