-
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
Docker mappings - incomplete? #424
Conversation
Any thoughts anyone? Shall I raise a PR? |
Sorry for responding so late. Yes, the file is missing. I'm not sure about the meaning of packaging the cc @fiadliel |
The reason to package the DockerFile is down to determining what the best way is to ship a Docker image. You can certainly publish to a repo, but what if I want to pass it around, perhaps even in some offline mode? I don't want to pass the image itself because they are too big. Instead, I want to package the DockerFile and its associated files so that I can pass it around and retain it for posterity. The archive is then quite small. Make sense? I shall work on this PR right now. Thanks. |
The Dockerfile wasn't being included in the `mappings` setting, but it now is. Along the way I took the opportunity of cleaning up how stage works, bringing it more inline with the approach taken by the Universal plugin. One change that occurred as a result of the above is that `target/docker` is now used to generate working files (`Dockerfile`) as well as holding a `stage` folder. The `stage` folder contains the `Dockerfile` for staging add its context files. This is very similar to the structure of the `target/universal` folder.
Provisionally released as |
I considered the Docker target as a runtime "archive", as much as RPMs, Debs, etc. You wouldn't expect the debian/ folder to be present in a Debian package, it just describes how to create a Debian package. Same with RPM SPEC files. The Dockerfile is completely unnecessary for runtime, so I would prefer if it were a choice, not the default. What would you think if we had something like a |
The native packager components have both a staging folder and an archive. Staging is where files are prepared for the purposes of archiving. In the case of Docker archiving is the act of building an image from the staged files and publishing it. There is no All that I've done here (aside from some tidy-up) is added the Does that help? |
@@ -117,9 +116,10 @@ object DockerPlugin extends AutoPlugin { | |||
} | |||
|
|||
val dockerCommands = Seq( | |||
Cmd("ADD", "files /"), | |||
Cmd("ADD", "* /"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always include the Dockerfile, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it will, hence the removal of it further down. I could be more explicit about what is included if you want me to. This seemed like the simpler approach though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the internal path change? I mean, currently it is /opt/docker/<app>
and for me
it looks like /stage/opt/docker/<app>
now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah... the stagingDirectory
is used for this?
Any movement on this? Don't like? |
Just to provide a little more background, we have another plugin named sbt-bundle which is for our new Reactive Runtime project. The idea of this plugin is to take all files for any archive produced by the native packager and we use The user declares a bundleType := Docker The config declared above is then used to scope as sbt-bundle itself has no knowledge of the types of archive that can be produced by the native packager. In fact all that it really wants is the Does this make more sense now? |
I'm willing to merge this pull request as we will do a lot more refactoring Main points users want to customize (and are not yet available ) are
I'm not sure if there should be a single task which generates the list of docker commands.
WDYT? |
Thanks for the review - should we do another release? |
May be we could allow the user to specify a function as a task where the function receives the settings that we already use to form a DockerFile so that they can customise the Dockerfile easily within the context of sbt. So the goal of the function would be a string containing the contents of the Dockerfile. The default setting for this function could be something along the lines of the function we have presently. |
I'll clean up the documentation (at least to a point where every example works for both the 0.8.x and the 1.0.x versions) and the we do another round of releases. Is this weekend early enough for you? |
Sure thing. No rush! Thanks. |
@huntc . This pull request broke most of the docker tests. They all fail with
Did this happen on your system as well? My configuration
|
The PR validator suceeded. The Docker tests also suceeded on my machine (OS X). |
The build is also passing according to the indicator in the README. |
The docker tests don't run on the automated tests, We haven't figured out how to configure We have two options.
IMHO, I prefer option 1 and I'll prepare a bigger refactoring for the docker plugin, which |
DId you run |
I can take a look right now |
Running Now trying the master branch... BTW: Is docker itself working correctly on your machine? Can you do a |
|
OK, the master branch is passing on my machine...
I dunno whether that'd make a difference... |
Which of the docker tests are failing? |
This is a long shot, but could you please try inserting the following: stageDirectory.mkdirs ...before this line: https://github.com/sbt/sbt-native-packager/blob/master/src/main/scala/com/typesafe/sbt/packager/Stager.scala#L22 |
Also, could you trying running the |
Already tried. I get the same error as in all the tests
The |
So you should have a |
Yep. Already did that. I tried it again with this output:
|
I just noticed a commit on Docker that may be having an effect: moby/moby#8076 Can you try upgrading your docker? |
It looks as though Docker is now also at |
My last ubuntu update removed the docker ppas. Still nice to know that we need docker 1.3 or higher? Works now. |
Yep. We need to document this. Most of the strange docker errors come from version gaps |
What also really need are our tests working on CI so that we can enforce the version constraint. Do you want me to raise a PR stipulating |
That would be awesome :) |
Yeah, travis has a problem running Docker - I have another project that would benefit from this. |
PR raised: #448 |
PR sbt#424 moved to a ADD wildcard approach, and then removed the Dockerfile. There were two problems with this: * ADD seems to behave weirdly regarding recursion. /opt/docker and /docker were both added to the output. * I had incorrectly set the current working directory to the parent of the context directory, where it really should be the context directory itself. This only worked because there was a Dockerfile in the parent also.
PR sbt#424 moved to a ADD wildcard approach, and then removed the Dockerfile. There were two problems with this: * ADD seems to behave weirdly regarding recursion. /opt/docker and /docker were both added to the output. * I had incorrectly set the current working directory to the parent of the context directory, where it really should be the context directory itself. This only worked because there was a Dockerfile in the parent also.
PR sbt/sbt-native-packager#424 moved to a ADD wildcard approach, and then removed the Dockerfile. There were two problems with this: * ADD seems to behave weirdly regarding recursion. /opt/docker and /docker were both added to the output. * I had incorrectly set the current working directory to the parent of the context directory, where it really should be the context directory itself. This only worked because there was a Dockerfile in the parent also.
I've just noticed that
docker:mappings
does not include theDockerFile
that is produced. Thesbt-bundle
plugin usesdocker:mappings
as a general approach to including files when staging or producing a dist (it actually doesn't know anothing about the 'docker' config as this a setting to it). Shoulddocker:mappings
also include theDockerFile
itself? I'm thinking so...As an alternative the
File
result ofstage
could be used... only again it does not include theDockerFile
as it points to/files
. I'd prefer to use mappings though anyhow given that it retains the relative path.What are your thoughts?
mappings
appears to be inclusive of the entire package with the other configurations doesn't it? /cc @jsuereth