Dockerfile-maven: Support for custom build args

Created on 8 Jun 2017  路  4Comments  路  Source: spotify/dockerfile-maven

The current plug-in doesn't seem to provide a capability to provide custom build args into the build image task.

I have a scenario where a version parameter is passed into my dockerfile via a buildarg.

As the docker-client already supports passing in a buildparam list (that's how nocache, etc. works) is this something that would be logical to add to the plug-in?

Would a PR supporting this be accepted?

Most helpful comment

+1 I also need this feature, which is present in the older docker-maven-plugin

To facilitate migration from docker-maven-plugin, it would be nice to support the same configuration format, ie :

<configuration>
    <buildArgs>
        <APT_MIRROR>http://my.org/ubuntu</APT_MIRROR>
    </buildArgs>
</configuration>

@joshdcollins : Do yo plan to submit a PR soon ? Would you like some help ?

All 4 comments

Perhaps I spoke too quickly about assuming docker-client would support this without change. I made the following local changes:

Add a new configuration parameter:
@Parameter(property = "dockerfile.customBuildArgs") private Properties customBuildArgs;

Use configuration value to create buildArgs (within buildImage):
if (customBuildArgs != null && !customBuildArgs.isEmpty()) { Enumeration<?> buildArgEnum = customBuildArgs.propertyNames(); while (buildArgEnum.hasMoreElements()) { String name = (String) buildArgEnum.nextElement(); buildParameters.add(new DockerClient.BuildParam(name, customBuildArgs.getProperty(name))); } }

Then within my pom file I've tried two approaches:
<customBuildArgs> <property> <name>build-arg</name> <value>buildversion=${project.version}</value> </property> </customBuildArgs>

and

<customBuildArgs> <property> <name>buildversion</name> <value>${project.version}</value> </property> </customBuildArgs>

Confirmed through logs that the parameter is properly read and added to the buildArg collection, but am unable to determine what, if anything, docker-client is doing with them.

+1 I also need this feature, which is present in the older docker-maven-plugin

To facilitate migration from docker-maven-plugin, it would be nice to support the same configuration format, ie :

<configuration>
    <buildArgs>
        <APT_MIRROR>http://my.org/ubuntu</APT_MIRROR>
    </buildArgs>
</configuration>

@joshdcollins : Do yo plan to submit a PR soon ? Would you like some help ?

I need this!

This was added in #41

Was this page helpful?
0 / 5 - 0 ratings