Skip to content

Commit 58ea149

Browse files
authored
External docker build (#637)
* Build docker container in a self-contained fashion This is prompted by various issues around our handling of arguments and how this clashes with -- and -D argument handling by both sbt-pack and sbt-native-packager Instead, we build scip-java entirely inside the docker container and point `scip-java` command directly at the jar, to exclude any possibility of weirdness introduced by launcher scripts. Additionally, this allows anyone to build a docker container without having JVM and SBT installed. * Update coursier launcher version and remove unnecessary architecture override
1 parent 4ca307a commit 58ea149

7 files changed

+101
-61
lines changed

.dockerignore

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
*.class
2+
*.log
3+
4+
# sbt specific
5+
.cache
6+
.history
7+
.lib/
8+
dist/*
9+
target/
10+
lib_managed/
11+
src_managed/
12+
project/boot/
13+
project/plugins/project/
14+
.bloop
15+
16+
_site/
17+
18+
# Scala-IDE specific
19+
.scala_dependencies
20+
.worksheet
21+
22+
.idea
23+
24+
# ENSIME specific
25+
.ensime_cache/
26+
.ensime
27+
28+
.metals/
29+
metals.sbt
30+
metals/project/
31+
32+
.bsp
33+
34+
.vscode/
35+
36+
local.*
37+
38+
.DS_Store
39+
40+
node_modules
41+
42+
lib/core/metadata.js
43+
lib/core/MetadataBlog.js
44+
45+
website/translated_docs
46+
website/build/
47+
website/yarn.lock
48+
website/node_modules
49+
website/i18n/*
50+
51+
project/metals.sbt
52+
out/
53+
*.hnir
54+
test-report.json
55+
index.scip
56+
57+
./generated
58+
/sources
59+
bazel-bin
60+
bazel-scip-java
61+
bazel-out
62+
bazel-testlogs
63+
bazel-lsif-java
64+
65+
VERSION
66+
67+
semanticdb-gradle-plugin/gradle
68+
aspects/scip_java.bzl

Dockerfile

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM eclipse-temurin:17
2+
3+
RUN apt-get update && apt-get install --yes jq wget curl zip unzip git python3 python3-pip autoconf automake libtool build-essential libtool make g++
4+
5+
WORKDIR /workdir
6+
7+
COPY ./bin/docker-setup.sh .
8+
RUN ./docker-setup.sh
9+
10+
11+
ENV PATH=/opt/maven/bin:${PATH}
12+
ENV PATH=/opt/gradle/bin:${PATH}
13+
ENV PATH=/root/.local/share/coursier/bin:${PATH}
14+
15+
ENV JAVA_TOOL_OPTIONS="-XX:MaxRAMPercentage=80.0 -XX:+UseContainerSupport"
16+
RUN git config --global --add safe.directory *
17+
18+
COPY . .
19+
20+
RUN sbt publishLocal dumpScipJavaVersion
21+
RUN mkdir -p /app && coursier bootstrap "com.sourcegraph:scip-java_2.13:$(cat VERSION)" -f -o /app/scip-java -M com.sourcegraph.scip_java.ScipJava
22+
23+
COPY ./bin/scip-java-docker-script.sh /usr/bin/scip-java
24+
25+
WORKDIR /sources
26+
27+
RUN rm -rf /workdir

bin/coursier

33.6 KB
Binary file not shown.

bin/docker-setup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
set -eux
3-
curl -fLo /usr/local/bin/coursier https://github.com/coursier/coursier/releases/download/v2.1.0-RC5/coursier
3+
curl -fLo /usr/local/bin/coursier https://github.com/coursier/coursier/releases/download/v2.1.5/coursier
44
chmod +x /usr/local/bin/coursier
55
coursier setup --yes
66

bin/scip-java-docker-script.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ do
3232
eval "$(coursier java --jvm "$JVM_VERSION" --env --jvm-index https://github.com/coursier/jvm-index/blob/master/index.json)"
3333

3434
java -version
35-
if /app/scip-java/bin/scip-java "$@"; then
35+
if /app/scip-java "$@"; then
3636
LAST_CODE="0"
3737
else
3838
LAST_CODE=$?

build.sbt

+3-56
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sbtdocker.DockerfileBase
12
import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, _}
23
import scala.xml.transform.{RewriteRule, RuleTransformer}
34
import java.io.File
@@ -318,62 +319,8 @@ lazy val cli = project
318319
latest ++ versioned
319320

320321
},
321-
docker / dockerfile := {
322-
val binaryDistribution = pack.value
323-
val scipJavaWrapper = (ThisBuild / baseDirectory).value / "bin" /
324-
"scip-java-docker-script.sh"
325-
val dockerSetup = (ThisBuild / baseDirectory).value / "bin" /
326-
"docker-setup.sh"
327-
new Dockerfile {
328-
from("eclipse-temurin:17")
329-
330-
// Setup system dependencies.
331-
run("apt-get", "update")
332-
run(
333-
"apt-get",
334-
"install",
335-
"--yes",
336-
"jq",
337-
"wget",
338-
"curl",
339-
"zip",
340-
"unzip",
341-
"git",
342-
// C++ and Python dependencies that may be needed by some random JVM
343-
// builds.
344-
"python3",
345-
"python3-pip",
346-
"autoconf",
347-
"automake",
348-
"libtool",
349-
"build-essential",
350-
"libtool",
351-
"make",
352-
"g++"
353-
)
354-
355-
// Install SDKMAN
356-
add(dockerSetup, "/docker-setup.sh")
357-
run("bash", "/docker-setup.sh")
358-
359-
env("PATH", "/opt/maven/bin:${PATH}")
360-
env("PATH", "/opt/gradle/bin:${PATH}")
361-
env("PATH", "/root/.local/share/coursier/bin:${PATH}")
362-
env(
363-
"JAVA_TOOL_OPTIONS",
364-
"-XX:MaxRAMPercentage=80.0 -XX:+UseContainerSupport"
365-
)
366-
367-
// Mark all directories as safe for Git, so that it doesn't
368-
// trigger this check and error:
369-
// `detected dubious ownership in repository at <folder>`
370-
run("git", "config", "--global", "--add", "safe.directory", "*")
371-
372-
// Install `scip-java` binary.
373-
add(scipJavaWrapper, "/usr/local/bin/scip-java")
374-
add(binaryDistribution, "/app/scip-java")
375-
}
376-
}
322+
docker / dockerfile :=
323+
NativeDockerfile((ThisBuild / baseDirectory).value / "Dockerfile")
377324
)
378325
.enablePlugins(PackPlugin, DockerPlugin, BuildInfoPlugin)
379326
.dependsOn(scip)

project/JavaToolchainPlugin.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ object JavaToolchainPlugin extends AutoPlugin {
9191
coursier.toString,
9292
"java-home",
9393
"--jvm",
94-
jvmName(v),
95-
"--architecture",
96-
jvmArchitecture
94+
jvmName(v)
9795
) ++ index
9896

9997
new File(Process(arguments).!!.trim)

0 commit comments

Comments
 (0)