-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Remove shared getDockerBuildTask
to enable parallel docker builds
#16384
Conversation
@davinchia I tried to sort out how we might share this Gradle method outside of the main build.gradle file (https://stackoverflow.com/questions/18715137/extract-common-methods-from-gradle-build-script#18718802) and I really can't get anything to work... any tips? |
Some notes:
|
@davinchia I've hit the end of my Gradle abilities (I tried messing around in buildSrc for a while). I've cleaned things up a bit, but there's still a lot of repeated code. I suggest we merge this in now, so we get the speed-up, and then in the future when you've got some time, a refactor can take place. |
@evantahler i'm pairing with @jdpgrailsdev later. I want to spend some time tomorrow trying something before we merge this in. That sound ok? |
airbyte-config/init/build.gradle
Outdated
buildArgs.put('JDK_IMAGE', openjdkImage) | ||
buildArgs.put('VERSION', buildVersion) | ||
} | ||
localDockerBuildTask.dependsOn(copyScripts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdpgrailsdev I believe what we did today works!
One hiccup is we have submodules whose copy tasks are on scripts instead of the generated tar. I have some idea on how to fix this but want to do in person as it's faster.
build.gradle
Outdated
// If subprojects have the dockerImageName property configured in their gradle property file, | ||
// register: | ||
// 1) A task to copy the generated tar. | ||
// 2) A task to build the docker image that depends on the generated tar. | ||
// 3) Make the docker image task depend on the default assemble task. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fancy!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
the old def Task getDockerBuildTask
always felt like a hack anyway
Thanks for getting this done @davinchia! |
method takes 2 arguments: | ||
- The image name, for example if `foo` is given as an image name, the image `airbyte/foo` will be created | ||
- The project directory folder. It is needed because the `getDockerBuildTask` is declared in the rootProject | ||
The top level `build.gradle` file defines several convenient tasks for building a docker image. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@git-phu how does this look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great! Just one comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great! Just one comment
method takes 2 arguments: | ||
- The image name, for example if `foo` is given as an image name, the image `airbyte/foo` will be created | ||
- The project directory folder. It is needed because the `getDockerBuildTask` is declared in the rootProject | ||
The top level `build.gradle` file defines several convenient tasks for building a docker image. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great! Just one comment
Co-authored-by: Peter Hu <peter@airbyte.io>
@evantahler @davinchia I think this PR broke my local build, for all the gradle modules which dont have the application plugin configured (Applying the Application plugin also implicitly applies the Distribution plugin), the task distTar is unknown and since the new subProject logic makes the
The error that am getting (this is just for
I fixed it by adding the distribution plugin to all such modules (see PR #16781) , but am not sure if thats the right thing to do. I think we might need to re-tweak the logic of Let me know what you think of it. |
@subodh1810 this isn't showing up for me or on the build runners. Wonder if it's specific to you. Can you try |
…irbytehq#16384) Define logic in root build.gradle to create a task in each subproject if the subproject contains dockerImageName in the gradle.properties file. Some caveats: - We also define a copyGeneratedTar task that is applied to all subprojects with the dockerImageName property. - This does not need to be used in each subproject. We leave it up to each subproject to define what task is depends on since some projects have more custom copy logic.
…irbytehq#16384) Define logic in root build.gradle to create a task in each subproject if the subproject contains dockerImageName in the gradle.properties file. Some caveats: - We also define a copyGeneratedTar task that is applied to all subprojects with the dockerImageName property. - This does not need to be used in each subproject. We leave it up to each subproject to define what task is depends on since some projects have more custom copy logic.
After a hot tip from the creator of the Docker Gradle plugin we are using, I removed our sharedgetDockerBuildTask
gradle task and moved it into each project. This did allow our docker builds to run in parallel!* Before - 18:30* After - 8:40Note how in the build scans the docker tasks in "after" ran in parallel 🥳To achieve ^ cleanly, we define logic in root build.gradle to create a task in each subproject if the subproject contains
dockerImageName
in the gradle.properties file.Some caveats:
dockerImageName
property. Although this do not need to be used in each subproject.