-
Notifications
You must be signed in to change notification settings - Fork 53
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
ARG's are not inherited from a parent stage - only the last stage is considered #116
Comments
You have typo in Dockerfile FROM python
- ARG GLOABLARG2
+ ARG GLOBALARG2
RUN echo $GLOBALARG2 It prints correct
dockerfile-parse intentionally returns only values related to the latest stage |
Also from docs https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
Global ARGs are not available in the stage if there is no empty ARG declaration within stage. IMO dockerfile-parse works as expected |
Whilst it may be working as intended, we have a legitimate use-case for wanting to set values outside of the last block. Would you accept a PR that keeps the current behaviour, but allows the user to override it with a kwarg? |
Can you describe it more? What do you mean by override? |
Sure. We have something akin to the following ARG NAME=somevalue
ARG ANOTHER="another value"
FROM alpine
ARG NAME
ARG ANOTHER
RUN ..
FROM scratch
ARG NAME
dockerfile-parse/dockerfile_parse/parser.py Line 628 in 169a7ff
|
Oh, so you want to be able to modify ARG global definitions before the first FROM? That sounds good to me |
I got broader agreement that this is a good idea, so I have opened 2 issues for that: Contributions are welcome |
When using global ARG's outside of a FROM line (for instance, to make them available to multiple stages), only the last stage is used to generate the arguments property.
For example, this Dockerfile:
With this sample script:
returns
{'GLOABLARG2': ''}
, despite the fact that GLOBALARG2 should have inherited from the parent, and its entirely missing GLOBALARG1.The library successfully detects this is a multistage build, but I can't seem to find a way to present the global arguments, or any arguments from a stage other than the last - as well as arguments not being inherited correctly
The text was updated successfully, but these errors were encountered: