-
Notifications
You must be signed in to change notification settings - Fork 436
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
Resources defined through mappings not copied into Docker #1349
Comments
Thanks for the detailed issue description. Let's unwrap this 😃 Setup and intentionsI assume what you are trying to do is packaging your frontend assets (scalajs) into the resulting server so they can be served. You have split up your build in two modules The actual errorI assume that the assets are not properly being served? How toBecause the If my assumption about the actual error is correct than you are like me and a lot of other jvm developers 😂 Loading resources from jars on the classpath is somewhat error prone and painful to debug on the jvm. Can you post the actual problem you are facing if I'm mistaken 😄 |
Hi @muuki88, What I wantIt is pretty easy actually: I need in my docker both my server applicatons and jars as well as my frontend assets in the same place. Something like in /opt/docker/:
What I haveOnly the first two directories (bin and lib), and not the webapp one. HowI try copy my frontend stuff in the /opt/docker/webapp with the Is the way I do is the way to do ? If yes, what is my mistake ? |
Thanks for the clarification @mathieuleclaire 😃 Can you show the output of $ sbt "show server / Docker / mappings" It should show all files that end up in the docker image. If the files don't appear there, then it's a configuration error, if they do, then there's a bug in native-packager. Does the // or similar
getClass.getClassLoader.getInputStream("/webapp/styles.css") Most scala http servers have built in support for this, e.g. akka getResourceDirectory |
I ran
The thing I observe is the frontend resources are not mapped in the
|
Well, I fixed my problem. But I am not very sure how (and I do not like this !) Here is the working snippet for memory: val prefix = "/opt/docker/application/target"
lazy val application = project.in(file("application")) settings (defaultSettings) dependsOn(server) enablePlugins (JavaServerAppPackaging) settings(
mappings in Docker ++= Seq(
(dependencyFile in client in Compile).value -> s"$prefix/webapp/js/connect-deps.js",
(fullOptJS in client in Compile).value.data -> s"$prefix/webapp/js/connect.js"
) ++ doMapping((resourceDirectory in client in Compile).value, prefix)
++ doMapping((cssFile in client in target).value, s"$prefix/webapp/css/"),
packageName in Docker := "openmole-connect",
organization in Docker := "openmole"
) |
Thanks for sharing. This is strange. The The docker plugin is quite complex due to the nature of docker being complex. I'll leave this open as there's |
I am trying to package a scala server app into a Docker
Expected behaviour
I am suppose to get my
application
and a directory with some resources in the docker image.Actual behaviour
Only
application
in/opt/docker/bin
and dependency jars inopt/docker/lib
are copied.The resources defined through the
mappings
mechanism are not copied.Information
I use:
Note: the doMapping function fetch recursively all the resources contained in directories.
Note that my
target/webapp
directory seems to be properly copied intarget/docker/stage/opt/docker/target/webapp
but not in the docker itself.The generated Docker instructions look like this:
The text was updated successfully, but these errors were encountered: