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

Support building and publishing Docker images. #277

Merged
merged 2 commits into from
Jun 26, 2014
Merged

Support building and publishing Docker images. #277

merged 2 commits into from
Jun 26, 2014

Conversation

fiadliel
Copy link
Contributor

This provides reasonable behaviour for Docker publish/publishLocal tasks.
docker:publishLocal maps to docker build -t [dockerTarget] .
docker:publish maps to docker push -t [dockerTarget]
docker:dockerTarget has a default value of [dockerRepository]/[normalizedName]:[version]

I have other code that creates a new Ivy repository type, but this way was simpler. Also, there was no access to the SBT logging context in Ivy's API, making reasonable support for logging/errors more difficult.

Note:
dockerBaseImage, dockerRepository are defined outside the Docker config, making them easier to set for a user, but they have reasonable defaults.

@muuki88 muuki88 added this to the 0.8.0 - windows services milestone Jun 22, 2014
@muuki88
Copy link
Contributor

muuki88 commented Jun 22, 2014

LGTM.The main logic is just:

val cmd = Seq("docker", "build", "-t", tag, ".")
val ret = Process(cmd, cwd) ! processLogger

// and
val cmd = Seq("docker", "push", tag)
val ret = Process(cmd, cwd) ! processLogger

Maybe you could refactor the processLoggers into some private methods. The main logic
is just too beautiful to be hidden by some logging stuff :)

@muuki88 muuki88 added the docker label Jun 23, 2014
@muuki88
Copy link
Contributor

muuki88 commented Jun 23, 2014

Damn yes :)

We released a v0.7.2-RC2 last week. If things go fine, I would like to add this feature as experimental in the v0.7.2. This would mean we need some documentation (maybe in the Advanced Topics section) and a small teaser on in the REAMDE.md (like the systemd support).

So, if you could write this documentation, it would be awesome (new pull request). If you don't have enough time, then just ping me here and I try to.

This provides reasonable behaviour for Docker publish/publishLocal tasks.
docker:publishLocal maps to "docker build -t [dockerTarget] ."
docker:publish maps to "docker push -t [dockerTarget]"
docker:dockerTarget has a default value of [dockerRepository]/[normalizedName]:[version]
@fiadliel
Copy link
Contributor Author

I've rebased and squashed this commit.

Note that if you don't want to merge this yet, then the current documentation is incorrect; I can submit another pull request to fix that (and add the documentation here instead).

@muuki88
Copy link
Contributor

muuki88 commented Jun 26, 2014

Ah, this pr got out my focus, sorry :(

Is there a way to test the docker:publishLocal task? If so a small test case would be awesome.
You may have to install docker via the .travis.yml.

Which part of the documentation is wrong? If we merge this pr the documentation
would be up-to-date again, right?

I retriggered the travis ci build as there seem to be some sbt initialization issues.

@fiadliel
Copy link
Contributor Author

I added a small test for an image that prints "Hello world".

But: Supporting Docker with Travis is going to be tough. It looks like TravisCI currently have no plans to support Docker inside their containers.

There seem to be some attempts by people to run docker servers, e.g. https://github.com/lukecyca/travis-docker-example/blob/master/.travis.yml - but it doesn't look like something to rely on.

@muuki88
Copy link
Contributor

muuki88 commented Jun 26, 2014

Hm, hopefully travis will provide something in the future. That would be awesome.
The test looks good anyway. Which version of docker do you use?

@fiadliel
Copy link
Contributor Author

$ docker -v
Docker version 1.0.1, build 990021a

Using https://github.com/boot2docker/boot2docker for OSX

@muuki88
Copy link
Contributor

muuki88 commented Jun 26, 2014

I'm currently running all the tests. When everything is fine I'll merge this one :)

muuki88 added a commit that referenced this pull request Jun 26, 2014
Support building and publishing Docker images.
@muuki88 muuki88 merged commit 37c887c into sbt:master Jun 26, 2014
@fiadliel fiadliel deleted the wip/docker-publish branch June 26, 2014 16:13
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.

2 participants