Skip to content

Commit

Permalink
Add back docker prune step between python container pushes (#28033) (#…
Browse files Browse the repository at this point in the history
…28101)

* Add back docker prune step between python container pushes

* Extract to variables

* Define var inside loop to avoid async race condition
  • Loading branch information
damccorm committed Aug 22, 2023
1 parent 28d20e4 commit 8f762e3
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion sdks/python/container/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ plugins { id 'org.apache.beam.module' }
applyGoNature()

description = "Apache Beam :: SDKs :: Python :: Container"
int min_python_version=8
int max_python_version=11

configurations {
sdkSourceTarball
Expand All @@ -42,8 +44,34 @@ tasks.register("buildAll") {
dependsOn ':sdks:python:container:py311:docker'
}

for(int i=min_python_version; i<=max_python_version; ++i) {
String min_version = "3" + min_python_version
String cur = "3" + i
String prev = "3" + (i-1)
tasks.register("push" + cur) {
if (cur != min_version) {
// Enforce ordering to allow the prune step to happen between runs.
// This will ensure we don't use up too much space (especially in CI environments)
mustRunAfter(":sdks:python:container:push" + prev)
}
dependsOn ':sdks:python:container:py' + cur + ':docker'

doLast {
if (project.hasProperty("prune-images")) {
exec {
executable("docker")
args("system", "prune", "-a", "--force")
}
}
}
}
}

tasks.register("pushAll") {
dependsOn ':sdks:python:container:buildAll'
dependsOn ':sdks:python:container:push38'
dependsOn ':sdks:python:container:push39'
dependsOn ':sdks:python:container:push310'
dependsOn ':sdks:python:container:push311'
}

tasks.register("generatePythonRequirementsAll") {
Expand Down

0 comments on commit 8f762e3

Please sign in to comment.