diff --git a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java index c05ad51507034..b58baf8f24033 100644 --- a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java +++ b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java @@ -187,4 +187,13 @@ public class JibConfig { */ @ConfigItem public Optional dockerExecutableName; + + /** + * Whether to set the creation time to the actual build time. Otherwise, the creation time + * will be set to the Unix epoch (00:00:00, January 1st, 1970 in UTC). See Jib + * FAQ for more information + */ + @ConfigItem(defaultValue = "true") + public boolean useCurrentTimestamp; } diff --git a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java index 9e465a1879caf..e7e3ddb6c11a9 100644 --- a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java +++ b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java @@ -482,8 +482,12 @@ private JibContainerBuilder createContainerBuilderFromFastJar(String baseJvmImag .setWorkingDirectory(workDirInContainer) .setEntrypoint(entrypoint) .setEnvironment(getEnvironmentVariables(jibConfig)) - .setLabels(allLabels(jibConfig, containerImageConfig, containerImageLabels)) - .setCreationTime(Instant.now()); + .setLabels(allLabels(jibConfig, containerImageConfig, containerImageLabels)); + + if (jibConfig.useCurrentTimestamp) { + jibContainerBuilder.setCreationTime(Instant.now()); + } + for (int port : jibConfig.ports) { jibContainerBuilder.addExposedPort(Port.tcp(port)); } @@ -558,8 +562,11 @@ private JibContainerBuilder createContainerBuilderFromLegacyJar(String baseJvmIm JibContainerBuilder jibContainerBuilder = javaContainerBuilder.toContainerBuilder() .setEnvironment(getEnvironmentVariables(jibConfig)) - .setLabels(allLabels(jibConfig, containerImageConfig, containerImageLabels)) - .setCreationTime(Instant.now()); + .setLabels(allLabels(jibConfig, containerImageConfig, containerImageLabels)); + + if (jibConfig.useCurrentTimestamp) { + jibContainerBuilder.setCreationTime(Instant.now()); + } if (jibConfig.jvmEntrypoint.isPresent()) { jibContainerBuilder.setEntrypoint(jibConfig.jvmEntrypoint.get()); @@ -597,8 +604,12 @@ private JibContainerBuilder createContainerBuilderFromNative(JibConfig jibConfig .setWorkingDirectory(workDirInContainer) .setEntrypoint(entrypoint) .setEnvironment(getEnvironmentVariables(jibConfig)) - .setLabels(allLabels(jibConfig, containerImageConfig, containerImageLabels)) - .setCreationTime(Instant.now()); + .setLabels(allLabels(jibConfig, containerImageConfig, containerImageLabels)); + + if (jibConfig.useCurrentTimestamp) { + jibContainerBuilder.setCreationTime(Instant.now()); + } + for (int port : jibConfig.ports) { jibContainerBuilder.addExposedPort(Port.tcp(port)); }