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

Custom base image ignored with Jib Gradle 1.6.0 #1995

Closed
lpellegr opened this issue Sep 15, 2019 · 3 comments · Fixed by #1998
Closed

Custom base image ignored with Jib Gradle 1.6.0 #1995

lpellegr opened this issue Sep 15, 2019 · 3 comments · Fixed by #1998

Comments

@lpellegr
Copy link
Contributor

Environment:

  • Jib version: 1.6.0
  • Build tool: Gradle 5.6.1
  • OS: Fedora 30

Description of the issue:

I have a Gradle app that is configured to use Java 12:

sourceCompatibility = 12
targetCompatibility = 12

It is packaged with Jib. Since Jib includes support for Java 11 only by default, I specify a Java 12 base image as follows. Unfortunately, when I run gradle jibDockerBuild, the task fails with the following message:

Your project is using Java 12 but the base image is for Java 11, perhaps you should configure a Java 12-compatible base image using the 'jib.from.image' parameter, or set targetCompatibility = 11 or below in your build configuration

Expected behavior:

Gradle jibDockerBuild task completes with success.

Steps to reproduce:

  1. Create a basic Java 12 app using Gradle.
  2. Include Gradle Jib definition as follows.
  3. Run gradle jibDockerBuild.

jib-gradle-plugin Configuration:

jib {
    container {
        jvmFlags = [
                '-server',
                '-Xms6g',
                '-Xmx6g',
                '-XX:+UnlockExperimentalVMOptions',
                '-XX:+UseShenandoahGC',
                '-Dauto-update.temp.dir=/root',
                '-Dmanagement.endpoints.jmx.exposure.exclude=*',
                '-Dmanagement.endpoints.web.exposure.include=health',
                '-Dspring.application.admin.enabled=false',
                '-Dspring.jmx.enabled=false'
        ]
        mainClass 'com.acme.Application'
    }
    from {
        image 'adoptopenjdk/openjdk12:slim'
    }
    to {
        auth {
            image = 'registry.hub.docker.com/acme/api:latest'
            username = 'acme'
            password = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
        }
        tags = ['latest']
    }
}

Additional Information: Downgrading to Jib Gradle version 1.5.1 solves the issue. It seems a change was introduced with version 1.6.0. I tried adding the prefix 'registry://' to the base image name but the task still fails.

@chanseokoh
Copy link
Member

chanseokoh commented Sep 15, 2019

@lpellegr thanks for reporting the bug. The version check is broken rather than the base image is ignored. We will fix this soon.

Just so you know, 1.5.0 and 1.5.1 suffer from an issue of substantially slower network performance than 1.6.0 and 1.4.0.

     String baseImageConfig =
-        rawConfiguration.getFromImage().orElse(getDefaultBaseImage(projectProperties));
+        rawConfiguration.getFromImage().isPresent()
+            ? rawConfiguration.getFromImage().get()
+            : getDefaultBaseImage(projectProperties);
     if (baseImageConfig.startsWith(Jib.TAR_IMAGE_PREFIX)) {
       return JavaContainerBuilder.from(baseImageConfig);
     }

@TadCordle
Copy link
Contributor

@lpellegr We just released v1.6.1 with the fix.

@lpellegr
Copy link
Contributor Author

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants