{"action":"created","issue":{"url":"https://api.github.com/repos/18F/tock/issues/359","repository_url":"https://api.github.com/repos/18F/tock","labels_url":"https://api.github.com/repos/18F/tock/issues/359/labels{/name}","comments_url":"https://api.github.com/repos/18F/tock/issues/359/comments","events_url":"https://api.github.com/repos/18F/tock/issues/359/events","html_url":"https://github.com/18F/tock/pull/359","id":157654921,"number":359,"title":"[WIP] Alternative docker-compose integration","user":{"login":"toolness","id":124687,"avatar_url":"https://avatars.githubusercontent.com/u/124687?v=3","gravatar_id":"","url":"https://api.github.com/users/toolness","html_url":"https://github.com/toolness","followers_url":"https://api.github.com/users/toolness/followers","following_url":"https://api.github.com/users/toolness/following{/other_user}","gists_url":"https://api.github.com/users/toolness/gists{/gist_id}","starred_url":"https://api.github.com/users/toolness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toolness/subscriptions","organizations_url":"https://api.github.com/users/toolness/orgs","repos_url":"https://api.github.com/users/toolness/repos","events_url":"https://api.github.com/users/toolness/events{/privacy}","received_events_url":"https://api.github.com/users/toolness/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-05-31T12:02:39Z","updated_at":"2016-05-31T16:44:14Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/18F/tock/pulls/359","html_url":"https://github.com/18F/tock/pull/359","diff_url":"https://github.com/18F/tock/pull/359.diff","patch_url":"https://github.com/18F/tock/pull/359.patch"},"body":"This cribs some things from #333 and https://github.com/18F/projects/pull/3 to add docker-compose integration with some nice developer ergonomics.\r\n\r\n## Trying it out\r\n\r\n1. Install docker/docker-compose. If you're on OS X/Windows, you'll also need to do everything in a Docker Quickstart Terminal, at least until [docker goes native](https://blog.docker.com/2016/03/docker-for-mac-windows-beta/).\r\n\r\n2. `cd` into the repository's `tock` directory (that is, the same directory that `manage.py` is in).\r\n\r\n3. Run:\r\n\r\n  ```shell\r\n$ cp .env.sample .env\r\n$ docker-compose build\r\n$ python manage.py migrate\r\n$ python manage.py loaddata test_data/data-update.json  \r\n$ docker-compose up\r\n  ```\r\n\r\n  (If the `manage.py` commands don't work, try running them with `docker-compose run app` in front of them, e.g. `docker-compose run app python manage.py migrate`.)\r\n\r\n4. If you're on linux, visit http://localhost:8000. If you're on OS X or Windows, you will probably need to visit http://192.168.99.100:8000 instead; if that doesn't work, try visiting port 8000 of the IP returned by running `docker-machine ip default`.\r\n\r\nAt this point, you can edit any of your project's source code files (Python code, template views, SASS, etc) and everything should be rebuilt automatically. Any errors will be logged to stdout.\r\n\r\n## To do\r\n\r\n- [x] Add docs to readme. Will probably want to consolidate them w/ the vagrant docs since both will have common elements. [You can view the new README here.](https://github.com/18F/tock/blob/atul-docker-compose/README.md)\r\n- [x] Make it possible to dynamically configure the port the web server is exposed at.\r\n- [x] Add a `sass` container that continuously runs sass.\r\n- [x] Define [`PYTHONUNBUFFERED`](https://docs.python.org/2/using/cmdline.html#envvar-PYTHONUNBUFFERED) so that the stdout from `manage.py runserver` always shows up.\r\n- [x] Add [graceful exit to `manage.py` via signal handler](https://github.com/18F/projects/pull/3/files#diff-632b651e5579af0e928ed63482e9bc77R6).\r\n- [x] Add convenient [`docker-compose` proxying to `manage.py`](https://github.com/18F/projects/pull/3/files#diff-632b651e5579af0e928ed63482e9bc77R45).\r\n- [x] Consider adding some code to `manage.py` that waits for the db to be up, to obviate [race conditions like this](https://github.com/18F/tock/pull/333#issuecomment-198567190). (Note that if we do this, would be great to add it to the `18/projects` repo too!)\r\n\r\n## Concerns\r\n\r\nI've hacked `manage.py` to proxy all invocations through to docker-compose if its import of `django.core.management` fails. For the vast majority of cases, this means that running `python manage.py` on the host machine is just like running `docker-compose run app python manage.py`, which saves *tons* of typing.\r\n\r\n~~However, if the developer has Django installed system-wide, then then import of `django.core.management` will succeed and `manage.py` *won't* run itself inside docker. This could potentially confuse anyone who has Django installed system-wide, so an alternative may be to write out the full `docker-compose run app python manage.py` in all installation instructions, but mention the proxied invocation as a convenience that works in most cases.~~\r\n\r\n**Update:** I ended up just writing out the full `docker-compose run app python manage.py` in all installation instructions, but mention the proxied invocation as a convenience that works in most cases.\r\n\r\n## Limitations\r\n\r\nRight now this docker-compose setup is largely intended for *development* rather than deployment. For example, `docker-compose up` runs `manage.py runserver` under the hood to ensure that assets are always recompiled when they change. It shouldn't be too hard to make it work for production too, but that's out of the scope of this PR for now.\r\n"},"comment":{"url":"https://api.github.com/repos/18F/tock/issues/comments/222747831","html_url":"https://github.com/18F/tock/pull/359#issuecomment-222747831","issue_url":"https://api.github.com/repos/18F/tock/issues/359","id":222747831,"user":{"login":"toolness","id":124687,"avatar_url":"https://avatars.githubusercontent.com/u/124687?v=3","gravatar_id":"","url":"https://api.github.com/users/toolness","html_url":"https://github.com/toolness","followers_url":"https://api.github.com/users/toolness/followers","following_url":"https://api.github.com/users/toolness/following{/other_user}","gists_url":"https://api.github.com/users/toolness/gists{/gist_id}","starred_url":"https://api.github.com/users/toolness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toolness/subscriptions","organizations_url":"https://api.github.com/users/toolness/orgs","repos_url":"https://api.github.com/users/toolness/repos","events_url":"https://api.github.com/users/toolness/events{/privacy}","received_events_url":"https://api.github.com/users/toolness/received_events","type":"User","site_admin":false},"created_at":"2016-05-31T16:44:14Z","updated_at":"2016-05-31T16:44:14Z","body":"Ok @adelevie, I removed the Vagrant stuff and documented the new instructions in the readme. I think it's good to go!\r\n\r\nLet me know if you run into any problems.\r\n"}}
{"actor":{"display_login":"toolness"}}