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

build: history should not contain ARG values. OTOH RUN history should contain final values. #3609

Merged
merged 1 commit into from
Nov 3, 2021

Conversation

flouthoc
Copy link
Collaborator

@flouthoc flouthoc commented Nov 1, 2021

It seems docker never writes ARG values to build history and only writes
values with RUN statements. As a result it can utilize caching better if
assgnment of an ARG value is never used.

Instance

FROM alpine
ARG FOO
ENV FOO=bat
RUN echo $FOO

In above example --build-arg FOO=value has no significance as value
is always overriden by ENV.

Following PR makes sure buildah mimics a similar behaviour.

Closes: #1936

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 1, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Nov 1, 2021

LGTM
@nalind PTAL

@TomSweeneyRedHat
Copy link
Member

@flouthoc all kinds of red test unhappiness. I didn't dig, but I'm guessing we've some checks on the args showing values somewhere in the test. Changes look generally good, but definitely want @nalind to take a look.

It seems docker never writes ARG values to build history and only writes
values with RUN statements. As a result it can utilize caching better if
assgnment of an ARG value is never used.

Instance
```Dockerfile
FROM alpine
ARG FOO
ENV FOO=bat
RUN echo $FOO
```

In above example --build-arg FOO=value has no significance as value
is always overriden by ENV.

Following PR makes sure buildah mimics a similar behaviour.

Signed-off-by: Aditya Rajan <[email protected]>
@flouthoc
Copy link
Collaborator Author

flouthoc commented Nov 2, 2021

@TomSweeneyRedHat since history does not contains ARG values so we will utilize caching better. Hence older tests were had to be adjusted to expect one less layer. @nalind PTAL.

@TomSweeneyRedHat
Copy link
Member

LGTM
@nalind?

@rhatdan
Copy link
Member

rhatdan commented Nov 3, 2021

/lgtm

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build cache is not reused when overriding ARG with ENV in Dockerfile
4 participants