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

Fix resolution of Dockerfile relative dockerignore #1607

Merged
merged 1 commit into from
Apr 14, 2021
Merged

Fix resolution of Dockerfile relative dockerignore #1607

merged 1 commit into from
Apr 14, 2021

Conversation

cehoffman
Copy link
Contributor

Fixes #1451

Description

Docker ships with buildkit enabled by default now enabling Dockerfile
specific dockerignore resolution, e.g. Dockerfile.dockerignore.

This functionality was added in #801, but not enabled in integration tests
because the standard docker build did not support this style of ignore.

I'm not sure where to add the integration test because the existing dockerfile
does an adequate job for validating the fix. Also I'm completely open to
changing the name of the new opts value from OriginalDockerfilePath.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes unit tests
  • Adds integration tests if needed.

See the contribution guide for more details.

Reviewer Notes

  • The code flow looks good.
  • Unit tests and or integration tests added.

Release Notes

- kaniko honors .dockerignore files specific to a Dockerfile, e.g.
  Dockerfile.dockerignore

@google-cla google-cla bot added the cla: yes CLA signed by all commit authors label Mar 23, 2021
@@ -223,6 +223,7 @@ func resolveDockerfilePath() error {
return errors.Wrap(err, "getting absolute path for dockerfile")
}
opts.DockerfilePath = abs
opts.OriginalDockerfilePath = abs
Copy link
Member

@tejal29 tejal29 Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a difference between OriginalDockerfilePath and DockerfilePath?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes because the line immediately following in copyDockerFile

opts.DockerfilePath = constants.DockerfilePath

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @cehoffman for the delayed response. The L257 code makes sure, we fall back to Dockerfile if the file passed in command line arg --dockerfile does not exist.

If we fallback to Dockerfile then the dockerfile ignore should also be Dockerfile.dockerignore right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L257 I believe is to make the Dockerfile used for build always ends up at /kaniko/Dockerfile. I see now I didn’t modify the the context local Dockerfile lookup on L235

I think perhaps the right solution is to extend copyDockerfile() to detect a relative dockerignore and copy it to /kaniko/Dockerfile.dockerignore. That would then let the existing lookup resolve and not require the OriginalDockerfilePath struct item.

@tejal29 tejal29 merged commit ac1fc88 into GoogleContainerTools:master Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes CLA signed by all commit authors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dockerfile.dockerignore not working
2 participants