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
Allow Dockerfile task to be UP-TO-DATE #357
Comments
@ayedo I think this is worth considering. I can imagine use cases when generated @cdancy WDYT? @ayedo are you interested in submitting PR? |
@orzeh I agree. Think this was probably left in from when we attempted a go at making docker image reproduction "UP-TO-DATE". |
would be very helpful if this is fixed |
@remmeier submit a PR? |
Removed in master. Next release will have change. |
currently we suspect this change to cause images are not rebuild properly with the application plugin ( |
Hi, I ran into a problem recently where I would change my "Dockerfile" task (specifically adding some environment variables and changing the entry point), however when I rebuild a task that depends on the "Dockerfile" task, the build task thinks that the "Dockerfile" task is up to date. Could it be that this is a regression that was introduced by the fix for this issue? It sounds a bit like what @childnode is experiencing as well. |
@kaserf what version of the plugin are you using? |
@cdancy 3.0.9 |
@kaserf that's why. Try upgrading to |
Just tried with |
@cdancy can you point me to a commit that fixed this? Maybe that helps narrowing down my issue. |
@kaserf You have to explicitly set inputs for task of type buildscript {
repositories {
jcenter()
}
}
plugins {
id "com.bmuschko.docker-remote-api" version "3.0.12"
}
ext {
alpineVersion = "3"
}
task dockerfile(type: com.bmuschko.gradle.docker.tasks.image.Dockerfile) {
from "alpine:$alpineVersion"
inputs.property "alpineVersion", alpineVersion
}
task build {
dependsOn dockerfile
} |
Thanks, I think there is a slight misunderstanding though! What about the following change:
Should this set the up to date check to false? I would assume so. I am changing the task itself, that should always set it to not be up to date. |
@kaserf you are right. I think this is a bug. In |
so, this I would also suggest to implicit define the input properties on every instruction change. If this is the case when you change Ps.: Time to reopen this issue or creating a PR for? |
@orzeh @kaserf @childnode so while we could make the @kaserf from your snippet above were you able to move forward? It wasn't clear after trying the above if you were able to get around your problem. @childnode if you have something in mind please feel free to send in a PR for review. |
Well, my workaround currently is to append this to my gradle file:
I took over this code from someone else, the gist seems to be not to use |
@kaserf correct. You could either use entrypoint method or as I believe you used above the instruction method. |
@kaserf that brings us back to the beginning @cdancy I don't understand in which cases the instruction list is not filled with the relevant information due to extensions on interfaces? |
@childnode there are 2 separate issues here at play. Yours is slightly different and it might warrant opening up another ISSUE/PR as you say if only to avoid folks chiming in here and confusing the flow of conversation. |
Talking about confusion... @cdancy are you saying the way I am doing things (modulo the |
Using Should I open a bug for this @cdancy ? |
OK, I was hacking with this for a while, and it turns out both issues have the same root. After removing The problem is that Gradle knows task output, but doesn't know anything about inputs. We can't just add
This can be used to do the following: Dockerfile() {
inputs.property("instructionsCache", { instructions.collect { it.build() }.join('\n') })
} Gradle will track string with instructions, which is the real task input. The closure will be evaluated in task execution phase, so everything should work as expected. I've prepared proof-of-concept of this solution and will submit it as a PR. Any feedback welcome! |
addressing - bmuschko#357 - and bmuschko#433
addressing - bmuschko#357 - and bmuschko#433
even I see this might be more related to #433 now, I'll continue here as an answer to @orzeh
what is predictable since gradle always only checks for incoming changes but not if the outcome would change .. have to, because else it will produce an outcome to then decide "not to run the task"
this ^ and the suggested change
would lead to longer build times, gradle startups due to the fact on any configuration phase, even the task is called or not, the input.property closure is evaluated and therefor the build() for all instructions are called. so I suggest to take the more affordable way to make instructions list Serializable. The only nut I see is to handle the closures given, but we can just serialize a hash from it, can't we? just started to write a regression test ... childnode@1e2690c |
addressing - bmuschko#357 - and bmuschko#433
@childnode if there is any room for improvement feel free to add that to your branch and we can review it there.
I think this may be Ok as tasks of this nature should generally be smaller and the process time should be quick enough though if there is a better way then by all means put that into your branch/PR and lets have at it! ;) |
ok, seems to #433 fixed -both- two out of three (see more in #434) and has no negative affects. Thanks @cdancy and @orzeh for you affords P.S: I expect
? If yes, this seems no to work in conjunction with the fix from #433 |
…nZenith } }` a valid use case now the base issue is fixed by bmuschko#433 ? << bmuschko#357 (comment)
…nZenith } }` a valid use case now the base issue is fixed by bmuschko#433 ? << bmuschko#357 (comment)
…nZenith } }` a valid use case now the base issue is fixed by bmuschko#433 ? << bmuschko#357 (comment)
…ateSpec - adressing bmuschko#357 and bmuschko#433
Closing as this has been addressed in a few PR's in an attempt to alleviate some (not all) of the issues noted. |
First of all: thanks for your awesome work!
I was wondering: why does the Dockerfile task set the following in the constructor:
Dockerfile() { outputs.upToDateWhen { false } }
I'm using the plugin to start a postgres database during the build in order to generate a jOOQ meta model. Incremental building does not work since in the end, the build chain depends on the Dockerfile task, which is never upToDate.
I tried overwriting the directive in my task, but without success.
The text was updated successfully, but these errors were encountered: