-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
- Trait DockerPlugin should not extend DockerKeys - publishArtifact in Docker is false - do not generate POM/etc. - Tasks for stage do not depend on each other. - Change the CWD in the Docker container to install location. - Adding Docker-specific mappings happens outside mapGenericFilesToDocker - Use defaultLinuxInstallLocation instead of defaultDockerInstallLocation - dockerBaseImage is set outside Docker config, easier to override
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,21 +5,18 @@ import Keys._ | |
import universal._ | ||
import sbt._ | ||
|
||
import sbt.Keys.cacheDirectory | ||
import universal.Keys.stage | ||
|
||
trait DockerPlugin extends Plugin with UniversalPlugin with DockerKeys { | ||
trait DockerPlugin extends Plugin with UniversalPlugin { | ||
val Docker = config("docker") extend Universal | ||
|
||
private[this] final def makeDockerContent(dockerBaseImage: String, dockerBaseDirectory: String, maintainer: String, daemonUser: String, name: String) = { | ||
Dockerfile( | ||
Cmd("FROM", dockerBaseImage), | ||
Cmd("MAINTAINER", maintainer), | ||
Cmd("ADD", "files /"), | ||
Cmd("WORKDIR", "%s/bin" format dockerBaseDirectory), | ||
ExecCmd("RUN", "chown", "-R", daemonUser, ".."), | ||
Cmd("WORKDIR", "%s" format dockerBaseDirectory), | ||
ExecCmd("RUN", "chown", "-R", daemonUser, "."), | ||
Cmd("USER", daemonUser), | ||
ExecCmd("ENTRYPOINT", name), | ||
ExecCmd("ENTRYPOINT", "bin/%s" format name), | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fiadliel
Contributor
|
||
ExecCmd("CMD") | ||
).makeContent | ||
} | ||
|
@@ -42,32 +39,33 @@ trait DockerPlugin extends Plugin with UniversalPlugin with DockerKeys { | |
} | ||
|
||
inConfig(Docker)(Seq( | ||
mappings <<= (mappings in Universal, defaultDockerInstallLocation) map { (mappings, dest) => | ||
mappings <<= (mappings in Universal, defaultLinuxInstallLocation) map { (mappings, dest) => | ||
renameDests(mappings, dest) | ||
}, | ||
mappings <++= dockerPackageMappings | ||
} | ||
)) | ||
} | ||
|
||
def dockerSettings: Seq[Setting[_]] = Seq( | ||
dockerBaseImage := "dockerfile/java", | ||
sourceDirectory in Docker <<= sourceDirectory apply (_ / "docker"), | ||
target in Docker <<= target apply (_ / "docker") | ||
) ++ mapGenericFilesToDocker ++ inConfig(Docker)(Seq( | ||
daemonUser := "daemon", | ||
dockerBaseImage := "dockerfile/java", | ||
defaultDockerInstallLocation := "/opt/docker", | ||
dockerPackageMappings <<= (sourceDirectory in Docker) map { dir => | ||
publishArtifact := false, | ||
defaultLinuxInstallLocation := "/opt/docker", | ||
dockerPackageMappings <<= (sourceDirectory) map { dir => | ||
MappingsHelper contentOf dir | ||
}, | ||
stage <<= dockerGenerateContext.dependsOn(dockerGenerateConfig), | ||
mappings <++= dockerPackageMappings, | ||
stage <<= (dockerGenerateConfig, dockerGenerateContext) map { (configFile, contextDir) => () }, | ||
dockerGenerateContext <<= (cacheDirectory, mappings, target) map { | ||
(cacheDirectory, mappings, t) => | ||
val contextDir = t / "files" | ||
stageFiles("docker")(cacheDirectory, contextDir, mappings) | ||
contextDir | ||
}, | ||
dockerGenerateConfig <<= | ||
(dockerBaseImage, defaultDockerInstallLocation, maintainer in Docker, daemonUser in Docker, normalizedName in Docker, target in Docker) map { | ||
(dockerBaseImage, defaultLinuxInstallLocation, maintainer, daemonUser, normalizedName, target) map { | ||
case (dockerBaseImage, baseDirectory, maintainer, daemonUser, normalizedName, target) => | ||
generateDockerConfig(dockerBaseImage, baseDirectory, maintainer, daemonUser, normalizedName, target) | ||
} | ||
|
Wouldn't it be better to have that as: