-
Notifications
You must be signed in to change notification settings - Fork 447
Separate Docker Layers for Dependencies and App jars. #1310
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
74edf03
Docker Layers separate for Dependencies and App jars.
ppiotrow 5f963df
Use indexed layers to allow flexibility
ppiotrow b797843
avoid mapping `dockerPackageMappings`
ppiotrow b379997
Calculate `dockerLayerMappings` once
ppiotrow e0a3a53
Dirty version that supports PR code review remarks
ppiotrow 657c673
Fix chmod for layers
ppiotrow 8000b39
Revert changes around Docker / mappings
ppiotrow 73491bb
Revert changes dockerLayerMappings
ppiotrow ee640e9
Documenting `dockerLayerGrouping`
ppiotrow 4a36f9e
Testing layer groups
ppiotrow 85f2749
fix tests
ppiotrow dec9481
fix more tests
ppiotrow 4b322e3
Version that might pass the tests
ppiotrow a8f2a41
Fix import for sbt 0.1.x
ppiotrow 87e7c6a
scalafmt
ppiotrow bebd7df
Experiment with Option[Int] for layer mapping
ppiotrow b501896
Docker tests of opt-out from layering
ppiotrow b8f966b
Test of dockerPackageMappings
ppiotrow 4cc6b52
Documentation
ppiotrow 48fd086
Merge branch 'master' into docker-dependencies-split-app
ppiotrow a6d2427
Merge branch 'master' into docker-dependencies-split-app
ppiotrow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/scala/com/typesafe/sbt/packager/docker/LayeredMapping.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.typesafe.sbt.packager.docker | ||
|
|
||
| import java.io.File | ||
|
|
||
| /** | ||
| * Mapping of file to layers | ||
| * | ||
| * @param layerId The identifier in the layer used to increase cache hits in | ||
| * docker caching. LayerId is present in docker:stage directory structure | ||
| * and in intermediate image produced in the multi-stage docker build. | ||
| * @param file The file produced by universal/stage to be moved into docker/stage directory. | ||
| * @param path The path in the final image | ||
| */ | ||
| case class LayeredMapping(layerId: Option[Int], file: File, path: String) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # Generate the Docker image locally | ||
| > docker:publishLocal | ||
| $ exists target/docker/stage/Dockerfile | ||
| $ exists target/docker/stage/opt/docker/bin/docker-exec | ||
| $ exists target/docker/stage/1/opt/docker/bin/docker-exec | ||
| > checkDockerfile | ||
| $ exec bash -c 'docker run docker-package:0.1.0 | grep -q "Hello world"' | ||
| $ exec bash -c 'docker run docker-package:0.1.0 | grep -q "Hello world"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
| enablePlugins(JavaAppPackaging) | ||
|
|
||
| organization := "com.example" | ||
| name := "docker-groups" | ||
| version := "0.1.0" | ||
|
|
||
| dockerLayerGrouping in Docker := { | ||
| val dockerBaseDirectory = (defaultLinuxInstallLocation in Docker).value | ||
| (path: String) => | ||
| { | ||
| val pathInWorkdir = path.stripPrefix(dockerBaseDirectory) | ||
| if (pathInWorkdir.startsWith(s"/lib/${organization.value}")) | ||
| Some(2) | ||
| else if (pathInWorkdir.startsWith("/bin/")) | ||
| Some(123) | ||
| else None | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) |
3 changes: 3 additions & 0 deletions
3
src/sbt-test/docker/test-layer-groups/src/main/scala/Main.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| object Main extends App { | ||
| println("Hello world") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Generate the Docker image locally | ||
| > docker:publishLocal | ||
| $ exists target/docker/stage/Dockerfile | ||
| $ exists target/docker/stage/123/opt/docker/bin/docker-groups | ||
| $ exists target/docker/stage/opt | ||
| $ exists target/docker/stage/2 | ||
|
|
||
| $ exec bash -c 'docker run --entrypoint=ls docker-groups:0.1.0 |tr "\n" "," | grep -q "bin,lib"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # Generate the Docker image locally | ||
| > docker:publishLocal | ||
| $ exists target/docker/stage/Dockerfile | ||
| $ exists target/docker/stage/opt/docker/bin/docker-test | ||
| $ exists target/docker/stage/1/opt/docker/bin/docker-test | ||
| > checkDockerfile | ||
| $ exec bash -c 'docker run docker-package:0.1.0 | grep -q "Hello world"' | ||
| $ exec bash -c 'docker run docker-package:0.1.0 | grep -q "Hello world"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # Generate the Docker image locally | ||
| > docker:publishLocal | ||
| $ exists target/docker/stage/Dockerfile | ||
| $ exists target/docker/stage/opt/docker/bin/docker-test | ||
| $ exists target/docker/stage/1/opt/docker/bin/docker-test | ||
| > checkDockerfile | ||
| $ exec bash -c 'docker run docker-package:0.1.0 | grep -q "Hello world"' | ||
| $ exec bash -c 'docker run docker-package:0.1.0 | grep -q "Hello world"' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.