Skip to content

Commit bc2bcfe

Browse files
committed
Revert "Make docker builds able to COPY custom files in (#1931)"
This reverts commit 8df8933.
1 parent 71447de commit bc2bcfe

File tree

7 files changed

+39
-38
lines changed

7 files changed

+39
-38
lines changed

contrib/bloop/test/src/mill/contrib/bloop/BloopTests.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ object BloopTests extends TestSuite {
8989
if (scala.util.Properties.isWin) None else Some(readBloopConf("scalanativeModule.json"))
9090

9191
"no-compilation" - {
92-
val workspaceOut = os.pwd / "target" / "workspace" / "bloop" / "out"
92+
val workspaceOut =
93+
os.pwd / "target" / "workspace" / "mill" / "contrib" / "bloop" / "BloopTests" / "testEvaluator"
9394

9495
// Ensuring that bloop config generation didn't trigger compilation
9596
assert(os.exists(workspaceOut / "scalaModule"))

contrib/docker/src/DockerModule.scala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ trait DockerModule { outer: JavaModule =>
8585
}
8686

8787
def dockerfile: T[String] = T {
88+
val jarName = assembly().path.last
8889
val labelRhs = labels()
8990
.map { case (k, v) =>
9091
val lineBrokenValue = v
@@ -112,25 +113,30 @@ trait DockerModule { outer: JavaModule =>
112113
if (user().isEmpty) "" else s"USER ${user()}"
113114
).filter(_.nonEmpty).mkString(sys.props("line.separator"))
114115

115-
s"""FROM ${baseImage()}
116+
s"""
117+
|FROM ${baseImage()}
116118
|$lines
117-
|COPY ["${assembly().path}", "/${assembly().path.last}"]
118-
|ENTRYPOINT ["java", "-jar", "/${assembly().path.last}"]""".stripMargin
119+
|COPY $jarName /$jarName
120+
|ENTRYPOINT ["java", "-jar", "/$jarName"]""".stripMargin
119121
}
120122

121123
final def build = T {
122-
val log = T.log
123-
val dockerfilePath = T.dest / "Dockerfile"
124+
val dest = T.dest
125+
126+
val asmPath = outer.assembly().path
127+
os.copy(asmPath, dest / asmPath.last)
124128

125-
os.write(dockerfilePath, dockerfile().replace(T.workspace.toString, ""))
129+
os.write(dest / "Dockerfile", dockerfile())
130+
131+
val log = T.log
126132

127133
val tagArgs = tags().flatMap(t => List("-t", t))
128134

129135
val (pull, _) = baseImageCacheBuster()
130136
val pullLatestBase = IterableShellable(if (pull) Some("--pull") else None)
131137

132138
val result = os
133-
.proc(executable(), "build", tagArgs, pullLatestBase, "-f", dockerfilePath, T.workspace)
139+
.proc(executable(), "build", tagArgs, pullLatestBase, dest)
134140
.call(stdout = os.Inherit, stderr = os.Inherit)
135141

136142
log.info(s"Docker build completed ${if (result.exitCode == 0) "successfully"

contrib/docker/test/src/DockerModuleTest.scala

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ object DockerModuleTest extends TestSuite {
9595
val eval = new TestEvaluator(Docker)
9696
val Right((dockerfileString, _)) = eval(Docker.dockerDefault.dockerfile)
9797
val expected = multineRegex.replaceAllIn(
98-
s"""FROM gcr.io/distroless/java:latest
99-
|COPY ["${Docker.millSourcePath / "out" / "dockerfile contents" / "default options" / "assembly.dest" / "out.jar"}", "/out.jar"]
100-
|ENTRYPOINT ["java", "-jar", "/out.jar"]""".stripMargin,
98+
"""
99+
|FROM gcr.io/distroless/java:latest
100+
|COPY out.jar /out.jar
101+
|ENTRYPOINT ["java", "-jar", "/out.jar"]""".stripMargin,
101102
sys.props("line.separator")
102103
)
103104
val dockerfileStringRefined = multineRegex.replaceAllIn(
@@ -111,18 +112,19 @@ object DockerModuleTest extends TestSuite {
111112
val eval = new TestEvaluator(Docker)
112113
val Right((dockerfileString, _)) = eval(Docker.dockerAll.dockerfile)
113114
val expected = multineRegex.replaceAllIn(
114-
s"""FROM docker.io/openjdk:11
115-
|LABEL "version"="1.0"
116-
|EXPOSE 8080/tcp 443/tcp
117-
|EXPOSE 80/udp
118-
|ENV foo=bar
119-
|ENV foobar=barfoo
120-
|VOLUME ["/v1", "/v2"]
121-
|RUN /bin/bash -c 'echo Hello World!'
122-
|RUN useradd -ms /bin/bash user1
123-
|USER user1
124-
|COPY ["${Docker.millSourcePath / "out" / "dockerfile contents" / "all options" / "assembly.dest" / "out.jar"}", "/out.jar"]
125-
|ENTRYPOINT ["java", "-jar", "/out.jar"]""".stripMargin,
115+
"""
116+
|FROM docker.io/openjdk:11
117+
|LABEL "version"="1.0"
118+
|EXPOSE 8080/tcp 443/tcp
119+
|EXPOSE 80/udp
120+
|ENV foo=bar
121+
|ENV foobar=barfoo
122+
|VOLUME ["/v1", "/v2"]
123+
|RUN /bin/bash -c 'echo Hello World!'
124+
|RUN useradd -ms /bin/bash user1
125+
|USER user1
126+
|COPY out.jar /out.jar
127+
|ENTRYPOINT ["java", "-jar", "/out.jar"]""".stripMargin,
126128
sys.props("line.separator")
127129
)
128130
val dockerfileStringRefined = multineRegex.replaceAllIn(

contrib/scoverage/test/src/HelloWorldTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ trait HelloWorldTests extends utest.TestSuite {
115115

116116
assert(
117117
result.path.toIO.getPath.replace("""\""", "/").endsWith(
118-
"mill/target/worksources/mill/contrib/scoverage/HelloWorldTests#HelloWorld/out/HelloWorld/core/scoverage/data/core/scoverage/data.dest"
118+
"mill/target/workspace/mill/contrib/scoverage/HelloWorldTests/eval/HelloWorld/core/scoverage/data/core/scoverage/data.dest"
119119
),
120120
evalCount > 0
121121
)

docs/antora/modules/ROOT/pages/Plugin_Docker.adoc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ object docker extends DockerConfig {
6161
def user = "new-user"
6262
// Optionally override the docker executable to use something else
6363
def executable = "podman"
64-
// Optionally override the content of the Dockerfile. Note: All paths need to be absolute and located within the project.
65-
def dockerfile =
66-
s"""FROM ${baseImage()}
67-
|RUN aptitude install -y pidgin
68-
|COPY ${assembly().path} /${assembly().path.last}
69-
|ENTRYPOINT ["java", "-jar", "/${assembly().path.last}"]""".stripMargin
70-
|""".stripMargin
7164
}
7265
----
7366

main/test/src/eval/TaskTests.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,11 @@ object SeqTaskTests extends TaskTests {
209209
object ParTaskTests extends TaskTests {
210210
def withEnv(f: (Build, TestEvaluator) => Unit)(implicit tp: TestPath) = {
211211
object build extends Build
212-
val check =
213-
new TestEvaluator(
214-
build,
215-
threads = Some(16),
216-
extraPathEnd = Seq(getClass().getSimpleName())
217-
)
212+
val check = new TestEvaluator(
213+
build,
214+
threads = Some(16),
215+
extraPathEnd = Seq(getClass().getSimpleName())
216+
)
218217
f(build, check)
219218
}
220219
}

main/testkit/src/testkit/MillTestkit.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ trait MillTestKit {
7272
debugEnabled: Boolean = false,
7373
extraPathEnd: Seq[String] = Seq.empty
7474
)(implicit fullName: sourcecode.FullName) {
75-
val outPath = module.millSourcePath / "out" / testPath / extraPathEnd
75+
val outPath = getOutPath(testPath) / extraPathEnd
7676

7777
// val logger = DummyLogger
7878
val logger = new mill.util.PrintLogger(

0 commit comments

Comments
 (0)