Skip to content

Commit 3b72ecd

Browse files
committed
Back to specific directory for ADD command
PR #424 moved to a ADD wildcard approach, and then removed the Dockerfile. There were two problems with this: * ADD seems to behave weirdly regarding recursion. /opt/docker and /docker were both added to the output. * I had incorrectly set the current working directory to the parent of the context directory, where it really should be the context directory itself. This only worked because there was a Dockerfile in the parent also.
1 parent 5fdf04c commit 3b72ecd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ object DockerPlugin extends AutoPlugin {
115115
Some(Cmd("MAINTAINER", maintainer))
116116
}
117117

118+
val files = dockerBaseDirectory.split(java.io.File.separator)(1)
119+
118120
val dockerCommands = Seq(
119-
Cmd("ADD", "* /"),
121+
Cmd("ADD", s"$files /$files"),
120122
Cmd("WORKDIR", "%s" format dockerBaseDirectory),
121123
ExecCmd("RUN", "chown", "-R", daemonUser, "."),
122-
ExecCmd("RUN", "rm", "/Dockerfile"),
123124
Cmd("USER", daemonUser),
124125
ExecCmd("ENTRYPOINT", entrypoint: _*),
125126
ExecCmd("CMD")
@@ -200,12 +201,11 @@ object DockerPlugin extends AutoPlugin {
200201

201202
def publishLocalDocker(context: File, tag: String, latest: Boolean, log: Logger): Unit = {
202203
val cmd = Seq("docker", "build", "--force-rm", "-t", tag, ".")
203-
val cwd = context.getParentFile
204204

205205
log.debug("Executing " + cmd.mkString(" "))
206-
log.debug("Working directory " + cwd.toString)
206+
log.debug("Working directory " + context.toString)
207207

208-
val ret = Process(cmd, cwd) ! publishLocalLogger(log)
208+
val ret = Process(cmd, context) ! publishLocalLogger(log)
209209

210210
if (ret != 0)
211211
throw new RuntimeException("Nonzero exit value: " + ret)

0 commit comments

Comments
 (0)