diff --git a/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala index 88ee7772e..87d4c0930 100644 --- a/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala @@ -112,10 +112,6 @@ object DockerPlugin extends AutoPlugin { Seq( executableScriptName := executableScriptName.value, mappings ++= dockerPackageMappings.value, - mappings ++= { - val baseDir = target.value - Seq(dockerGenerateConfig.value) pair (file => IO.relativize(baseDir, file)) - }, name := name.value, packageName := packageName.value, publishLocal := { @@ -145,13 +141,14 @@ object DockerPlugin extends AutoPlugin { }, sourceDirectory := sourceDirectory.value / "docker", stage := Stager.stage(Docker.name)(streams.value, stagingDirectory.value, mappings.value), + stage := (stage dependsOn dockerGenerateConfig).value, stagingDirectory := (target in Docker).value / "stage", target := target.value / "docker", daemonUser := "daemon", daemonGroup := daemonUser.value, defaultLinuxInstallLocation := "/opt/docker", dockerPackageMappings := MappingsHelper.contentOf(sourceDirectory.value), - dockerGenerateConfig := generateDockerConfig(dockerCommands.value, target.value) + dockerGenerateConfig := generateDockerConfig(dockerCommands.value, stagingDirectory.value) ) ) diff --git a/src/sbt-test/docker/entrypoint/test b/src/sbt-test/docker/entrypoint/test index 6ab640bcb..8fba43b1f 100644 --- a/src/sbt-test/docker/entrypoint/test +++ b/src/sbt-test/docker/entrypoint/test @@ -1,3 +1,3 @@ # Stage the distribution and ensure files show up. > docker:stage -$ exec grep -q -F 'ENTRYPOINT ["/bin/sh", "-c", "env"]' target/docker/Dockerfile +$ exec grep -q -F 'ENTRYPOINT ["/bin/sh", "-c", "env"]' target/docker/stage/Dockerfile diff --git a/src/sbt-test/docker/labels/build.sbt b/src/sbt-test/docker/labels/build.sbt index c8617d663..818491b08 100644 --- a/src/sbt-test/docker/labels/build.sbt +++ b/src/sbt-test/docker/labels/build.sbt @@ -8,7 +8,7 @@ dockerLabels := Map("foo" -> "bar", "fooBar" -> "foo bar", "number" -> "123") TaskKey[Unit]("checkDockerfile") := { - val dockerfile = IO.read((target in Docker).value / "Dockerfile") + val dockerfile = IO.read((stagingDirectory in Docker).value / "Dockerfile") assert(dockerfile contains """LABEL foo="bar"""", s"does not contain foo=bar\n$dockerfile") assert(dockerfile contains """LABEL fooBar="foo bar"""", s"does not contain foo=bar\n$dockerfile") diff --git a/src/sbt-test/docker/ports/test b/src/sbt-test/docker/ports/test index a23ca52d4..8d6e17b83 100644 --- a/src/sbt-test/docker/ports/test +++ b/src/sbt-test/docker/ports/test @@ -1,3 +1,3 @@ # Stage the distribution and ensure files show up. > docker:stage -$ exec grep -q -F 'EXPOSE 9000 9001 10000/udp 10001/udp' target/docker/Dockerfile +$ exec grep -q -F 'EXPOSE 9000 9001 10000/udp 10001/udp' target/docker/stage/Dockerfile diff --git a/src/sbt-test/docker/test-executableScriptName/build.sbt b/src/sbt-test/docker/test-executableScriptName/build.sbt index 93086b161..bbe73e03e 100644 --- a/src/sbt-test/docker/test-executableScriptName/build.sbt +++ b/src/sbt-test/docker/test-executableScriptName/build.sbt @@ -11,7 +11,7 @@ version := "0.1.0" maintainer := "Gary Coady " TaskKey[Unit]("checkDockerfile") := { - val dockerfile = IO.read(target.value / "docker" / "Dockerfile") + val dockerfile = IO.read((stagingDirectory in Docker).value / "Dockerfile") assert( dockerfile.contains("ENTRYPOINT [\"bin/docker-exec\"]\n"), "dockerfile doesn't contain ENTRYPOINT [\"docker-exec\"]\n" + dockerfile diff --git a/src/sbt-test/docker/test-packageName-universal/build.sbt b/src/sbt-test/docker/test-packageName-universal/build.sbt index 17c214855..919e75ae3 100644 --- a/src/sbt-test/docker/test-packageName-universal/build.sbt +++ b/src/sbt-test/docker/test-packageName-universal/build.sbt @@ -9,7 +9,7 @@ version := "0.1.0" maintainer := "Gary Coady " TaskKey[Unit]("checkDockerfile") := { - val dockerfile = IO.read(target.value / "docker" / "Dockerfile") + val dockerfile = IO.read((stagingDirectory in Docker).value / "Dockerfile") assert( dockerfile.contains("ENTRYPOINT [\"bin/docker-test\"]\n"), "dockerfile doesn't contain ENTRYPOINT [\"docker-test\"]\n" + dockerfile diff --git a/src/sbt-test/docker/test-packageName/build.sbt b/src/sbt-test/docker/test-packageName/build.sbt index f855ea17b..9149bbeb8 100644 --- a/src/sbt-test/docker/test-packageName/build.sbt +++ b/src/sbt-test/docker/test-packageName/build.sbt @@ -10,7 +10,7 @@ version := "0.1.0" maintainer := "Gary Coady " TaskKey[Unit]("checkDockerfile") := { - val dockerfile = IO.read(target.value / "docker" / "Dockerfile") + val dockerfile = IO.read((stagingDirectory in Docker).value / "Dockerfile") assert( dockerfile.contains("ENTRYPOINT [\"bin/docker-test\"]\n"), "dockerfile doesn't contain ENTRYPOINT [\"docker-test\"]\n" + dockerfile diff --git a/src/sbt-test/docker/udp-only-ports/test b/src/sbt-test/docker/udp-only-ports/test index 6c60b6b0f..2061f2a57 100644 --- a/src/sbt-test/docker/udp-only-ports/test +++ b/src/sbt-test/docker/udp-only-ports/test @@ -1,3 +1,3 @@ # Stage the distribution and ensure files show up. > docker:stage -$ exec grep -q -F 'EXPOSE 10000/udp 10001/udp' target/docker/Dockerfile +$ exec grep -q -F 'EXPOSE 10000/udp 10001/udp' target/docker/stage/Dockerfile diff --git a/src/sbt-test/docker/volumes/test b/src/sbt-test/docker/volumes/test index 302f8845a..03bc826a9 100644 --- a/src/sbt-test/docker/volumes/test +++ b/src/sbt-test/docker/volumes/test @@ -1,5 +1,5 @@ # Stage the distribution and ensure files show up. > docker:stage -$ exec grep -q -F 'VOLUME ["/opt/docker/logs", "/opt/docker/config"]' target/docker/Dockerfile -$ exec grep -q -F 'RUN ["chown", "-R", "daemon:daemon", "/opt/docker/logs", "/opt/docker/config"]' target/docker/Dockerfile -$ exec grep -q -F 'RUN ["mkdir", "-p", "/opt/docker/logs", "/opt/docker/config"]' target/docker/Dockerfile +$ exec grep -q -F 'VOLUME ["/opt/docker/logs", "/opt/docker/config"]' target/docker/stage/Dockerfile +$ exec grep -q -F 'RUN ["chown", "-R", "daemon:daemon", "/opt/docker/logs", "/opt/docker/config"]' target/docker/stage/Dockerfile +$ exec grep -q -F 'RUN ["mkdir", "-p", "/opt/docker/logs", "/opt/docker/config"]' target/docker/stage/Dockerfile