-
Notifications
You must be signed in to change notification settings - Fork 443
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
docker:publishLocal fails on and after 1.7.0 #1365
Comments
Thanks for the detailed report 🥰 . To summarize
The main change in Do you have a minimal reproducible test case? Maybe we can add ubuntu 16.04 as a test system to the integration tests as well and see if this breaks. |
Now I have: https://github.com/kingslef/sbt-native-packager-issue-1365! While creating it, I noticed that adding a file to the docker image actually causes the failure:
I also noticed that I must have had dirty work directory, when I concluded that it works on Mac, as after |
Thanks a lot @kingslef . That clears up things a lot. I'll checkout the test case and let you know |
I can confirm having this issue on MacOS and Linux. |
Does this still happen with |
yeah, still fails. |
Thanks for the fast response 😘 . I'll see if I have time to dig deeper into this |
Happens also on 1.8.0. |
@muuki88 - can confirm it fails for me as well on OSX with latest sbt-native-packager 1.8.0 and docker |
Having this issue as well. It does happen on one of the apps and doesn't on others with exact same plugin setup. Very weird. |
I finally found the time to look into this. So the line that's causing this is Docker / mappings += file(
s"${baseDirectory.value}/src/main/resources/foobar.yaml"
) -> "/res/foobar.yaml" which causes the COPY opt /opt
...
RUN ["chmod", "-R", "u=rX,g=rX", "/opt/docker"] in the Dockerfile, which fails as these folders don't exist: $ tree target/docker/stage
target/docker/stage
├── 1
│ └── opt
│ └── docker
│ ├── bin
│ │ ├── sbt-native-packager-issue-1365
│ │ └── sbt-native-packager-issue-1365.bat
│ └── lib
│ └── org.scala-lang.scala-library-2.13.1.jar
├── 2
│ └── opt
│ └── docker
│ └── lib
│ └── default.sbt-native-packager-issue-1365-1.0.jar
├── Dockerfile
└── res
└── foobar.yaml @ppiotrow it would be amazing if you find time to work on this 😍 I guess the issue is the sbt-native-packager/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala Line 584 in 870e260
|
After tinkering a bit with this, I'm not sure if this a bug, a feature or missing documentation. The build from the sample project can be fixed by adding a Docker / dockerGroupLayers := {
// map the "res" stuff in layer 3
case (_, path) if path.contains("res") => 3
// otherwise fallback to the predefined layering
case in => (Docker / dockerGroupLayers).value(in)
}
// change the path from "/res/foobar.yaml" to "/opt/docker/res/foobar.yaml" as this is the
Docker / mappings += file(
s"${baseDirectory.value}/src/main/resources/foobar.yaml"
) -> "/opt/docker/res/foobar.yaml"
// copy the file also to /res
dockerCommands += Cmd("COPY", s"/${(Docker / defaultLinuxInstallLocation).value}/res", "/res") This is... very cumbersome and unintuitive. If you use the copy command at the moment the
Not sure how much work this is and how much depends on the installation path being part of the staging directory. I want to take a step back and o understand the use case better. Is the |
While implementing this feature I was surprised with |
for me, the idea is to copy a file from the repo to a certain place in the docker image, so having it under
I'm not exactly sure if |
Thanks for the responses :)
But why 😄 ? Is there a specific requirement for a third party library? As @ppiotrow pointed out ususally there's no need to add additional files via the
I do see that the behaviour is counter intuitive. Adding something to the mappings under sbt native packager has validations for your build configuration. Would it have helped you if there was a warning that says something like "you have non standard mapping entries that point to a directory that's not "Docker / linuxDefaultInstallation" and have group layers enabled. Either turn off group layering via ... or add a custom rules like ..." ? |
Hi @muuki88 and @ppiotrow - any update on this issue? I have tried proposed workaround to disabled grouped layers with
|
That's strange. The workaround with now layering work for me. Is the setting applied in the proper scope and actually used? From your log output it seems that it's still using layering. |
Recently I faced same issue and next worded for me. I had mapping defined like:
And then I've added prefix for every file in directory, like:
Bottom line - you need to add sbt-native-packager version: 1.8.0 |
Thanks for sharing @IvannKurchenko 🤗 Let me refine the bottom line You need to add |
@muuki88 thanks for taking care of this issue - I just wanted to mention quickly in response your earlier comment
My team manipulates both We could do this with separate builds & Dockerfiles, but we find it extremely useful to operate our entire stack as a single sbt-managed project, and be able to build/integration test from a single control plane. Just wanted to give more color to how and why those end up getting touched in practice. |
Thanks for sharing @BoopBoopBeepBoop (an amazing display name 😂 ) 🤗 That makes a lot of sense. Especially 3rd party libraries that are not (yet) built for container environments and expect very fixed paths for their configuration or jar files. I'm still not sure what's the way to go here. There are a few options that surfaced from this discussion
I'm open to any other suggestions 😄 |
My gut feeling, for what it is worth, is that documenting the usage of the default path variable is likely enough. Option 3 (prefixing paths) seems a bit too magic & likely to lead to more confusion. |
FWIW I am not using any mappings and I still get this error when using a custom All my sbt native packager config:
This worked until 1.7.0, it works with 1.6.2 |
can we get an update on this? I'm having the issue on Mac |
@simao thanks for the patience. You are not using custom mappings, but you change the Options are to either deactivate layering entirely or to use the default |
As mentioned in #1365 (comment) we most likely will document this behaviour and users that change The docker build is already very complex and adding even more complexity will not solve this 😞 |
I still have publish fail issue on MacOS
|
@jijingg |
I can confirm this when we tried to upgrade from
|
Expected behaviour
sbt docker:publishLocal
creates docker image.Actual behaviour
sbt docker:publishLocal
fails with:Information
1.7.5, but this first appeared on 1.7.0
1.3.13
Ubuntu 16.04
Docker
rpm --version
)19.03.9
Ubuntu 16.04
dockerGroupLayers in Docker := PartialFunction.empty
makes it work but I would like to use the layered docker builds.On another machine, using Mac OS 10.15.6 and Docker version 19.03.12, the same project works.(UPDATE: turns out it fails there too) I compared the differences withsbt docker:stage
and on Ubuntu, thetarget/docker/stage/
folder looks like this:While on Mac, there is the
opt
directory, which doesn't contain anything else than emptydocker/bin
anddocker/lib/
directories:The error looks the same as in #1348, but there is no
docker
folder in the project.The text was updated successfully, but these errors were encountered: