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

feat(jib): support building images from scratch #3091

Merged
merged 1 commit into from
May 23, 2024
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 @@ -22,6 +22,7 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import com.google.cloud.tools.jib.api.ImageReference;
import org.eclipse.jkube.kit.build.api.assembly.BuildDirs;
import org.eclipse.jkube.kit.common.Assembly;
import org.eclipse.jkube.kit.common.AssemblyFileEntry;
Expand Down Expand Up @@ -54,10 +55,16 @@ private JibServiceUtil() {
private static final String BUSYBOX = "busybox:latest";

public static JibContainerBuilder containerFromImageConfiguration(
ImageConfiguration imageConfiguration, String pullRegistry, Credential pullRegistryCredential) {
final JibContainerBuilder containerBuilder = Jib
.from(toRegistryImage(getBaseImage(imageConfiguration, pullRegistry), pullRegistryCredential))
.setFormat(ImageFormat.Docker);
ImageConfiguration imageConfiguration, String pullRegistry, Credential pullRegistryCredential
) {
final String baseImage = getBaseImage(imageConfiguration, pullRegistry);
final JibContainerBuilder containerBuilder;
if (baseImage.equals(ImageReference.scratch().toString() + ":latest")) {
containerBuilder = Jib.fromScratch();
} else {
containerBuilder = Jib.from(toRegistryImage(baseImage, pullRegistryCredential));
}
containerBuilder.setFormat(ImageFormat.Docker);
if (imageConfiguration.getBuildConfiguration() != null) {
final BuildConfiguration bic = imageConfiguration.getBuildConfiguration();
Optional.ofNullable(bic.getEntryPoint())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,6 @@ void prependsRegistryWhenNotConfiguredInName() throws Exception {
@DisplayName("build")
class Build {

@BeforeEach
void setUp() {
imageConfiguration = imageConfiguration.toBuilder()
.build(imageConfiguration.getBuild().toBuilder()
.from("gcr.io/distroless/base@sha256:8267a5d9fa15a538227a8850e81cf6c548a78de73458e99a67e8799bbffb1ba0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was that part not necessary ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anymore

It was necessary because from scratch wasn't supported

.build())
.build();
}

@Test
void build() throws Exception {
try (JibService jibService = new JibService(jibLogger, testAuthConfigFactory, configuration, imageConfiguration)) {
Expand Down