Full stack django example project build on multiple docker containers ready for development and production.
Batteries
postgres(withpostgisandhstoreextensions)nginxgunicornredisceleryrabbitmq
Create your own
git clone git@github.com:sspross/django-fullstack.git your-project-name && cd your-project-name && git remote rm origin
This repository is an instance of cookiecutter-django-fullstack. Check it out to create your own django fullstack project.
Setup
brewis required, see brew.sh
brew install docker boot2docker docker-compose
boot2docker upgrade
boot2docker init
In case of errors, try boot2docker delete && boot2docker init again.
For more details, read documentation.
Create host alias for current docker host IP with echo $(boot2docker ip) dockerhost | sudo tee -a /etc/hosts.
IP can change in future, update it in /etc/hosts if necessary.
Running
boot2docker start
$(boot2docker shellinit)
docker-compose up
- Browse to http://dockerhost/
- Or run something like
docker-compose run django python manage.py shell
Register your django app image (e.g. this repo) to a docker registry. E.g. quay.io, which builds your container images on git push.
- Push your repository to GitHub
- Create an account on quay.io
- Add a repository and link it to your GitHub repository
- Update
images ofdjangoandworkerintutum.ymltoquay.io/YOURUSER/YOURDJANGOPROJECT
You can deploy this app in many different ways of course. E.g. just checking it out on a server and running it with docker-compose (not recommended for production use and that's so 2014). So we use tutum.co to manage our cloud (nodes on e.g. DigitalOcean or Amazon) and deployment of our docker images.
- Create an account on tutum.co
- Create at least 1 node (e.g. on DigitalOcean). How many nodes you need and which containers are best on which nodes depends heavy on your kind of application. But you can change this later very easy thanks to tutum.co
- Update
VIRTUAL_HOSTofdjangointutum.ymltonginx.YOURDJANGOPROJECT.YOURUSER.svc.tutum.ioand use it to create a new stack on tutum.co - Start it and browse to http://nginx.YOURDJANGOPROJECT.YOURUSER.svc.tutum.io/
- link code as volume, don't ADD it into image
- how can I separate dev from prod??
- we should use
manage.py runserverto take advantage of code hot reload - same goes for static files like scss etc. find a way...
- how to use python env? e.g. open sublime in it...
- what about
gulp,webpack-server....
- here we should use gunicorn
- creating docker image: ADD code including
collectstaticandcompilemessagestuff.
- Fix code live editing in development
- should we
collectstaticandcompilemessagesdo while building image and onlymigratewhile running? - how to deploy code updates right....
-
docker-compose.ymlandtutum.ymlare very similar.... organise into dev, stage, prod etc. - static serving is production style right now, bad for development?
- How to use a domain... and is this
vhost.dthe best way? - Move secret key away from env
- Add https support
- Add Celery test
- Add Postgis
- Try Kubernetes (with GCE)
- Delete a specific container including its volumes
docker rm -v [container] - Delete all docker containers
docker rm -f $(docker ps -a -q) - Delete all docker images
docker rmi -f $(docker images -q)