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

Remove windows container support #775

Merged
Merged
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<class name="io.ballerina.c2c.test.docker.DockerGeneratorNegativeTests"/>
<class name="io.ballerina.c2c.test.docker.DockerCMDTest"/>
<class name="io.ballerina.c2c.test.docker.DockerInvalidCopyTest"/>
<class name="io.ballerina.c2c.test.docker.DockerGeneratorWindowsTests"/>
<class name="io.ballerina.c2c.test.samples.JobTest"/>
<class name="io.ballerina.c2c.test.samples.Sample1Test"/>
<class name="io.ballerina.c2c.test.samples.Sample2Test"/>
Expand Down
1 change: 0 additions & 1 deletion compiler-plugin-tests/src/test/resources/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<class name="io.ballerina.c2c.test.docker.DockerGeneratorNegativeTests"/>
<class name="io.ballerina.c2c.test.docker.DockerCMDTest"/>
<class name="io.ballerina.c2c.test.docker.DockerInvalidCopyTest"/>
<class name="io.ballerina.c2c.test.docker.DockerGeneratorWindowsTests"/>
<class name="io.ballerina.c2c.test.samples.JobTest"/>
<class name="io.ballerina.c2c.test.samples.Sample1Test"/>
<class name="io.ballerina.c2c.test.samples.Sample2Test"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
*/
public class DockerGenConstants {
public static final String ENABLE_DEBUG_LOGS = "BAL_DOCKER_DEBUG";
public static final String ENABLE_WINDOWS_BUILD = "BAL_DOCKER_WINDOWS";
public static final String EXECUTABLE_JAR = ".jar";
public static final String REGISTRY_SEPARATOR = "/";
public static final String TAG_SEPARATOR = ":";
public static final String JRE_SLIM_BASE = "ballerina/jvm-runtime:2.0";
public static final String JRE_WINDOWS_BASE_IMAGE = "openjdk:17-windowsservercore";
public static final String NATIVE_BUILDER_IMAGE = "ghcr.io/graalvm/native-image-community:17-ol8";
public static final String NATIVE_RUNTIME_BASE_IMAGE = "gcr.io/distroless/base";
public static final int MAX_BALLERINA_LAYERS = 110;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
@Getter
@Setter
public class DockerModel {
private final boolean windowsBuild =
Boolean.parseBoolean(System.getenv(DockerGenConstants.ENABLE_WINDOWS_BUILD));

private String name;
private String registry;
private String tag;
Expand Down Expand Up @@ -69,8 +68,7 @@ public DockerModel() {
// Initialize with default values except for image name
this.tag = "latest";
this.buildImage = true;
this.baseImage = windowsBuild ? DockerGenConstants.JRE_WINDOWS_BASE_IMAGE :
DockerGenConstants.JRE_SLIM_BASE;
this.baseImage = DockerGenConstants.JRE_SLIM_BASE;
this.enableDebug = false;
this.debugPort = 5005;
this.externalFiles = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ public void createArtifacts(PrintStream outStream, String logAppender, Path jarF
outputDir.resolve(this.dockerModel.getFatJarPath().getFileName()));
} else {
String dockerContent;
if (!isWindowsBuild()) {
dockerContent = generateDockerfile();
} else {
dockerContent = generateThinJarWindowsDockerfile();
}
dockerContent = generateDockerfile();
copyNativeJars(outputDir);
DockerGenUtils.writeToFile(dockerContent, outputDir.resolve("Dockerfile"));
Path jarLocation = outputDir.resolve(DockerGenUtils.extractJarName(jarFilePath) + EXECUTABLE_JAR);
Expand Down Expand Up @@ -241,48 +237,6 @@ protected void appendUser(StringBuilder dockerfileContent) {
}
}

private String generateThinJarWindowsDockerfile() {
final String separator = "\\";
StringBuilder dockerfileContent = new StringBuilder();
dockerfileContent.append("# Auto Generated Dockerfile").append(LINE_SEPARATOR);
dockerfileContent.append("FROM ").append(this.dockerModel.getBaseImage()).append(LINE_SEPARATOR);
dockerfileContent.append(LINE_SEPARATOR);
dockerfileContent.append("LABEL maintainer=\"[email protected]\"").append(LINE_SEPARATOR);
dockerfileContent.append(LINE_SEPARATOR);
dockerfileContent.append("WORKDIR ").append(getWorkDir()).append(LINE_SEPARATOR);

for (Path path : this.dockerModel.getDependencyJarPaths()) {
dockerfileContent.append("COPY ").append(path.getFileName()).append(getWorkDir())
.append("jars").append(separator);
dockerfileContent.append(LINE_SEPARATOR);
}
dockerfileContent.append(LINE_SEPARATOR);
appendCommonCommands(dockerfileContent);
if (isBlank(this.dockerModel.getEntryPoint())) {
PackageID packageID = this.dockerModel.getPkgId();
String mainClass = JarResolver.getQualifiedClassName(packageID.orgName.value, packageID.name.value,
packageID.version.value, MODULE_INIT_CLASS_NAME);
mainClass = "'" + mainClass + "'";
if (this.dockerModel.isEnableDebug()) {
dockerfileContent.append("CMD java -Xdiag -agentlib:jdwp=transport=dt_socket,server=y,suspend=n," +
"address=*:").append(this.dockerModel.getDebugPort()).append(" -cp \"")
.append(this.dockerModel.getJarFileName()).append(":jars/*\" ").append(mainClass);
} else {
dockerfileContent.append("CMD java -Xdiag -cp \"").append(this.dockerModel.getJarFileName())
.append(":jars/*\" ").append(mainClass);
}
} else {
dockerfileContent.append(this.dockerModel.getEntryPoint());
}
dockerfileContent.append(LINE_SEPARATOR);
if (!isBlank(this.dockerModel.getCommandArg())) {
dockerfileContent.append(this.dockerModel.getCommandArg());
}
dockerfileContent.append(LINE_SEPARATOR);

return dockerfileContent.toString();
}

protected void appendCommonCommands(StringBuilder dockerfileContent) {
this.dockerModel.getEnv().forEach((key, value) -> dockerfileContent.append("ENV ").
append(key).append("=").append(value).append(LINE_SEPARATOR));
Expand Down Expand Up @@ -310,11 +264,7 @@ protected void appendCommonCommands(StringBuilder dockerfileContent) {
}
}

private boolean isWindowsBuild() {
return Boolean.parseBoolean(System.getenv(DockerGenConstants.ENABLE_WINDOWS_BUILD));
}

private String getWorkDir() {
return isWindowsBuild() ? "C:\\ballerina\\home\\" : "/home/ballerina";
return "/home/ballerina";
}
}
Loading