Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dockerizing Django projects

Dockerizing Django projects

Pros and Cons of the different ways there are to turn a Django project into a Docker container.

Roberto Rosario

April 15, 2016
Tweet

More Decks by Roberto Rosario

Other Decks in Programming

Transcript

  1. Docker provides an integrated technology suite that enables development and

    IT operations teams to build, ship, and run distributed applications anywhere.
  2. docker run --name postgres -e POSTGRES_DB=mayan -e POSTGRES_USER=mayan -e POSTGRES_PASSWORD=mysecretpassword

    -v /var/lib/postgresql/data -d postgres docker run --name redis -d redis docker run --name mayan-edms -p 80:80 --link postgres:postgres --link redis:redis -e POSTGRES_DB=mayan -e POSTGRES_USER=mayan -e POSTGRES_PASSWORD=mysecretpassword -v /usr/local/lib/python2.7/dist- packages/mayan/media -d mayanedms/monolithic
  3. • Single download • Low entry barrier • Easiest to

    maintain • Big size download • Not good for scaling • Same VM/Server problem
  4. • Scale individually • Smaller download • Best approach for

    production • Harder to setup • Need documentation • Several DockerFiles
  5. • Single download • Can reuse configuration file templates •

    Single core repo • Bigger size download
  6. • Smallest download • Hardest to configure • Might not

    scale best • Might violate port export concept
  7. environment: - NGINX_HOST=foobar.com - NGINX_PORT=80 command: /bin/bash -c "envsubst <

    /etc/nginx/conf.d/mysite.template > /etc/nginx/conf. d/default.conf && nginx -g 'daemon off;'"
  8. • Single download • Lowest entry barrier • Biggest size

    download • Terrible for scaling • Same VM/Server problem • Support 3rd party software
  9. $ docker run --name postgres -e POSTGRES_DB=mayan -e POSTGRES_USER=mayan -e

    POSTGRES_PASSWORD=mysecretpassword -v /var/lib/postgresql/data -d postgres $ docker run --name redis -d redis $ docker run --name mayan-edms -p 80:80 --link postgres:postgres --link redis:redis -e POSTGRES_DB=mayan -e POSTGRES_USER=mayan -e POSTGRES_PASSWORD=mysecretpassword -v /usr/local/lib/python2.7/dist- packages/mayan/media -d mayanedms/monolithic
  10. $ docker run --name postgres -e POSTGRES_DB=mayan -e POSTGRES_USER=mayan -e

    POSTGRES_PASSWORD=mysecretpassword -v /var/lib/postgresql/data -d postgres $ docker run --name redis -d redis $ docker run --name mayan-edms -p 80:80 --link postgres:postgres --link redis:redis -e POSTGRES_DB=mayan -e POSTGRES_USER=mayan -e POSTGRES_PASSWORD=mysecretpassword -v /usr/local/lib/python2.7/dist- packages/mayan/media -d mayanedms/monolithic
  11. $ docker run --name postgres -e POSTGRES_DB=mayan -e POSTGRES_USER=mayan -e

    POSTGRES_PASSWORD=mysecretpassword -v /var/lib/postgresql/data -d postgres $ docker run --name redis -d redis $ docker run --name mayan-edms -p 80:80 --link postgres:postgres --link redis:redis -e POSTGRES_DB=mayan -e POSTGRES_USER=mayan -e POSTGRES_PASSWORD=mysecretpassword -v /usr/local/lib/python2.7/dist- packages/mayan/media -d mayanedms/monolithic until nc -z $POSTGRES_PORT_5432_TCP_ADDR $POSTGRES_PORT_5432_TCP_PORT; do echo "$(date) - waiting for postgres..." sleep 1 done
  12. until nc -z $POSTGRES_PORT_5432_TCP_ADDR $POSTGRES_PORT_5432_TCP_PORT; do echo "$(date) - waiting

    for postgres..." sleep 1 done until nc -z $RABBITMQ_PORT_5672_TCP_ADDR $RABBITMQ_PORT_5672_TCP_PORT; do echo "$(date) - waiting for rabbitmq..." sleep 1 done
  13. $ docker run -d --name mycontainer some-image-or-other $ docker run

    --link mycontainer:mycontainer aanand/wait waiting for TCP connection to 172.17.0.105:5432......ok