-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Reset uid/gid to 0 in build context to fix cache busting issues on ADD/COPY in stream mode #549
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
Closed
shouze
wants to merge
5
commits into
docker:master
from
shouze:reset-uid-and-gid-in-stream-mode-build
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package image | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| "github.com/docker/docker/pkg/streamformatter" | ||
| "github.com/gotestyourself/gotestyourself/fs" | ||
| "github.com/moby/buildkit/session" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestAddDirToSession(t *testing.T) { | ||
| dest := fs.NewDir(t, "test-build-session", | ||
| fs.WithFile("Dockerfile", ` | ||
| FROM alpine:3.6 | ||
| COPY foo / | ||
| `), | ||
| fs.WithFile("foo", "some content", fs.AsUser(65534, 65534)), | ||
| ) | ||
| defer dest.Remove() | ||
|
|
||
| contextDir := dest.Path() | ||
| sharedKey, err := getBuildSharedKey(contextDir) | ||
| require.NoError(t, err) | ||
|
|
||
| var s *session.Session | ||
| s, err = session.NewSession(filepath.Base(contextDir), sharedKey) | ||
| require.NoError(t, err) | ||
|
|
||
| syncDone := make(chan error) | ||
| progressOutput := streamformatter.NewProgressOutput(new(bytes.Buffer)) | ||
| err = addDirToSession(s, contextDir, progressOutput, syncDone) | ||
| // Needs some assertions here to ensure we reset uid/gid to 0 for example | ||
| require.NoError(t, err) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 0 additions & 70 deletions
70
vendor/github.com/docker/docker/pkg/chrootarchive/archive.go
This file was deleted.
Oops, something went wrong.
86 changes: 0 additions & 86 deletions
86
vendor/github.com/docker/docker/pkg/chrootarchive/archive_unix.go
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
vendor/github.com/docker/docker/pkg/chrootarchive/archive_windows.go
This file was deleted.
Oops, something went wrong.
108 changes: 0 additions & 108 deletions
108
vendor/github.com/docker/docker/pkg/chrootarchive/chroot_linux.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnephin @tonistiigi ok I guess the best is to mock/fake the session here instead of using the true one. @tonistiigi does it worth that builkit provides a session faker at some point? I can put it in the cli ATM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having the CLI depend on a
type Session interface{...}instead of the struct would be great, then it should be easy for us to fake.A fake as part of the CLI testing code sounds fine to me.