dockerfile-rails
dockerfile-rails copied to clipboard
Allow args without a value
This is a WIP. I'd appreciate some help with it, as well as confirmation it's worth doing.
In a Dockerfile, the ENV
keyword requires a name and value. But ARG
just requires a name; a default value is optional. There's some examples here, and another one here which is what led me to this.
So this PR allows you to provide args without a default value.
I can't get the tests to run at the moment.
Error:
TestArg#test_env:
Errno::ENOENT: No such file or directory @ rb_sysopen - Dockerfile
/Users/alex/Code/dockerfile-rails/test/base.rb:43:in `read'
/Users/alex/Code/dockerfile-rails/test/base.rb:43:in `check_dockerfile'
test/test_arg.rb:10:in `test_env'
Can come back to this another time, posting here in case anyone has any tips...
I approved running of the tests, so you can see the results.
Note that test/base.rb replaces arg values in the actual and expected results with xxx
so that (for example) you can run the tests with a different node version and have the tests pass.
Given that any option you specify is saved to dockerfile.yml and included by default in subsequent runs, I'd like for there to be some way to remove an ARG that you previously specified without requiring manual edit of the dockerfile.yml file itself.
Given that any option you specify is saved to dockerfile.yml and included by default in subsequent runs, I'd like for there to be some way to remove an ARG that you previously specified without requiring manual edit of the dockerfile.yml file itself.
(Just as a side note, from the start I've found this a slightly odd design decision. If I'm removing something from the existing config or changing it, I go edit the config file and treat bin/rails g dockerfile
as the command to regenerate it rather than driving it from the CLI. Appreciate that's probably not up for debate now though 😀)
That said, I wonder if we could use the somewhat common practice of prepending no-
to flags to remove things. So running --no-arg=IMPORTANT:value
would delete the ARG IMPORTANT="value"
from the Dockerfile, and running --arg=IMPORTANT
would add ARG IMPORTANT
to the Dockerfile?
Means there's a clear distinction between "I want to remove this arg entirely" and "I want this arg required without a value set".
So running --no-arg=IMPORTANT:value would delete the ARG IMPORTANT="value"
Seems reasonable (though I would argue against including :value
in --no-arg
)
So running --no-arg=IMPORTANT:value would delete the ARG IMPORTANT="value"
Seems reasonable (though I would argue against including
:value
in--no-arg
)
Ugh, knew I’d missed something obvious. Agreed, just --no-arg=IMPORTANT
.