Gradle plugin for working with the Docker Registry, targetted specifically toward creating multi-archtecture image manifests.
|
Warning
|
The current implementation is incomplete — the plugin so far supports retrieving simple manifests and metadata from the registry and creating and uploading a multi-architecture manifest. The target registry MUST support the Docker V2 API. The source images, source manifests, and target manifest MUST all be in the same library on that server. |
To use this plugin, include it in your build script.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.xanophis:gradle-multidocker-plugin:X.Y.Z'
}
}And then apply the plugin to projects where you want to use it.
apply plugin: 'com.s390x.gradle.multidocker'You may need to import task classes:
import com.s390x.gradle.multidocker.tasks.*The plugin depends on the configuration of a target registry:
registry {
name = gradle.ext.registryCredentials.name
url = gradle.ext.registryCredentials.url
username = gradle.ext.registryCredentials.username
password = gradle.ext.registryCredentials.password
}The registry name and url will default to the docker registry if not
provided, but the username and password are manditory. Users are advised
not to hardcode username and password into the build file, but rather to
source them from some file that is not included in source code management.
|
Note
|
Registry name is an FQDN, e.g. registry.docker.io. The url,
on the other hand, is used as the root of REST calls and so will usually be
"https:\\${name}\v2\". Defaulting is not yet build into the plugin.
|
Get two already existing images with two different architectures and create a build for them.
def archs = ['amd64','s390x']
def getManifestTasks = archs.collect() { arch ->
project.task(name: "getManifest-#{arch}", type: GetManifest) {
os = 'linux'
architecture = project.name
imageName = "${library}/${dockerImageName}"
tag = "latest-${arch}"
}
}
task putMultidocker(type: PutMultidocker, dependsOn: tasks) {
metadataFiles = getManifestTasks*.getMetadataFile()
imageName = "${library}/${dockerImageName}"
tag = "latest"
}