Skip to content

Commit

Permalink
Remove redundant Dockerfile (#1062)
Browse files Browse the repository at this point in the history
* Remove redundant Dockerfile

Fixes #1060

* Update tests

* Change stage task to use dependsOn
  • Loading branch information
mrfyda authored and muuki88 committed Nov 5, 2017
1 parent 47fc21b commit 1cc81a0
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 := {
Expand Down Expand Up @@ -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)
)
)

Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/docker/entrypoint/test
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/sbt-test/docker/labels/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/docker/ports/test
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/sbt-test/docker/test-executableScriptName/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version := "0.1.0"
maintainer := "Gary Coady <gary@lyranthe.org>"

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
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/docker/test-packageName-universal/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version := "0.1.0"
maintainer := "Gary Coady <gary@lyranthe.org>"

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
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/docker/test-packageName/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version := "0.1.0"
maintainer := "Gary Coady <gary@lyranthe.org>"

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
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/docker/udp-only-ports/test
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions src/sbt-test/docker/volumes/test
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1cc81a0

Please sign in to comment.