Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any plan to support the new ARG command #334

Closed
djsly opened this issue Nov 18, 2015 · 6 comments
Closed

Any plan to support the new ARG command #334

djsly opened this issue Nov 18, 2015 · 6 comments
Milestone

Comments

@djsly
Copy link

djsly commented Nov 18, 2015

It would be great if we could provide the maven variables as Docker file build variables.
http://docs.docker.com/engine/reference/builder/#arg

@jgangemi
Copy link
Collaborator

if you define the container configuration via the plugin xml, this can already be accomplished. you can also already use maven properties inside a Dockerfile that you have specified as part of the build, but this is very non-portable.

past that, i believe supporting this would require us to parse the Dockerfile to look for these values and re-create a new Dockerfile with everything substituted.

actually...now that i think about this, you could probably accomplish this now provided you were always overriding the value on the command line.

ARG foo=${some.maven.property}

in the above case, the plugin would automatically substitute in the property value and docker would just think a default value was specified and use that. this doesn't work, though, if you wanted to have an actual default value there and only substitute it sometimes.

@djsly
Copy link
Author

djsly commented Nov 18, 2015

Our current use case would be around a dockerfile that we manage externally. (not using the auto generated dockerfile feature)

docker build 1.9 provides you with a new docker build flag pass ARG.

so I would see that a new xml attribute could be create

<docker-build-args>
     <docker-build-arg>my_arg=${maven.releaseVersion}</docker-build-arg>
<docker-build-args>

which would translate to the equivalent docker remote API call for

--build-arg my_arg=${maven.releaseVersion}

edit:

from the v1.21 API

POST /build now optionally takes a serialized map of build-time variables.
buildargs – JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for command(s) run via the Dockerfile’s RUN instruction or for variable expansion in other Dockerfile instructions. This is not meant for passing secret values. Read more about the buildargs instruction

@jgangemi
Copy link
Collaborator

hrm - i didn't see that in the api documentation when i looked the first time.

yeah - something like that should definitely be possible then.

@rhuss
Copy link
Collaborator

rhuss commented Nov 30, 2015

We will consider to support this when we increase the support for external Dockerfiles. Currently these external Dockerfile don't have Maven property substitution (but this is planned for #205)

Luckily we postponed this a bit, because we probably would have chosen the same expression syntax as Docker 1.9 for ARG interpolation (namely ${...}) ;-). So we need sth different for Maven properties if we want to support this as an extension, too. Alternatively we could omit Maven property substitution completely and only use Dockerfile expressions (and feeding in the build-args when building the image).

Docker 1.9 support is planned for 0.14 so it might take a bit, though.

@rhuss rhuss added this to the 0.14.0 milestone Nov 30, 2015
@jgangemi
Copy link
Collaborator

jgangemi commented Dec 1, 2015

my thought here is while we should be accommodating, we shouldn't bend over backwards to support this and the onus should be on the user to do the right thing.

resource filtering in maven is only enabled if you explicitly turn it on, so if someone wants to use the build-args support, they can't run their Dockerfile through maven's resource filtering or they need to use unique property names that won't be known to maven.

they can still turn have a Dockerfile template, we would just recommend they take one approach or the other.

@rhuss rhuss modified the milestones: 0.14.1, 0.14.0 Feb 24, 2016
@rhuss
Copy link
Collaborator

rhuss commented Mar 22, 2016

FYU, my thoughts on the ARG support can be found in #409

@rhuss rhuss modified the milestones: 0.14.1, 0.15.0 Mar 23, 2016
rhuss added a commit that referenced this issue Apr 4, 2016
This is based on the work done in #409 (thanks @	balazsmaria !) and allows the usage of ARG in external Dockerfiles.
Documentation and external property config hanlder has been updated, too.
@rhuss rhuss closed this as completed Apr 27, 2016
leusonmario pushed a commit to leusonmario/docker-maven-plugin that referenced this issue Aug 18, 2018
* update docker client to latest (8.4.0)

* checkstyle

* bump docker client to 8.5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants