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

Add a useCurrentTimestamp flag for Jib #23463

Merged
merged 1 commit into from
Feb 6, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,13 @@ public class JibConfig {
*/
@ConfigItem
public Optional<String> 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 <a href=
* "https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#why-is-my-image-created-48-years-ago">Jib
* FAQ</a> for more information
*/
@ConfigItem(defaultValue = "true")
public boolean useCurrentTimestamp;
}
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,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));
}
Expand Down Expand Up @@ -539,8 +543,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());
Expand Down Expand Up @@ -578,8 +585,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));
}
Expand Down