{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/85172475","pull_request_review_id":5903181,"id":85172475,"diff_hunk":"@@ -43,6 +43,22 @@ func (rl *roLayer) TarStream() (io.ReadCloser, error) {\n \treturn rc, nil\n }\n \n+func (rl *roLayer) TarStreamFrom(parent ChainID) (io.ReadCloser, error) {","path":"layer/ro_layer.go","position":4,"original_position":4,"commit_id":"bec82a1bf5c4103c4f77181acf03e207fba644fb","original_commit_id":"a45e88c8a7350904de84b15d8d3b12cc54494149","user":{"login":"dmcgowan","id":169601,"avatar_url":"https://avatars.githubusercontent.com/u/169601?v=3","gravatar_id":"","url":"https://api.github.com/users/dmcgowan","html_url":"https://github.com/dmcgowan","followers_url":"https://api.github.com/users/dmcgowan/followers","following_url":"https://api.github.com/users/dmcgowan/following{/other_user}","gists_url":"https://api.github.com/users/dmcgowan/gists{/gist_id}","starred_url":"https://api.github.com/users/dmcgowan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmcgowan/subscriptions","organizations_url":"https://api.github.com/users/dmcgowan/orgs","repos_url":"https://api.github.com/users/dmcgowan/repos","events_url":"https://api.github.com/users/dmcgowan/events{/privacy}","received_events_url":"https://api.github.com/users/dmcgowan/received_events","type":"User","site_admin":false},"body":"`TarStream` on `roLayer` must guarantee that the returned tar stream matches exactly what was given on register. Since this tar stream was never registered we cannot make that guarantee nor is it important. We should document these guarantees for `roLayer` so it is not attempted to be used for a push, but this looks correct to me.","created_at":"2016-10-26T17:10:15Z","updated_at":"2016-10-26T17:10:15Z","html_url":"https://github.com/docker/docker/pull/22641#discussion_r85172475","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/22641","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/85172475"},"html":{"href":"https://github.com/docker/docker/pull/22641#discussion_r85172475"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/22641"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/22641","id":69572628,"html_url":"https://github.com/docker/docker/pull/22641","diff_url":"https://github.com/docker/docker/pull/22641.diff","patch_url":"https://github.com/docker/docker/pull/22641.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/22641","number":22641,"state":"open","locked":false,"title":"Adds ability to flatten image after build","user":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"body":"<!--\r\nPlease make sure you've read and understood our contributing guidelines;\r\nhttps://github.com/docker/docker/blob/master/CONTRIBUTING.md\r\n\r\n** Make sure all your commits include a signature generated with `git commit -s` **\r\n\r\nFor additional information on our contributing process, read our contributing\r\nguide https://docs.docker.com/opensource/code/\r\n\r\nIf this is a bug fix, make sure your description includes \"fixes #xxxx\", or\r\n\"closes #xxxx\"\r\n\r\nPlease provide the following information:\r\n-->\r\n\r\n**- What I did**\r\nAllow built images to be flattened to their parent (or to `scratch`).\r\nFlattening does not destroy any images or layers, and preserves the build cache.\r\n\r\n**- How I did it**\r\nIntroduce a new CLI argument `--flatten` to `docker build` which accepts either `full` or `parent` as an option.\r\nIntroduce a new param to the build API endpoint `flatten` which accepts these same values.\r\n\r\nOnce the build is complete, docker creates a new image loading the diffs from each layer into a single new layer and references all the parent's layers. In the case of `--flatten=parent` the parent is the Dockerfile's `FROM` image, for `full` the parent is scratch.\r\n\r\n**- How to verify it**\r\n```Dockerfile\r\nFROM busybox\r\nRUN echo hello > /hello\r\nRUN echo world >> /hello\r\nRUN touch remove_me /remove_me\r\nENV HELLO world\r\nRUN rm /remove_me\r\n```\r\n\r\n```\r\n$ docker build -t test --flatten=parent .\r\n...\r\n$ docker history test\r\nIMAGE               CREATED             CREATED BY                                      SIZE                COMMENT\r\n4e10cb5b4cac        3 seconds ago                                                       12 B                merge sha256:88a7b0112a41826885df0e7072698006ee8f621c6ab99fca7fe9151d7b599702 to sha256:47bcc53f74dc94b1920f0b34f6036096526296767650f223433fe65c35f149eb\r\n<missing>           5 minutes ago       /bin/sh -c rm /remove_me                        0 B\r\n<missing>           5 minutes ago       /bin/sh -c #(nop) ENV HELLO=world               0 B\r\n<missing>           5 minutes ago       /bin/sh -c touch remove_me /remove_me           0 B\r\n<missing>           5 minutes ago       /bin/sh -c echo world >> /hello                 0 B\r\n<missing>           6 minutes ago       /bin/sh -c echo hello > /hello                  0 B\r\n<missing>           7 weeks ago         /bin/sh -c #(nop) CMD [\"sh\"]                    0 B\r\n<missing>           7 weeks ago         /bin/sh -c #(nop) ADD file:47ca6e777c36a4cfff   1.113 MB\r\n```\r\n\r\n```\r\n$ docker build -t test --flatten=full .\r\n...\r\n$ docker history test\r\nIMAGE               CREATED             CREATED BY                                      SIZE                COMMENT\r\n6cdd246e9b62        2 seconds ago                                                       1.113 MB            create new from sha256:e955163396e76d1168f3450c626d664bea95ef00b7746140998d3d333c0fd0bc\r\n<missing>           24 seconds ago      /bin/sh -c rm /remove_me                        0 B\r\n<missing>           25 seconds ago      /bin/sh -c #(nop) ENV HELLO=world               0 B\r\n<missing>           26 seconds ago      /bin/sh -c touch remove_me /remove_me           0 B\r\n<missing>           27 seconds ago      /bin/sh -c echo world >> /hello                 0 B\r\n<missing>           28 seconds ago      /bin/sh -c echo hello > /hello                  0 B\r\n<missing>           7 weeks ago         /bin/sh -c #(nop) CMD [\"sh\"]                    0 B\r\n<missing>           7 weeks ago         /bin/sh -c #(nop) ADD file:47ca6e777c36a4cfff   0 B\r\n```\r\n\r\nTest the image, check for `/remove_me` being gone, make sure `hello\\nworld` is in `/hello`, make sure the `HELLO` envvar's value is `world`\r\n\r\n**- Description for the changelog**\r\n<!--\r\nWrite a short (one line) summary that describes the changes in this\r\npull request for inclusion in the changelog:\r\n-->\r\nAdd option to flatten image layers after successful builds\r\n\r\n**- A picture of a cute animal (not mandatory but encouraged)**\r\n![](http://www.southernsavers.com/wp-content/uploads/2012/03/build-a-bear-coupon.jpg)\r\n\r\n\r\nSome of the implementation is a little rough around the edges but wanted to get this out there.\r\nI also really wanted to make sure that when using the `full` option the user is prompted to make sure they know what it's really doing.","created_at":"2016-05-10T20:31:04Z","updated_at":"2016-10-26T17:11:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d71810d5ba43d577084daf310c310fd3751c7245","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/docker/docker/milestones/56","html_url":"https://github.com/docker/docker/milestones/1.13.0","labels_url":"https://api.github.com/repos/docker/docker/milestones/56/labels","id":1839404,"number":56,"title":"1.13.0","description":"","creator":{"login":"thaJeztah","id":1804568,"avatar_url":"https://avatars.githubusercontent.com/u/1804568?v=3","gravatar_id":"","url":"https://api.github.com/users/thaJeztah","html_url":"https://github.com/thaJeztah","followers_url":"https://api.github.com/users/thaJeztah/followers","following_url":"https://api.github.com/users/thaJeztah/following{/other_user}","gists_url":"https://api.github.com/users/thaJeztah/gists{/gist_id}","starred_url":"https://api.github.com/users/thaJeztah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaJeztah/subscriptions","organizations_url":"https://api.github.com/users/thaJeztah/orgs","repos_url":"https://api.github.com/users/thaJeztah/repos","events_url":"https://api.github.com/users/thaJeztah/events{/privacy}","received_events_url":"https://api.github.com/users/thaJeztah/received_events","type":"User","site_admin":false},"open_issues":109,"closed_issues":465,"state":"open","created_at":"2016-06-20T22:51:25Z","updated_at":"2016-10-26T16:12:53Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/docker/docker/pulls/22641/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/22641/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/22641/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/bec82a1bf5c4103c4f77181acf03e207fba644fb","head":{"label":"cpuguy83:build_finalization","ref":"build_finalization","sha":"bec82a1bf5c4103c4f77181acf03e207fba644fb","user":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"repo":{"id":15300899,"name":"docker","full_name":"cpuguy83/docker","owner":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cpuguy83/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/cpuguy83/docker","forks_url":"https://api.github.com/repos/cpuguy83/docker/forks","keys_url":"https://api.github.com/repos/cpuguy83/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cpuguy83/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cpuguy83/docker/teams","hooks_url":"https://api.github.com/repos/cpuguy83/docker/hooks","issue_events_url":"https://api.github.com/repos/cpuguy83/docker/issues/events{/number}","events_url":"https://api.github.com/repos/cpuguy83/docker/events","assignees_url":"https://api.github.com/repos/cpuguy83/docker/assignees{/user}","branches_url":"https://api.github.com/repos/cpuguy83/docker/branches{/branch}","tags_url":"https://api.github.com/repos/cpuguy83/docker/tags","blobs_url":"https://api.github.com/repos/cpuguy83/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cpuguy83/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cpuguy83/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/cpuguy83/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cpuguy83/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/cpuguy83/docker/languages","stargazers_url":"https://api.github.com/repos/cpuguy83/docker/stargazers","contributors_url":"https://api.github.com/repos/cpuguy83/docker/contributors","subscribers_url":"https://api.github.com/repos/cpuguy83/docker/subscribers","subscription_url":"https://api.github.com/repos/cpuguy83/docker/subscription","commits_url":"https://api.github.com/repos/cpuguy83/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/cpuguy83/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/cpuguy83/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/cpuguy83/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/cpuguy83/docker/contents/{+path}","compare_url":"https://api.github.com/repos/cpuguy83/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cpuguy83/docker/merges","archive_url":"https://api.github.com/repos/cpuguy83/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cpuguy83/docker/downloads","issues_url":"https://api.github.com/repos/cpuguy83/docker/issues{/number}","pulls_url":"https://api.github.com/repos/cpuguy83/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/cpuguy83/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/cpuguy83/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cpuguy83/docker/labels{/name}","releases_url":"https://api.github.com/repos/cpuguy83/docker/releases{/id}","deployments_url":"https://api.github.com/repos/cpuguy83/docker/deployments","created_at":"2013-12-19T02:58:40Z","updated_at":"2015-04-27T13:11:12Z","pushed_at":"2016-10-26T16:40:53Z","git_url":"git://github.com/cpuguy83/docker.git","ssh_url":"git@github.com:cpuguy83/docker.git","clone_url":"https://github.com/cpuguy83/docker.git","svn_url":"https://github.com/cpuguy83/docker","homepage":"http://www.docker.io","size":107542,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"2a2f183627af25fb6f1c93c5fc2c4d04ab7e75bb","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","deployments_url":"https://api.github.com/repos/docker/docker/deployments","created_at":"2013-01-18T18:10:57Z","updated_at":"2016-10-26T16:40:01Z","pushed_at":"2016-10-26T17:08:06Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":215824,"stargazers_count":36300,"watchers_count":36300,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10717,"mirror_url":null,"open_issues_count":1936,"forks":10717,"open_issues":1936,"watchers":36300,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/22641"},"html":{"href":"https://github.com/docker/docker/pull/22641"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/22641"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/22641/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/22641/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/22641/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/bec82a1bf5c4103c4f77181acf03e207fba644fb"}}}}
{"actor":{"display_login":"dmcgowan"}}