Skip to content

Commit

Permalink
Merge pull request #818 from anuruddhal/master
Browse files Browse the repository at this point in the history
Update Docker base image version
  • Loading branch information
anuruddhal authored Nov 18, 2024
2 parents 72f43d5 + b693912 commit 96b54f2
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 52 deletions.
2 changes: 1 addition & 1 deletion ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ license = ["Apache-2.0"]
keywords = ["cloud", "kubernetes", "docker", "k8s", "c2c"]
distribution = "2201.8.0"

[platform.java17]
[platform.java21]
graalvmCompatible = true
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.11.0-20241111-172200-095db58f"
distribution-version = "2201.11.0-20241117-133400-a3054b77"

[[package]]
org = "ballerina"
Expand Down
2 changes: 1 addition & 1 deletion build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ license = ["Apache-2.0"]
keywords = ["cloud", "kubernetes", "docker", "k8s", "c2c"]
distribution = "2201.8.0"

[platform.java17]
[platform.java21]
graalvmCompatible = true
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/

plugins {
id "com.github.spotbugs" version "5.0.14"
id "com.github.johnrengelman.shadow" version "8.1.1"
id "de.undercouch.download" version "5.4.0"
id "net.researchgate.release" version "2.8.0"
id "com.github.spotbugs-base" version "${spotbugsPluginVersion}"
id "com.github.johnrengelman.shadow" version "${shadowJarPluginVersion}"
id "de.undercouch.download" version "${downloadPluginVersion}"
id "net.researchgate.release" version "${releasePluginVersion}"
id 'maven-publish'
}

Expand Down Expand Up @@ -114,6 +114,7 @@ subprojects {
ballerinaStdLibs "io.ballerina.stdlib:http-ballerina:${stdlibHttpVersion}"
ballerinaStdLibs "io.ballerina.stdlib:observe-ballerina:${observeVersion}"
ballerinaStdLibs "io.ballerina:observe-ballerina:${observeInternalVersion}"
ballerinaStdLibs "io.ballerina.lib:data.jsondata-ballerina:${stdlibDataJsonDataVersion}"
}
}

Expand Down
4 changes: 4 additions & 0 deletions cloud-tooling/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
<Match>
<Bug pattern="EI_EXPOSE_REP, EI_EXPOSE_REP2, MS_EXPOSE_REP, MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR" />
</Match>
<Match>
<Class name="io.ballerina.c2c.tooling.completion.CloudTomlCompletionContext"/>
<Bug pattern="CT_CONSTRUCTOR_THROW"/>
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void validateCustomBaseImage() throws IOException, InterruptedException,
String content = Files.readString(dockerFile.toPath(), StandardCharsets.UTF_8);
Assert.assertTrue(dockerFile.exists());
Assert.assertTrue(content.contains("FROM alpine"));
Assert.assertTrue(content.contains("FROM ghcr.io/graalvm/native-image-community:17-ol8 as build"));
Assert.assertTrue(content.contains("FROM ghcr.io/graalvm/native-image-community:21-ol9 as build"));
KubernetesUtils.deleteDirectory(DOCKER_TARGET_PATH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void validateDockerBuildOption() throws IOException, InterruptedException
Assert.assertTrue(dockerFile.exists());
Assert.assertTrue(content.contains("RUN native-image -jar custom_builder.jar -H:Name=custom_builder " +
"--no-fallback --static --libc=musl"));
Assert.assertTrue(content.contains("FROM ghcr.io/graalvm/native-image-community:17-muslib-ol8 as build"));
Assert.assertTrue(content.contains("FROM ghcr.io/graalvm/native-image-community:21-muslib-ol9 as build"));
Assert.assertTrue(content.contains("FROM gcr.io/distroless/base"));
KubernetesUtils.deleteDirectory(DOCKER_TARGET_PATH);
}
Expand All @@ -65,7 +65,7 @@ public void validateK8sBuildOption() throws IOException, InterruptedException, K
Assert.assertTrue(dockerFile.exists());
Assert.assertTrue(content.contains("RUN native-image -jar custom_builder.jar -H:Name=custom_builder " +
"--no-fallback --static --libc=musl"));
Assert.assertTrue(content.contains("FROM ghcr.io/graalvm/native-image-community:17-muslib-ol8 as build"));
Assert.assertTrue(content.contains("FROM ghcr.io/graalvm/native-image-community:21-muslib-ol9 as build"));
Assert.assertTrue(content.contains("FROM gcr.io/distroless/base"));
KubernetesUtils.deleteDirectory(DOCKER_TARGET_PATH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void validateDockerfile() throws IOException {
String content = Files.readString(dockerFile.toPath(), StandardCharsets.UTF_8);
Assert.assertTrue(content.contains("RUN native-image -jar hello.jar -H:Name=hello --no-fallback " +
"-H:+StaticExecutableWithDynamicLibC"));
Assert.assertTrue(content.contains("FROM ghcr.io/graalvm/native-image-community:17-ol8 as build"));
Assert.assertTrue(content.contains("FROM ghcr.io/graalvm/native-image-community:21-ol9 as build"));
Assert.assertTrue(content.contains("FROM gcr.io/distroless/base"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void validateDockerfile() throws IOException {
String content = Files.readString(dockerFile.toPath(), StandardCharsets.UTF_8);
Assert.assertTrue(content.contains("RUN native-image -jar hello.jar -H:Name=hello --no-fallback " +
"-H:+StaticExecutableWithDynamicLibC"));
Assert.assertTrue(content.contains("FROM ghcr.io/graalvm/native-image-community:17-ol8 as build"));
Assert.assertTrue(content.contains("FROM ghcr.io/graalvm/native-image-community:21-ol9 as build"));
Assert.assertTrue(content.contains("FROM gcr.io/distroless/base"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static void generateCaches(Path sourcePath, Path jBalToolsPath) {
defaultBuilder.addCompilationCacheFactory(new FileSystemCache.FileSystemCacheFactory(repo.resolve("cache")));
Project project = BuildProject.load(defaultBuilder, sourcePath);
PackageCompilation packageCompilation = project.currentPackage().getCompilation();
JBallerinaBackend.from(packageCompilation, JvmTarget.JAVA_17);
JBallerinaBackend.from(packageCompilation, JvmTarget.JAVA_21);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"character": 0
}
},
"newText": "# This file contains most used configurations supported by Ballerina Code to Cloud\n# All the fields are optional. If these fields are not specified, default value will be taken from the compiler.\n# Full Code to Cloud specification can be accessed from https://github.com/ballerina-platform/ballerina-spec/blob/master/c2c/code-to-cloud-spec.md\n# Uncomment Any field below if you want to override the default value.\n\n# Settings related to artifacts generation\n#[settings]\n#buildImage = true # Build the Docker image while building the project\n#thinJar = true # Use the thin jars in the container\n#\n# Properties related to the container image\n#[container.image]\n#name = \"hello\" # Name of the container image\n#repository = \"ballerina\" # Container repository to host the container\n#tag = \"latest\" # Tag of the container\n#base = \"ballerina/jvm-runtime:2.0\" # Base container of the container image\n#\n# Copy the files to the container image\n#[[container.copy.files]]\n#sourceFile = \"./data/data.txt\" # Path to the external file\n#target = \"/home/ballerina/data/data.txt\" # Path of the file within the container\n#\n# External files required for the code\n#[[cloud.config.maps]]\n#file = \"resource/file.txt\" # Path of the external file\n#mount_dir = \"/home/ballerina/resource\" # Directory of the file within the container\n#\n# Environment variables required for the application\n#[[cloud.config.envs]]\n#key_ref = \"FOO\" # Key of the environment variable\n#name = \"foo\" # Name of the env if it is different from the key\n#config_name = \"module-foo\" # Name of the config config map\n#\n# Properties related to the deployment\n#[cloud.deployment]\n#min_memory = \"100Mi\" # Minimum memory allocated to the container\n#max_memory = \"512Mi\" # Maximum memory allocated to the container\n#min_cpu = \"200m\" # Minimum CPU allocated to the container\n#max_cpu = \"500m\" # Maximum CPU allocated to the container\n#\n# Matrices to auto-scale the container\n#[cloud.deployment.autoscaling]\n#min_replicas = 1 # Minimum number of replicas of the container alive at a given time\n#max_replicas = 2 # Maximum number of replicas of the container alive at a given time\n#cpu = 50 # CPU Utilization threshold for spawning a new instance\n#\n# Probe to indicate whether the container is ready to respond to requests. No readiness probe will be generated if not specified\n#[cloud.deployment.probes.readiness]\n#port = 9091 # Port of the readiness probe endpoint\n#path = \"/probes/readyz\" # Endpoint of the readiness probe\n#\n# Probe to indicate whether the container is running. No liveness probe will be generated if not specified\n#[cloud.deployment.probes.liveness]\n#port = 9091 # Port of the liveness probe endpoint\n#path = \"/probes/healthz\" # Endpoint of the liveness probe\n#\n# Volume definitions of the application. No default volumes will be generated if not specified\n#[[cloud.deployment.storage.volumes]]\n#name = \"volume1\" # Name of the volume\n#local_path = \"files\" # Path of the volume\n#size = \"2Gi\" # Maximum size of the volume\n#\n# Properties related to the builder image of the multistage build\n#[graalvm.builder]\n#base = \"ghcr.io/graalvm/native-image-community:17-ol8\" # base image of the builder image\n#buildCmd = \"native-image -jar hello.jar hello\" # RUN statement to build the native image\n#"
"newText": "# This file contains most used configurations supported by Ballerina Code to Cloud\n# All the fields are optional. If these fields are not specified, default value will be taken from the compiler.\n# Full Code to Cloud specification can be accessed from https://github.com/ballerina-platform/ballerina-spec/blob/master/c2c/code-to-cloud-spec.md\n# Uncomment Any field below if you want to override the default value.\n\n# Settings related to artifacts generation\n#[settings]\n#buildImage = true # Build the Docker image while building the project\n#thinJar = true # Use the thin jars in the container\n#\n# Properties related to the container image\n#[container.image]\n#name = \"hello\" # Name of the container image\n#repository = \"ballerina\" # Container repository to host the container\n#tag = \"latest\" # Tag of the container\n#base = \"ballerina/jvm-runtime:2.0\" # Base container of the container image\n#\n# Copy the files to the container image\n#[[container.copy.files]]\n#sourceFile = \"./data/data.txt\" # Path to the external file\n#target = \"/home/ballerina/data/data.txt\" # Path of the file within the container\n#\n# External files required for the code\n#[[cloud.config.maps]]\n#file = \"resource/file.txt\" # Path of the external file\n#mount_dir = \"/home/ballerina/resource\" # Directory of the file within the container\n#\n# Environment variables required for the application\n#[[cloud.config.envs]]\n#key_ref = \"FOO\" # Key of the environment variable\n#name = \"foo\" # Name of the env if it is different from the key\n#config_name = \"module-foo\" # Name of the config config map\n#\n# Properties related to the deployment\n#[cloud.deployment]\n#min_memory = \"100Mi\" # Minimum memory allocated to the container\n#max_memory = \"512Mi\" # Maximum memory allocated to the container\n#min_cpu = \"200m\" # Minimum CPU allocated to the container\n#max_cpu = \"500m\" # Maximum CPU allocated to the container\n#\n# Matrices to auto-scale the container\n#[cloud.deployment.autoscaling]\n#min_replicas = 1 # Minimum number of replicas of the container alive at a given time\n#max_replicas = 2 # Maximum number of replicas of the container alive at a given time\n#cpu = 50 # CPU Utilization threshold for spawning a new instance\n#\n# Probe to indicate whether the container is ready to respond to requests. No readiness probe will be generated if not specified\n#[cloud.deployment.probes.readiness]\n#port = 9091 # Port of the readiness probe endpoint\n#path = \"/probes/readyz\" # Endpoint of the readiness probe\n#\n# Probe to indicate whether the container is running. No liveness probe will be generated if not specified\n#[cloud.deployment.probes.liveness]\n#port = 9091 # Port of the liveness probe endpoint\n#path = \"/probes/healthz\" # Endpoint of the liveness probe\n#\n# Volume definitions of the application. No default volumes will be generated if not specified\n#[[cloud.deployment.storage.volumes]]\n#name = \"volume1\" # Name of the volume\n#local_path = \"files\" # Path of the volume\n#size = \"2Gi\" # Maximum size of the volume\n#\n# Properties related to the builder image of the multistage build\n#[graalvm.builder]\n#base = \"ghcr.io/graalvm/native-image-community:21-ol9\" # base image of the builder image\n#buildCmd = \"native-image -jar hello.jar hello\" # RUN statement to build the native image\n#"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"source": "source/project1/Ballerina.toml",
"items": [
{
"label": "platform.java17.dependency",
"label": "platform.java21.dependency",
"kind": "Snippet",
"detail": "Table Array",
"sortText": "C",
"insertText": "[[platform.java17.dependency]]"
"insertText": "[[platform.java21.dependency]]"
},
{
"label": "package",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[build-options]
observabilityIncluded = true

[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "/usr/libs/"


4 changes: 4 additions & 0 deletions compiler-plugin/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@
<Match>
<Bug pattern="EI_EXPOSE_REP, EI_EXPOSE_REP2, MS_EXPOSE_REP" />
</Match>
<Match>
<Class name="io.ballerina.c2c.utils.DockerImageName"/>
<Bug pattern="CT_CONSTRUCTOR_THROW"/>
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ public class DockerGenConstants {
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 NATIVE_BUILDER_IMAGE = "ghcr.io/graalvm/native-image-community:17-ol8";
public static final String JRE_SLIM_BASE = "ballerina/jvm-runtime:3.0";
public static final String NATIVE_BUILDER_IMAGE = "ghcr.io/graalvm/native-image-community:21-ol9";
public static final String NATIVE_RUNTIME_BASE_IMAGE = "gcr.io/distroless/base";
public static final int MAX_BALLERINA_LAYERS = 110;

public static final String SCHEMA_FILE_NAME = "c2c-schema.json";
public static final String WINDOWS_SEPARATOR = "\\";
public static final String REFLECT_JSON_FILE = "reflect-config.json";
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private void setupForRunningTestsInCloud(CompilerLifecycleEventContext compilerL
Optional<Path> executablePath, Project project, Package currentPackage,
BalCommand balCommand) {
JBallerinaBackend jBallerinaBackend = JBallerinaBackend.from(compilerLifecycleEventContext.compilation(),
JvmTarget.JAVA_17);
JvmTarget.JAVA_21);
dataHolder.getDockerModel().setTest(true);
executablePath.ifPresent(path -> {
Target target;
Expand Down Expand Up @@ -331,7 +331,7 @@ private void addTestDependencyJars(Project project, PackageCompilation compilati
Map<String, TestSuite> testSuiteMap,
List<Path> classPaths, List<Path> moduleJarPaths) {
JBallerinaBackend jBallerinaBackend = JBallerinaBackend.from(compilation,
JvmTarget.JAVA_17);
JvmTarget.JAVA_21);
JarResolver jarResolver = jBallerinaBackend.jarResolver();

Collection<JarLibrary> dependencies = jarResolver.getJarFilePathsRequiredForTestExecution(
Expand Down Expand Up @@ -378,7 +378,7 @@ private static Path getCopiedJarPath(Path jarFileName) {

private void addDependencyJars(PackageCompilation compilation, String executableFatJar) {
JBallerinaBackend jBallerinaBackend = JBallerinaBackend.from(compilation,
JvmTarget.JAVA_17);
JvmTarget.JAVA_21);
io.ballerina.projects.JarResolver jarResolver = jBallerinaBackend.jarResolver();
// Add dependency jar files to docker model.
dataHolder.getDockerModel().addDependencyJarPaths(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void codeGeneratedInternal(PackageID packageId, Path executableJarFile, S
}

private void addDependencyJars(PackageCompilation compilation, String executableFatJar) {
JBallerinaBackend jBallerinaBackend = JBallerinaBackend.from(compilation, JvmTarget.JAVA_17);
JBallerinaBackend jBallerinaBackend = JBallerinaBackend.from(compilation, JvmTarget.JAVA_21);
io.ballerina.projects.JarResolver jarResolver = jBallerinaBackend.jarResolver();

// Add dependency jar files to docker model.
Expand Down
2 changes: 1 addition & 1 deletion compiler-plugin/src/main/resources/c2c-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@
"description": "base image of the builder image",
"type": "string",
"pattern": "^(?!\\s*$).+",
"default": "ghcr.io/graalvm/native-image-community:17-ol8",
"default": "ghcr.io/graalvm/native-image-community:21-ol9",
"message": {
"pattern": "`base` should not be empty"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/graalvm-custom-builder/Cloud.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ tag = "1.0.0"
buildImage = false

[graalvm.builder]
base = "ghcr.io/graalvm/native-image-community:17-muslib-ol8"
base = "ghcr.io/graalvm/native-image-community:21-muslib-ol9"
buildCmd = "native-image -jar custom_builder.jar -H:Name=custom_builder --no-fallback --static --libc=musl"
51 changes: 28 additions & 23 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@ org.gradle.jvmargs='-Dfile.encoding=UTF-8'
group=io.ballerina
version=3.1.1-SNAPSHOT
systemProp.org.gradle.internal.publish.checksums.insecure=true
ballerinaLangVersion=2201.11.0-20241111-172200-095db58f
stdlibConstraintVersion=1.5.0
stdlibIoVersion=1.6.1
stdlibLogVersion=2.10.0
stdlibHttpVersion=2.12.0
stdlibAuthVersion=2.12.0
stdlibFileVersion=1.10.0
stdlibCacheVersion=3.8.0
stdlibCryptoVersion=2.7.2
stdlibTimeVersion=2.4.0
stdlibMimeVersion=2.10.0
stdlibOsVersion=1.8.0
stdlibTaskVersion=2.5.0
stdlibJwtVersion=2.13.0
stdlibGrpcVersion=1.12.0
stdlibOAuth2Version=2.12.0
stdlibUuidVersion=1.8.0
stdlibGraphqlVersion=1.14.0
stdlibUrlVersion=2.4.0
stdlibWebsubVersion=2.12.0
stdlibWebsubhubVersion=1.12.0
observeVersion=1.3.0
observeInternalVersion=1.3.0
spotbugsPluginVersion=6.0.18
shadowJarPluginVersion=8.1.1
downloadPluginVersion=5.4.0
releasePluginVersion=2.8.0
ballerinaLangVersion=2201.11.0-20241117-133400-a3054b77
stdlibConstraintVersion=1.6.0-20241113-090900-d276ad5
stdlibIoVersion=1.6.2-20241112-233100-995cf5f
stdlibLogVersion=2.10.1-20241113-120000-4577868
stdlibHttpVersion=2.13.0-20241114-182900-7e9f66a
stdlibAuthVersion=2.12.1-20241113-162300-ded40eb
stdlibFileVersion=1.10.1-20241113-151700-e1a2e38
stdlibCacheVersion=3.8.1-20241113-125700-b75a1bf
stdlibCryptoVersion=2.7.3-20241113-081400-d015a39
stdlibTimeVersion=2.6.0-20241113-073800-201b904
stdlibMimeVersion=2.10.2-20241113-154200-d953747
stdlibOsVersion=1.8.1-20241113-122000-cca973b
stdlibTaskVersion=2.5.1-20241113-123500-f905281
stdlibJwtVersion=2.13.1-20241113-162400-b59ccfa
stdlibGrpcVersion=1.13.0-20241114-195700-5188f60
stdlibOAuth2Version=2.12.1-20241113-162400-4c6ddfe
stdlibDataJsonDataVersion=0.3.0-20241114-143900-285d739
stdlibUuidVersion=1.8.1-20241113-154400-443c67b
stdlibGraphqlVersion=1.15.0-20241117-164000-4d95b39
stdlibUrlVersion=2.4.1-20241113-073900-335ff51
stdlibWebsubVersion=2.13.0-20241114-233100-73205d6
stdlibWebsubhubVersion=1.13.0-20241116-124900-2bb76a4
observeVersion=1.4.0-20241113-092000-b83ae74
observeInternalVersion=1.3.1-20241113-101700-265054d
ballerinaGradlePluginVersion=2.0.1
9 changes: 6 additions & 3 deletions gradle/javaProject.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

sourceCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21

jacoco {
toolVersion = "0.8.10"
Expand All @@ -58,8 +58,11 @@ test {

spotbugsMain {
ignoreFailures = true
effort = "max"
reportLevel = "low"
def classLoader = plugins["com.github.spotbugs"].class.classLoader
def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence")
def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort")
effort = SpotBugsEffort.MAX
reportLevel = SpotBugsConfidence.LOW
reportsDir = file("$project.buildDir/reports/spotbugs")
def excludeFile = file("spotbugs-exclude.xml")
if (excludeFile.exists()) {
Expand Down

0 comments on commit 96b54f2

Please sign in to comment.