← All recipes
Open source

Add OCI image labels

Recipe IDorg.openrewrite.docker.AddOciLabelsArtifactorg.openrewrite:rewrite-docker

Adds standard OCI (Open Container Initiative) image labels to a Dockerfile. These labels provide metadata about the image such as title, version, source, and license information. See https://github.com/opencontainers/image-spec/blob/main/annotations.md for the specification.

Single recipeApache 2.0

Add to your build

Get a download tokenSign in with GitHub or Google, and your token replaces YOUR_DOWNLOAD_TOKEN below. Free for open source recipes like this one.

~/.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.docker.AddOciLabels")
}

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:rewrite-docker:8.92.8")
}

Then run

./gradlew rewriteRun

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.docker.AddOciLabels

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite:rewrite-docker:RELEASE

Options

NameTypeDescription
titleStringHuman-readable title of the image (org.opencontainers.image.title).
e.g. My Application
descriptionStringHuman-readable description of the image (org.opencontainers.image.description).
e.g. A containerized web application
versionStringVersion of the packaged software (org.opencontainers.image.version).
e.g. 1.0.0
createdStringDate and time the image was built in RFC 3339 format. If 'now', uses the current time.
e.g. 2024-01-15T10:30:00Z
revisionStringSource control revision identifier for the packaged software (org.opencontainers.image.revision).
e.g. abc123def456
sourceStringURL to get source code for building the image (org.opencontainers.image.source).
e.g. https://github.com/myorg/myapp
urlStringURL to find more information about the image (org.opencontainers.image.url).
e.g. https://myapp.example.com
vendorStringName of the distributing entity, organization, or individual (org.opencontainers.image.vendor).
e.g. My Organization
licensesStringLicense(s) under which contained software is distributed as a SPDX License Expression (org.opencontainers.image.licenses).
e.g. Apache-2.0
authorsStringContact details of the people or organization responsible (org.opencontainers.image.authors).
e.g. maintainers@example.com

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