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

Jib and Gradle rebuild with arbitrary file change. #3457

Closed
forgo opened this issue Dec 28, 2019 · 12 comments
Closed

Jib and Gradle rebuild with arbitrary file change. #3457

forgo opened this issue Dec 28, 2019 · 12 comments
Labels
area/build build/jib help wanted We would love to have this done, but don't have the bandwidth, need help from contributors kind/feature-request priority/p3 agreed that this would be good to have, but no one is available at the moment.

Comments

@forgo
Copy link

forgo commented Dec 28, 2019

Expected behavior

I have a series of custom gradle tasks that leverage different built-in tasks. It goes something like this:

assemble -> tar (custom) -> copy (custom) -> jib*

I'm leveraging Jib to easily containerize/serve my JavaScript using an nginx:latest image.

Everything works great, but I'd like to be able to trigger a skaffold rebuild when I change a non-Java related file under my gradle project.

For example:

My copy tasks takes an Nginx config from my project's nginx/default.conf and preps it into build/jib-extra-dir/... along with my exploded web content bundle.

I'd like to be able to trigger a skaffold deployment when something in default.conf or my tar.gz changes.

Is there a way to accomplish this via the skaffold.yaml?

I noticed other types of build artifacts (e.g. - buildpack) offer a dependencies: section which:

file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact.

Why is it that jib artifacts do not also have this feature?

Actual behavior

Changes to Nginx config file don't redeploy my client container.

Information

  • Skaffold version: 1.1.0
  • Operating system: macOS Catalina 10.15.1 (19B88)
  • Contents of skaffold.yaml:
build:
  artifacts:
  - image: forgo/forgo-client
    jib:
      project: client
@loosebazooka
Copy link
Member

Yeah this isn't currently possible mostly because jib can't know how those files are getting there. I think it makes sense for us to add a dependencies to the jib config block.

@nkubala
Copy link
Contributor

nkubala commented Jan 8, 2020

we could also address this by adding support for a trigger file. see #1954

@balopat balopat added kind/feature-request priority/p3 agreed that this would be good to have, but no one is available at the moment. labels Jan 16, 2020
@balopat
Copy link
Contributor

balopat commented Jan 16, 2020

I agree that something here would be interesting.

Now Jib itself is providing dependencies automatically currently (based on maven src, resources definitions), similar to Docker builder (we calculate it based COPY and ADD commands) that's why we didn't have that here in the first place.

I'm thinking about calling this extraBuildTriggers?

@nkubala WDYT?

We'll also need a mini design doc here to explore the cases when these overlap with jib dependencies and/or sync definitions.

@balopat balopat added the help wanted We would love to have this done, but don't have the bandwidth, need help from contributors label Jan 16, 2020
@nkubala
Copy link
Contributor

nkubala commented Jan 21, 2020

@balopat that seems fine. it might be nice to somehow say these are files and not "triggers" themselves, though now we're getting pretty verbose so I'm not sure it matters much.

I'd love to see a small design writeup here if anyone is interested!

@lightoze
Copy link

@balopat @nkubala For many projects Jib plugin makes a decent job but there are special use cases. I've encountered one of them with a module utilizing generated resources. Current implementation has two drawbacks:

  1. Jib does not report any inputs of Gradle resource generation task to Skaffold, so rebuild is not triggered during "skaffold dev" and caching is not working correctly.
  2. Jib reports generated resources folder. That may be desirable sometimes, e.g. when generated resources are stored in version control. When resources are always generated during the build this creates another caching problem - I encountered a situation where it picked up cached image for empty (not yet generated) resource directory and skipped the build. It also may trigger unnecessary redeploys when resource generation is not entirely reproducible (e.g. some contents are randomly reordered).

So my design suggestion is to have same style dependencies { paths: [], ignore: [] } configuration for Jib as for buildpack and others, so that dependencies reported by _jibSkaffoldFilesV2 task are merged with manual ones and ignores are applied afterwards.

Another option would be to handle that in Jib itself but it's Skaffold-specific configuration anyways and having it in skaffold.yaml seems to be a simpler solution.

@loosebazooka
Copy link
Member

loosebazooka commented Feb 12, 2020

@lightoze is your generated resources folder in the build directory?

Perhaps there's a way to query the runtimeClasspath to get the inputs that generate it? didn't realize you're referencing resources, not classes

@lightoze
Copy link

@loosebazooka yes it is in build directory. Also generated sources probably will cause the same problem.

@loosebazooka
Copy link
Member

@lightoze I think this is better solved on the jib side -- in the linked proposal: GoogleContainerTools/jib#2290

@lightoze
Copy link

@loosebazooka ultimately either way is fine for me. Having it on jib side is much more flexible, though.

@loosebazooka
Copy link
Member

I would probably actually prefer it happens on the jib side.

@loosebazooka
Copy link
Member

@lightoze any chance you can try out this branch? GoogleContainerTools/jib#2292

@nkubala nkubala added this to the Icebox [P2+] milestone Sep 1, 2020
@briandealwis
Copy link
Member

Closing as fixed in upstream: see the Jib docs for the skaffold watch configuration (maven, gradle).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build build/jib help wanted We would love to have this done, but don't have the bandwidth, need help from contributors kind/feature-request priority/p3 agreed that this would be good to have, but no one is available at the moment.
Projects
None yet
Development

No branches or pull requests

7 participants