question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configuring a base image built earlier in the Gradle build

See original GitHub issue

I’d like to use a base image for Jib that was built (via a normal Dockerfile) earlier in the Gradle build. (This lets me use a base OS and JDK of my choosing with project-specific other things that aren’t easily done by simply copying files from the project via jib’s extraDirectories.)

The image is built like this using https://bmuschko.github.io/gradle-docker-plugin/:

task buildBaseDockerImg(type: DockerBuildImage) {
    inputDir = file("$rootProject.projectDir/docker")
}

I can get the sha256:... string for the image with another task:

task inspect(type: DockerInspectImage) {
    dependsOn buildBaseDockerImg

    targetImageId buildBaseDockerImg.imageId

    onNext { image ->
        // the sha256:.. is at `image.config.image`
    }
}

However, in the onNext closure seems to be too late to configure the jib extension to use the sha256:.... Is there a way to do this?

Note: even when I configure the jib extension with something like

jib {
    from {
        image = 'sha256:...'
    }

it still seems to be trying to pull that from a repository, which of course doesn’t work since I didn’t push it anywhere. Does jib only know how to use base images that it pulls from a repo?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
loosebazookacommented, Jan 24, 2019

@marshallpierce to clarify, what I mean is doing something like this in your build.gradle and using that uuidTag everywhere

def uuidTag = UUID.randomUUID().toString()
println uuidTag
0reactions
loosebazookacommented, Jan 24, 2019

Gotcha. I’ll go ahead and close this for now. Please open a new bug if you’re having trouble further optimizing your build with jib.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automating Docker Builds With Gradle - Tom Gregory
Let's configure the Palantir Docker plugin to create an image for the Dockerfile we just created, and then run the container.
Read more >
Java Example with Gradle and Docker · Codefresh | Docs
The easiest way to use Gradle is with multi-stage builds. With multi-stage builds a Docker build can use one base image for compilation/packaging/unit...
Read more >
Building Docker image with Gradle - DevBlog
In short - you need to build Docker image and push it to registry. ... I will show how to prepare Gradle configuration...
Read more >
Configure your build - Android Developers
There are a few Gradle build configuration files that are part of the standard project structure for an Android app. Before you can...
Read more >
Create images using Jib Gradle plugin
1. In jib extension we configure the three important fields. The `from`. Configures the base image to build our application on top of....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found