dnephin / dobi

A build automation tool for Docker applications
https://dnephin.github.io/dobi/
Apache License 2.0
309 stars 36 forks source link

Allow build args to be overridden from the command line #151

Open outofcoffee opened 6 years ago

outofcoffee commented 6 years ago

In addition to the static set of args within the dobi file, it would be helpful to allow build args to be overridden from the command line.

One of the scenarios this would support is where a build arg is used within a Dockerfile but is known only at runtime. For example, an arg might form part of the base image name/tag from which the image extends.

dnephin commented 6 years ago

Setting anything on the command line is difficult. dobi was designed so that any parameters are encoded in the config. make works in a similar way. The only way to specify parameters is through environment variables. #91 seems related, I don't have a good solution for that.

There are a couple ways to set dynamic values from the config. By setting an env variable on the command like you can read it using {env.VARIABLENAME} (http://dnephin.github.io/dobi/variables.html).

If the value is only available as output from some command than you can use job:capture (http://dnephin.github.io/dobi/tasks.html#job-tasks) to run the command and capture stdout to a variable, which you can then use with the same {env.VARNAME} syntax.

outofcoffee commented 6 years ago

Thanks @dnephin; I'd missed the capture task. That might do the job, cheers!