{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible-container/issues/217","repository_url":"https://api.github.com/repos/ansible/ansible-container","labels_url":"https://api.github.com/repos/ansible/ansible-container/issues/217/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-container/issues/217/comments","events_url":"https://api.github.com/repos/ansible/ansible-container/issues/217/events","html_url":"https://github.com/ansible/ansible-container/issues/217","id":175655601,"number":217,"title":"rethink build specification in container.yml","user":{"login":"dustymabe","id":4530030,"avatar_url":"https://avatars.githubusercontent.com/u/4530030?v=3","gravatar_id":"","url":"https://api.github.com/users/dustymabe","html_url":"https://github.com/dustymabe","followers_url":"https://api.github.com/users/dustymabe/followers","following_url":"https://api.github.com/users/dustymabe/following{/other_user}","gists_url":"https://api.github.com/users/dustymabe/gists{/gist_id}","starred_url":"https://api.github.com/users/dustymabe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dustymabe/subscriptions","organizations_url":"https://api.github.com/users/dustymabe/orgs","repos_url":"https://api.github.com/users/dustymabe/repos","events_url":"https://api.github.com/users/dustymabe/events{/privacy}","received_events_url":"https://api.github.com/users/dustymabe/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible-container/labels/feature%20idea","name":"feature idea","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-09-08T03:16:35Z","updated_at":"2016-09-16T11:53:40Z","closed_at":null,"body":"There are a few issues I'd like to discuss.\r\n\r\n- Being more explicit about what is going on in ansible-container\r\n- allowing for users to specify what playbook file to use\r\n- making the resulting image names from produced ansible-container images predictable\r\n- allowing for new \"build strategies\" to be used in the future\r\n\r\nI'd like to introduce the concept of a \"build strategy\". Currently there would exist two \"build strategies\": `dockerfile`, and `ansible`. The default build strategy would be `dockerfile` if a build context path was given. \r\n \r\nHere are 3 scenarios:\r\n```\r\nservices:\r\n  db:\r\n    image: postgres:latest\r\n\r\n  api:\r\n    image: myapi:latest\r\n    build:\r\n        context: ./path/to/dockerfiledir/\r\n\r\n  webui:\r\n    image: mywebui:latest\r\n    build:\r\n        strategy: ansible\r\n        from: centos:7\r\n        playbook: ./mywebui.yml\r\n```\r\n\r\n\r\n1st\r\n```\r\n  db:\r\n    image: postgres:latest\r\n```\r\n\r\nFor db service in the 1st scenario, no build would occur and the postgres image would be used only at runtime (i.e. no image needs to be created).\r\n\r\n\r\n2nd\r\n```\r\n  api:\r\n    image: myapi:latest\r\n    build:\r\n        context: ./path/to/dockerfiledir/\r\n```\r\n\r\nFor the api service in the 2nd scenario, we are using the `dockerfile` build strategy because we passed in the path to a directory where the Dockerfile lives. The build would execute and the resulting container image would be tagged with `myapi:latest`. A user could optionally specify `strategy: dockerfile` here if they wanted, but it is implied so the software should take care of setting that. NOTE: this case is completely compatible with docker-compose. \r\n\r\n3rd\r\n```\r\n  webui:\r\n    image: mywebui:latest\r\n    build:\r\n        strategy: ansible\r\n        from: centos:7\r\n        playbook: ./mywebui.yml\r\n```\r\n\r\nFor the webui service we set a build strategy of `ansible` and specify we want to use the `centos:7` image as the starting image. We also state that we want to run the playbook in `./mywebui.yml` against the container before saving it off under the `mywebui:latest` tag.\r\n\r\n\r\nThoughts? "},"comment":{"url":"https://api.github.com/repos/ansible/ansible-container/issues/comments/247582173","html_url":"https://github.com/ansible/ansible-container/issues/217#issuecomment-247582173","issue_url":"https://api.github.com/repos/ansible/ansible-container/issues/217","id":247582173,"user":{"login":"containscafeine","id":9133660,"avatar_url":"https://avatars.githubusercontent.com/u/9133660?v=3","gravatar_id":"","url":"https://api.github.com/users/containscafeine","html_url":"https://github.com/containscafeine","followers_url":"https://api.github.com/users/containscafeine/followers","following_url":"https://api.github.com/users/containscafeine/following{/other_user}","gists_url":"https://api.github.com/users/containscafeine/gists{/gist_id}","starred_url":"https://api.github.com/users/containscafeine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/containscafeine/subscriptions","organizations_url":"https://api.github.com/users/containscafeine/orgs","repos_url":"https://api.github.com/users/containscafeine/repos","events_url":"https://api.github.com/users/containscafeine/events{/privacy}","received_events_url":"https://api.github.com/users/containscafeine/received_events","type":"User","site_admin":false},"created_at":"2016-09-16T11:53:40Z","updated_at":"2016-09-16T11:53:40Z","body":"Hey @j00bar,\r\n\r\n> 1) In your specification, the image directive has an ambiguous meaning. In the present spec, image means \"start from here\". With what you've suggested, in different circumstances, it means the current meaning or it means \"save the image here.\" I dislike that ambiguity.\r\n\r\nThis is how it currently the [`build`](https://docs.docker.com/compose/compose-file/#/build) directive works with Docker Compose v2, so if we're to be compatible with that, it should work.\r\n\r\n> 2) I'm very -1 on playbook name override, and I've noted as much on #207 and #216. I want to encourage the best practice of keeping your Ansible playbook and container.yml in VCS alongside your application's code. I don't want to encourage storing them separately.\r\n\r\n+1 on keeping the playbook in the VCS, but maybe I have a directory with multiple playbooks, I just want to use one of those; and making the directory structure like `ansible/main.yml` mandatory is not very convenience, since I have to copy and rename each one of those. This is also a _very_ requested feature in #161 and #76.\r\n\r\n> 3) I'm entirely in favor of being able to override the default naming and tagging of built images, as being tracked in #125. I'd be fine with there being a per-service container.yml directive that contained an overridden name. I'm not sure the best way to override the version tagging, and I'm very open to suggestions.\r\n\r\nWell, the same, if we're going to have to support Compose v2, `image` and `build` come free.\r\n\r\n> You can build from a Dockerfile or an Ansible Playbook or both without having to explicitly state what \"build strategy\" you're using.\r\n\r\nYep, makes sense at the moment since we have only 2 build strategies, but if we're planning to support alternate container runtimes (`acbuild` - #228) or some other way of building container images, we need something _like_ a `build strategy` in the `container.yml` with intelligent defaults.\r\n\r\nThoughts?"}}
{"actor":{"display_login":"containscafeine"}}