Skip to content

Latest commit

 

History

History
110 lines (85 loc) · 4.92 KB

README.adoc

File metadata and controls

110 lines (85 loc) · 4.92 KB

Maven Wagon for Image repositories

This Maven Wagon allows you to use your Image repository as a Maven repository. By image repository we roughly follow the Distribution Spec. That being said, we do try to support popular vendors (e.g Docker, Azure, Google, RedHat etc…​) that often put additional constraints on allowed characters in Image repository names (e.g Docker Hub doesn’t allow /). Contributions are welcome!

Use it

The wagon-docker-registry wagon uses the docker:// prefix for repository URLs and works similarly to other Maven wagons. For example, to use Docker Hub as a Maven repository:

<!-- settings.xml example -->
<server>
  <id>docker-hub</id>
  <username>jpoth</username>
  <password>XXXXXX</password>
</server>

<repository>
  <id>docker-hub</id>
  <name>Docker Hub Repository</name>
  <url>docker://docker.io/jpoth</url>
</repository>
<!-- pom.xml example -->
<distributionManagement>
  <snapshotRepository>
    <id>docker-hub</id>
    <url>docker://docker.io/jpoth</url>
  </snapshotRepository>
  <repository>
    <id>docker-hub</id>
    <url>docker://docker.io/jpoth</url>
  </repository>
</distributionManagement>

<build>
  <extensions>
    <extension>
        <groupId>com.github.johnpoth</groupId>
        <artifactId>wagon-docker-registry</artifactId>
        <version>0.2.0</version>
    </extension>
  </extensions>
</build>

Now you can deploy/pull your Maven artifacts to/from Docker Hub. Enjoy !

Image Format

This Maven wagon will upload your artifact as an OCI or Docker (by default) compliant Image with a single Layer (or Blob) that is simply the TAR of your artifact. The Image repository name will be roughly equal to the HTTP path built by Maven. For example, given the Maven artifact org.apache.ant:ant:jar:1.10.12, it’s HTTP path will be org/apache/ant/ant/1.10.12/ant-1.10.12.jar and it’s the Image repository name will be mapped by default to org_apache_ant_ant_1_10_12_ant-1_10_12_jar and it’s Image tag equal to 1.10.12. Notice that the Image repository name is lower cased, prefixed with maven_, . and / are replaced with _. This is done in order to be compliant with the Spec and restrictions put in place by popular vendors (Amazon, Red Hat, Microsoft, Docker Hub, etc…​). The maven_ prefix was added in order to easily retrieve images uploaded by wagon-docker-registry which makes cleaning things up a bit easier.

Image Repository naming

As mentioned above, the Image repository name will be equal to the HTTP path requested by Maven but lower cased, prefixed with maven_, . and / are replaced with _ by default. The image Tag will be equal to the artifact’s version or latest if none is provided.

Here’s a table illustrating the different ways the Image name can be built:

Strategy Maven artifact Maven HTTP path Image Name Image Tag

Default

org.apache.ant:ant:jar:1.10.12

org/apache/ant/ant/1.10.12/ant-1.10.12.jar

maven_org_apache_ant_ant_1_10_12_ant-1_10_12_jar

1.10.12

None

org.apache.ant:ant:jar:1.10.12

org/apache/ant/ant/1.10.12/ant-1.10.12.jar

org/apache/ant/ant/1.10.12/ant-1.10.12.jar

1.10.12

SHA256

org.apache.ant:ant:jar:1.10.12

org/apache/ant/ant/1.10.12/ant-1.10.12.jar

fa7a092905691cbd66d18bc9be3eb7b87bd2cdde5a2499d348a5dfe43362b27a

1.10.12

The SHA256 strategy is only recommend as a last resort because users won’t be able to know whats in the Image just by looking at it’s name.

If the above isn’t enough, a map can be configured to store mappings that will be used to construct the Image Repository names.

The strategy and custom mapping can be set using the imageNamingStrategy and imageNamingMap configuration property respectively:

<!-- settings.xml example -->
<server>
  <id>docker-hub</id>
  <username>jpoth</username>
  <password>XXXXXX</password>
  <configuration>
    <imageNamingMap>
      <key1>value1</key1>
      <key2>value2</key2>
    </imageNamingMap>
    <imageNamingStrategy>None</imageNamingStrategy>
  </configuration>
</server>

Here’s a full list of available options:

Name Type Default Description

timeout

Integer

20000

HTTP timeout

allowInsecureRegistries

Boolean

true

Allow HTTP

sendAuthorizationOverHttp

Boolean

true

Allow sending auth over HTTP connections

imageFormat

Enum (Docker,OCI)

Docker

Image format

imageNamingStrategy

Enum (Default,None, SHA256)

Default

Image repository naming strategy

imageNamingMap

Map

Empty

Map that will be looked up for Image names

Credits

The wagon uses the awesome Jib library to build and push the Image TAR.