Skip to content

Instantly share code, notes, and snippets.

@numa08
Last active August 29, 2015 14:05
Show Gist options
  • Save numa08/4a94f7926a3d3e6eabb6 to your computer and use it in GitHub Desktop.
Save numa08/4a94f7926a3d3e6eabb6 to your computer and use it in GitHub Desktop.
sbt docker plugin

SBT Docker Plugin

Description

Create Docker Image on SBT task.

How To?

First, you write plugin.sbt

addSbtPlugin("net.numa08" % "docker-plugin" % "0.1")

Second, write docker setting in build.sbt

// Path for your Dockerfile
dockerPath = "./"

dockerTag = s"my-image:${version}"

dockerRegistry = Seq["numa08", "my-registry.com:5000"]

Third, run command in sbt

$sbt dockerBuild dockerPush

then, this plugin build docker image (tagged my-image:1.0 and my-image:latest) and push to registry ( numa08/my-image and my-registry.com:5000/my-image)

最近、Docker対応をうたうPaaSが増えてきた。Amazon Elastic BeansTalkをはじめ、Google Cloud Computing,Windows Azureb etc...また、Circle CIもDockerに対応し、テストやビルドタスクをDockerのコンテナ内部で実行できるようだ。

そうなると、必然的にsbtで管理されているアプリケーションもDockerコンテナで動作をさせたくなる。その辺りのタスクを簡略化したい。

ただ一応、sbtのタスクにDocker buildやpushを取り込むプラグインは既にある。marcuslonnberg/sbt-docker

これは、どうやらDockerfileをdslで記述して生成し、ビルドするらしい。

いや、そうじゃないんだ。そんなプラグインに完全に依存をしたシステムにはしたくない。そもそも、DockerにはDockerfileというシステムが既にある。それを外部から拡張する必要は特に無い、と思う。

事前に用意したDockerfileを利用する、それだけでいいじゃないか。別に、新しいdslを修得する必要なんてないんだ。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment