{"action":"opened","number":3,"pull_request":{"url":"https://api.github.com/repos/voxmedia/docker_base_images/pulls/3","id":135872520,"html_url":"https://github.com/voxmedia/docker_base_images/pull/3","diff_url":"https://github.com/voxmedia/docker_base_images/pull/3.diff","patch_url":"https://github.com/voxmedia/docker_base_images/pull/3.patch","issue_url":"https://api.github.com/repos/voxmedia/docker_base_images/issues/3","number":3,"state":"open","locked":false,"title":"Exec as host user","user":{"login":"thenonsequitur","id":17254,"avatar_url":"https://avatars2.githubusercontent.com/u/17254?v=4","gravatar_id":"","url":"https://api.github.com/users/thenonsequitur","html_url":"https://github.com/thenonsequitur","followers_url":"https://api.github.com/users/thenonsequitur/followers","following_url":"https://api.github.com/users/thenonsequitur/following{/other_user}","gists_url":"https://api.github.com/users/thenonsequitur/gists{/gist_id}","starred_url":"https://api.github.com/users/thenonsequitur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thenonsequitur/subscriptions","organizations_url":"https://api.github.com/users/thenonsequitur/orgs","repos_url":"https://api.github.com/users/thenonsequitur/repos","events_url":"https://api.github.com/users/thenonsequitur/events{/privacy}","received_events_url":"https://api.github.com/users/thenonsequitur/received_events","type":"User","site_admin":false},"body":"## Purpose\r\n\r\nOn Linux, when a container writes a file to a mounted volume, the file is written with the same uid/gid as the user inside the container. Since we were previously running the app as `root`, this meant that files generated by the app were also owned by `root` on the host machine. This PR works around this problem.\r\n\r\nThere is a new entrypoint script in the rails base image to execute the docker command as a non-root user with the same uid and gid as the host user.  Then when the user inside the container writes files, they will end up on the host system owned by the host.\r\n\r\nNote that this happens automatically for OSX, but it's important to have a Linux solution too.\r\n\r\n## Notable changes\r\n\r\nThere is actually no good automatic way to pass the host UID and GID to the container. Docker compose can pass environment variables, but this would require an extra step of setting the env vars before being able to run the container. The ability for docker-compose to determine the host UID/GID is a much-desired feature and there are several open issues/questions requesting such a method (partial list of examples: [1](https://github.com/docker/compose/issues/1532) [2](https://github.com/docker/compose/issues/4725) [3](https://github.com/moby/moby/issues/21259) [4](https://stackoverflow.com/questions/44026949/dynamically-pick-the-user-gui-and-uid-whos-running-docker-at-the-host-from-entr)), but these issues have gone unaddressed. So this PR works around by using a hack:\r\n\r\n    HOST_UID=$(stat -c %u docker-compose.yml)\r\n    HOST_GID=$(stat -c %g docker-compose.yml)\r\n\r\nThis extracts the UID/GID from a file (docker-compose.yml) that is known to live in a mounted volume in all apps that will use this base image. This works for now, but hopefully docker-compose will eventually address this issue, at which point there would be a less hacky way to do this.\r\n\r\n## Tangential change\r\n\r\nIn passing, this also adds `ENV PATH /app/bin:$PATH`. This allows unqualified access to the binsubs in the app dir, obviating the need for \"bundle exec\" on most common commands.\r\n\r\n## Launch plan\r\n\r\nAfter merging this in, build and tag a new `rails-0.2` base image. Then update all apps using the `rails-0.1` image to this new image, and apply the new functionality.\r\n","created_at":"2017-08-15T19:25:35Z","updated_at":"2017-08-15T19:25:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/voxmedia/docker_base_images/pulls/3/commits","review_comments_url":"https://api.github.com/repos/voxmedia/docker_base_images/pulls/3/comments","review_comment_url":"https://api.github.com/repos/voxmedia/docker_base_images/pulls/comments{/number}","comments_url":"https://api.github.com/repos/voxmedia/docker_base_images/issues/3/comments","statuses_url":"https://api.github.com/repos/voxmedia/docker_base_images/statuses/c334fc6e85b127f1ba78c666cf1e5b4609e36866","head":{"label":"voxmedia:systems-exec-as-host-user","ref":"systems-exec-as-host-user","sha":"c334fc6e85b127f1ba78c666cf1e5b4609e36866","user":{"login":"voxmedia","id":316807,"avatar_url":"https://avatars3.githubusercontent.com/u/316807?v=4","gravatar_id":"","url":"https://api.github.com/users/voxmedia","html_url":"https://github.com/voxmedia","followers_url":"https://api.github.com/users/voxmedia/followers","following_url":"https://api.github.com/users/voxmedia/following{/other_user}","gists_url":"https://api.github.com/users/voxmedia/gists{/gist_id}","starred_url":"https://api.github.com/users/voxmedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voxmedia/subscriptions","organizations_url":"https://api.github.com/users/voxmedia/orgs","repos_url":"https://api.github.com/users/voxmedia/repos","events_url":"https://api.github.com/users/voxmedia/events{/privacy}","received_events_url":"https://api.github.com/users/voxmedia/received_events","type":"Organization","site_admin":false},"repo":{"id":56696835,"name":"docker_base_images","full_name":"voxmedia/docker_base_images","owner":{"login":"voxmedia","id":316807,"avatar_url":"https://avatars3.githubusercontent.com/u/316807?v=4","gravatar_id":"","url":"https://api.github.com/users/voxmedia","html_url":"https://github.com/voxmedia","followers_url":"https://api.github.com/users/voxmedia/followers","following_url":"https://api.github.com/users/voxmedia/following{/other_user}","gists_url":"https://api.github.com/users/voxmedia/gists{/gist_id}","starred_url":"https://api.github.com/users/voxmedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voxmedia/subscriptions","organizations_url":"https://api.github.com/users/voxmedia/orgs","repos_url":"https://api.github.com/users/voxmedia/repos","events_url":"https://api.github.com/users/voxmedia/events{/privacy}","received_events_url":"https://api.github.com/users/voxmedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/voxmedia/docker_base_images","description":null,"fork":false,"url":"https://api.github.com/repos/voxmedia/docker_base_images","forks_url":"https://api.github.com/repos/voxmedia/docker_base_images/forks","keys_url":"https://api.github.com/repos/voxmedia/docker_base_images/keys{/key_id}","collaborators_url":"https://api.github.com/repos/voxmedia/docker_base_images/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/voxmedia/docker_base_images/teams","hooks_url":"https://api.github.com/repos/voxmedia/docker_base_images/hooks","issue_events_url":"https://api.github.com/repos/voxmedia/docker_base_images/issues/events{/number}","events_url":"https://api.github.com/repos/voxmedia/docker_base_images/events","assignees_url":"https://api.github.com/repos/voxmedia/docker_base_images/assignees{/user}","branches_url":"https://api.github.com/repos/voxmedia/docker_base_images/branches{/branch}","tags_url":"https://api.github.com/repos/voxmedia/docker_base_images/tags","blobs_url":"https://api.github.com/repos/voxmedia/docker_base_images/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/voxmedia/docker_base_images/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/voxmedia/docker_base_images/git/refs{/sha}","trees_url":"https://api.github.com/repos/voxmedia/docker_base_images/git/trees{/sha}","statuses_url":"https://api.github.com/repos/voxmedia/docker_base_images/statuses/{sha}","languages_url":"https://api.github.com/repos/voxmedia/docker_base_images/languages","stargazers_url":"https://api.github.com/repos/voxmedia/docker_base_images/stargazers","contributors_url":"https://api.github.com/repos/voxmedia/docker_base_images/contributors","subscribers_url":"https://api.github.com/repos/voxmedia/docker_base_images/subscribers","subscription_url":"https://api.github.com/repos/voxmedia/docker_base_images/subscription","commits_url":"https://api.github.com/repos/voxmedia/docker_base_images/commits{/sha}","git_commits_url":"https://api.github.com/repos/voxmedia/docker_base_images/git/commits{/sha}","comments_url":"https://api.github.com/repos/voxmedia/docker_base_images/comments{/number}","issue_comment_url":"https://api.github.com/repos/voxmedia/docker_base_images/issues/comments{/number}","contents_url":"https://api.github.com/repos/voxmedia/docker_base_images/contents/{+path}","compare_url":"https://api.github.com/repos/voxmedia/docker_base_images/compare/{base}...{head}","merges_url":"https://api.github.com/repos/voxmedia/docker_base_images/merges","archive_url":"https://api.github.com/repos/voxmedia/docker_base_images/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/voxmedia/docker_base_images/downloads","issues_url":"https://api.github.com/repos/voxmedia/docker_base_images/issues{/number}","pulls_url":"https://api.github.com/repos/voxmedia/docker_base_images/pulls{/number}","milestones_url":"https://api.github.com/repos/voxmedia/docker_base_images/milestones{/number}","notifications_url":"https://api.github.com/repos/voxmedia/docker_base_images/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/voxmedia/docker_base_images/labels{/name}","releases_url":"https://api.github.com/repos/voxmedia/docker_base_images/releases{/id}","deployments_url":"https://api.github.com/repos/voxmedia/docker_base_images/deployments","created_at":"2016-04-20T15:03:13Z","updated_at":"2017-03-30T21:36:30Z","pushed_at":"2017-08-15T19:23:16Z","git_url":"git://github.com/voxmedia/docker_base_images.git","ssh_url":"git@github.com:voxmedia/docker_base_images.git","clone_url":"https://github.com/voxmedia/docker_base_images.git","svn_url":"https://github.com/voxmedia/docker_base_images","homepage":"https://hub.docker.com/r/voxmedia/docker_base_images/builds/","size":12,"stargazers_count":1,"watchers_count":1,"language":"Shell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"voxmedia:master","ref":"master","sha":"6940b9a5d49628a83b64c2aa334a7f1670b01472","user":{"login":"voxmedia","id":316807,"avatar_url":"https://avatars3.githubusercontent.com/u/316807?v=4","gravatar_id":"","url":"https://api.github.com/users/voxmedia","html_url":"https://github.com/voxmedia","followers_url":"https://api.github.com/users/voxmedia/followers","following_url":"https://api.github.com/users/voxmedia/following{/other_user}","gists_url":"https://api.github.com/users/voxmedia/gists{/gist_id}","starred_url":"https://api.github.com/users/voxmedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voxmedia/subscriptions","organizations_url":"https://api.github.com/users/voxmedia/orgs","repos_url":"https://api.github.com/users/voxmedia/repos","events_url":"https://api.github.com/users/voxmedia/events{/privacy}","received_events_url":"https://api.github.com/users/voxmedia/received_events","type":"Organization","site_admin":false},"repo":{"id":56696835,"name":"docker_base_images","full_name":"voxmedia/docker_base_images","owner":{"login":"voxmedia","id":316807,"avatar_url":"https://avatars3.githubusercontent.com/u/316807?v=4","gravatar_id":"","url":"https://api.github.com/users/voxmedia","html_url":"https://github.com/voxmedia","followers_url":"https://api.github.com/users/voxmedia/followers","following_url":"https://api.github.com/users/voxmedia/following{/other_user}","gists_url":"https://api.github.com/users/voxmedia/gists{/gist_id}","starred_url":"https://api.github.com/users/voxmedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voxmedia/subscriptions","organizations_url":"https://api.github.com/users/voxmedia/orgs","repos_url":"https://api.github.com/users/voxmedia/repos","events_url":"https://api.github.com/users/voxmedia/events{/privacy}","received_events_url":"https://api.github.com/users/voxmedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/voxmedia/docker_base_images","description":null,"fork":false,"url":"https://api.github.com/repos/voxmedia/docker_base_images","forks_url":"https://api.github.com/repos/voxmedia/docker_base_images/forks","keys_url":"https://api.github.com/repos/voxmedia/docker_base_images/keys{/key_id}","collaborators_url":"https://api.github.com/repos/voxmedia/docker_base_images/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/voxmedia/docker_base_images/teams","hooks_url":"https://api.github.com/repos/voxmedia/docker_base_images/hooks","issue_events_url":"https://api.github.com/repos/voxmedia/docker_base_images/issues/events{/number}","events_url":"https://api.github.com/repos/voxmedia/docker_base_images/events","assignees_url":"https://api.github.com/repos/voxmedia/docker_base_images/assignees{/user}","branches_url":"https://api.github.com/repos/voxmedia/docker_base_images/branches{/branch}","tags_url":"https://api.github.com/repos/voxmedia/docker_base_images/tags","blobs_url":"https://api.github.com/repos/voxmedia/docker_base_images/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/voxmedia/docker_base_images/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/voxmedia/docker_base_images/git/refs{/sha}","trees_url":"https://api.github.com/repos/voxmedia/docker_base_images/git/trees{/sha}","statuses_url":"https://api.github.com/repos/voxmedia/docker_base_images/statuses/{sha}","languages_url":"https://api.github.com/repos/voxmedia/docker_base_images/languages","stargazers_url":"https://api.github.com/repos/voxmedia/docker_base_images/stargazers","contributors_url":"https://api.github.com/repos/voxmedia/docker_base_images/contributors","subscribers_url":"https://api.github.com/repos/voxmedia/docker_base_images/subscribers","subscription_url":"https://api.github.com/repos/voxmedia/docker_base_images/subscription","commits_url":"https://api.github.com/repos/voxmedia/docker_base_images/commits{/sha}","git_commits_url":"https://api.github.com/repos/voxmedia/docker_base_images/git/commits{/sha}","comments_url":"https://api.github.com/repos/voxmedia/docker_base_images/comments{/number}","issue_comment_url":"https://api.github.com/repos/voxmedia/docker_base_images/issues/comments{/number}","contents_url":"https://api.github.com/repos/voxmedia/docker_base_images/contents/{+path}","compare_url":"https://api.github.com/repos/voxmedia/docker_base_images/compare/{base}...{head}","merges_url":"https://api.github.com/repos/voxmedia/docker_base_images/merges","archive_url":"https://api.github.com/repos/voxmedia/docker_base_images/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/voxmedia/docker_base_images/downloads","issues_url":"https://api.github.com/repos/voxmedia/docker_base_images/issues{/number}","pulls_url":"https://api.github.com/repos/voxmedia/docker_base_images/pulls{/number}","milestones_url":"https://api.github.com/repos/voxmedia/docker_base_images/milestones{/number}","notifications_url":"https://api.github.com/repos/voxmedia/docker_base_images/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/voxmedia/docker_base_images/labels{/name}","releases_url":"https://api.github.com/repos/voxmedia/docker_base_images/releases{/id}","deployments_url":"https://api.github.com/repos/voxmedia/docker_base_images/deployments","created_at":"2016-04-20T15:03:13Z","updated_at":"2017-03-30T21:36:30Z","pushed_at":"2017-08-15T19:23:16Z","git_url":"git://github.com/voxmedia/docker_base_images.git","ssh_url":"git@github.com:voxmedia/docker_base_images.git","clone_url":"https://github.com/voxmedia/docker_base_images.git","svn_url":"https://github.com/voxmedia/docker_base_images","homepage":"https://hub.docker.com/r/voxmedia/docker_base_images/builds/","size":12,"stargazers_count":1,"watchers_count":1,"language":"Shell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/voxmedia/docker_base_images/pulls/3"},"html":{"href":"https://github.com/voxmedia/docker_base_images/pull/3"},"issue":{"href":"https://api.github.com/repos/voxmedia/docker_base_images/issues/3"},"comments":{"href":"https://api.github.com/repos/voxmedia/docker_base_images/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/voxmedia/docker_base_images/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/voxmedia/docker_base_images/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/voxmedia/docker_base_images/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/voxmedia/docker_base_images/statuses/c334fc6e85b127f1ba78c666cf1e5b4609e36866"}},"merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":4,"additions":30,"deletions":4,"changed_files":3}}
{"actor":{"display_login":"thenonsequitur"}}