Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce builder image size #243

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions jdock/src/main/java/io/quarkus/images/modules/GraalVMModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public class GraalVMModule extends AbstractModule {
private final boolean isLegacyGraalVm;

private static final String TEMPLATE = """
--mount=type=bind,source=%s,target=%s \\
tar xzf %s -C /opt \\
&& mv /opt/graalvm-ce-*-%s* /opt/graalvm \\
&& %s/bin/gu --auto-yes install native-image \\
&& rm -Rf %s""";
&& %s/bin/gu --auto-yes install native-image""";

private static final String NEW_TEMPLATE = """
--mount=type=bind,source=%s,target=%s \\
tar xzf %s -C /opt \\
&& mv /opt/graalvm-community-openjdk-%s* /opt/graalvm \\
&& rm -Rf %s""";
&& mv /opt/graalvm-community-openjdk-%s* /opt/graalvm""";
private final String graalvmVersion;

public GraalVMModule(String version, String arch, String javaVersion, String sha) {
Expand Down Expand Up @@ -71,21 +71,20 @@ public List<Command> commands(BuildContext bc) {
String script;
if (isLegacyGraalVm) {
script = TEMPLATE.formatted(
artifact.path, "/tmp/" + artifact.name, // mount bind
"/tmp/" + artifact.name, // tar
graalvmVersion,
GRAALVM_HOME, // gu
"/tmp/" + artifact.name); // rm
graalvmVersion, // mv
GRAALVM_HOME); // gu
} else {
script = NEW_TEMPLATE.formatted(
artifact.path, "/tmp/" + artifact.name, // mount bind
"/tmp/" + artifact.name, // tar
graalvmVersion,
"/tmp/" + artifact.name); // rm
graalvmVersion);
}

return List.of(
new EnvCommand("JAVA_HOME", GRAALVM_HOME, "GRAALVM_HOME", GRAALVM_HOME),
new MicrodnfCommand("fontconfig", "freetype-devel"),
new CopyCommand(artifact, "/tmp/" + artifact.name),
new RunCommand(script));
}
}
11 changes: 7 additions & 4 deletions jdock/src/main/java/io/quarkus/images/modules/MandrelModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class MandrelModule extends AbstractModule {
private final String filename;

private static final String TEMPLATE = """
--mount=type=bind,source=%s,target=%s \\
mkdir -p %s \\
&& tar xzf %s -C %s --strip-components=1 \\
&& rm -Rf %s""";
&& tar xzf %s -C %s --strip-components=1""";

public MandrelModule(String version, String arch, String javaVersion, String sha) {
super("mandrel",
Expand All @@ -39,11 +39,14 @@ public MandrelModule(String version, String arch, String javaVersion, String sha
public List<Command> commands(BuildContext bc) {
Artifact artifact = bc.addArtifact(new Artifact(filename, url, sha));
String script = TEMPLATE.formatted(
MANDREL_HOME, "/tmp/" + artifact.name, MANDREL_HOME, "/tmp/" + artifact.name);
artifact.path, "/tmp/" + artifact.name, // mount bind
MANDREL_HOME, // mkdir
"/tmp/" + artifact.name, MANDREL_HOME, //tar
"/tmp/" + artifact.name); //rm

return List.of(
new EnvCommand("JAVA_HOME", MANDREL_HOME, "GRAALVM_HOME", MANDREL_HOME),
new MicrodnfCommand("fontconfig", "freetype-devel"),
new CopyCommand(artifact, "/tmp/" + artifact.name),
new RunCommand(script));
}
}