Upgrade Python Docker base image
org.openrewrite.python.migrate.UpgradePythonDockerImageArtifactorg.openrewrite.recipe:rewrite-migrate-pythonUpdate the Python version of Python images in Dockerfiles to a target version: FROM python:<version> base images and COPY --from=<python image> / ADD --from=<python image> stage references (e.g. COPY --from=registry.example.com/approved-images/python:3.10-ubuntu22.04 /usr /usr). Tag suffixes such as -slim are preserved, any patch component is dropped, and an image already on a newer version is left as-is. --from references to named build stages are not image references and are left untouched.
Add to your build
~/.gradle/gradle.properties
codeGenomeUsername=you@example.com
codeGenomeToken=YOUR_DOWNLOAD_TOKEN
build.gradle.kts
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("org.openrewrite.python.migrate.UpgradePythonDockerImage")
}
repositories {
mavenCentral()
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = providers.gradleProperty("codeGenomeUsername").get()
password = providers.gradleProperty("codeGenomeToken").get()
}
}
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-migrate-python:0.14.0")
}
Then run
./gradlew rewriteRunThis recipe has required options, which a build sets in a rewrite.yml recipe that you activate instead.
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.python.migrate.UpgradePythonDockerImage --recipe-option "version=3.12"If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-migrate-python:RELEASEOptions
| Name | Type | Description |
|---|---|---|
versionrequired | String | The target Python version as MAJOR.MINOR (for example 3.12). Any patch component is dropped; the minor release is the upgrade target.e.g. 3.12 |
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats