Skip to content
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

Use spotify docker-client for docker:publishLocal goal #658

Merged
merged 1 commit into from
Sep 8, 2015

Conversation

gbougeard
Copy link
Contributor

Handle #558 only for publishLocal.

publish is a little bit complex as it requires to handle push to private repositories and credentials.

@muuki88
Copy link
Contributor

muuki88 commented Sep 1, 2015

Sweet. Looks pretty simple to me. One big thing. We shouldn't replace the native implementation, but instead provide a plugin overriding the native task. See the JDebPackaging as an example

@gbougeard
Copy link
Contributor Author

You mean not just a val dockerUseNativeClient = SettingKey[Boolean]("dockerUseNativeClient", "Use native client for publishLocal") ?
You prefer to transform object DockerPlugin into trait DockerPluginLike and a object DockerPluginNative and object DockerPluginClient ?
I'm not familiar with sbt plugins development yet :)

@muuki88
Copy link
Contributor

muuki88 commented Sep 1, 2015

I had to do this for the Debian stuff as it's a lot more messy and it was written before autoplugins were introduced.

So for docker you would put exactly your code in a DockerSpotifyClientPlugin autoplugin that requires the normal DockerPlugin. SBT then loads the DockerPlugin, which sets all sensible defaults. After that the DockerSpotifyClientPlugin gets initialised and overwrites all the "native" task, that that use the CLI.

By this we keep the Spotify part to a minimum and makes use of improvements in the core plugin.

@muuki88
Copy link
Contributor

muuki88 commented Sep 1, 2015

Adding conversation from gitter (@jsuereth , @fiadliel )

gbougeard
hi, I might do a PR about #558 but in a first time handling only publishLocal. publishis a little bit > complex as it needs to handle credentials and push to private repositories. Are you interested?

jsuereth 12:17
Regarding credentials, what http client does it use? Ivy will automatically configure the native JDK one

fiadliel 12:33
@gbougeard I think it would be cool. Though I’m concerned by extra dependencies in sbt-native-packager, especially a common one like async-http-client (a lot of people won’t be able to upgrade this library because they’re tied by Play Framework). My preference would be to have it as an external plugin, with some really easy way to enable it.
gbougeard 12:54

@fiadliel I did use spotify docker-client in publishLocal and just needed to add it as depencency (an no other one).
@jsuereth it uses https://github.com/spotify/docker-client/blob/master/pom.xml#L130
fiadliel 12:59

@gbougeard that’s not the problem; it’s when this plugin needs one version of httpclient, and another plugin needs another (incompatible) version; as a required dependency of a popular system like Play, I’d consider it an important thing to bear in mind. Making this functionality optional is a relatively cheap way of providing some extra flexibility around library dependencies. But I’m not a maintainer, it’s just my 2c.

@gbougeard
Copy link
Contributor Author

@muuki88 I think I coded it but I'm getting trouble on how to activate DockerSpotifyClientPlugin.
I thought adding enablePlugins(DockerSpotifyClientPlugin) would be enough but when I launch docker:publishLocal it still uses the Native implementation (so DockerPlugin instead of DockerSpotifyClientPlugin)

@muuki88
Copy link
Contributor

muuki88 commented Sep 2, 2015

Can you push your code here? otherwise it's hard to say what went wrong ;)

@gbougeard
Copy link
Contributor Author

I finally did it.
I modified the test-project-docker to use the DockerSpotifyClientPlugin and it builds the image using the Remote API.

@muuki88
Copy link
Contributor

muuki88 commented Sep 3, 2015

That looks pretty smooth. The only thing I'm still struggling is, if we should put this in sbt-native-packager itself or in a new project and feature it here.

@fiadliel has a point. We don't know on what libraries clients depend and what conflicts can occur. The spotify client depends on a few stuff that can really be critical (even for this lib alone)

  • org.bouncycastle
  • apache compress

On the other hand, keeping it here in the code base it's a lot easier for users and for developers to use (in case of no conflicts)

@muuki88
Copy link
Contributor

muuki88 commented Sep 4, 2015

@gbougeard can you squash the commits into one? Actually I want to merge this and release an milestone release, hoping to gather some feedback.

val id = docker.build(Paths.get(dockerDirectory), tag, new ProgressHandler() {
def progress(message: ProgressMessage) = {
val error: String = message.error()
if (error != null && !error.isEmpty) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but spotify docker-client is a java lib, how could it be done another way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example

Option(message.error()) match {
  case Some(error) if error.nonEmpty => log.error(message.error())
  case _ => log.info(message.stream())
}

Use spotify docker-client for docker:publishLocal goal
@gbougeard
Copy link
Contributor Author

Is it ok for you now?

*
* == Requirements ==
*
* You need docker to have docker installed on your system.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually not a requirement, via an env var you can just point at a remote endpoint

muuki88 added a commit that referenced this pull request Sep 8, 2015
Use spotify docker-client for docker:publishLocal goal
@muuki88 muuki88 merged commit f742f83 into sbt:master Sep 8, 2015
@muuki88
Copy link
Contributor

muuki88 commented Sep 8, 2015

Awesome. I release a soon I have time

@gbougeard
Copy link
Contributor Author

Great we need that milestone release :)

@muuki88
Copy link
Contributor

muuki88 commented Sep 9, 2015

@gbougeard 1.0.5-M1 is out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants