Package: django-yadpt-starter
# django-yadpt-starterdjango-yadpt-starteris Yet Another Django Project Template skeleton for Django projects.While there is no shortage of Template Skeletons for Django projects, the aim of this one is to provide you, to the extent possible, with a fully automated setup usingDocker Containersand a [Let’s Encrypt](https://letsencrypt.org) SSL certificate for your site, all while adhering to recommended best practices. A few key features are:Configuration performed bydjango-yadpt-starter, a small utility that makes it trivial to setup your project;Automatic generation and renewal of [Let’s Encrypt](https://letsencrypt.org) certificates;Adheres to best practices;Provides different environments: One without a valid certificate for local development and another with a valid certificate (for Production or Staging).Once finished there should be 2 templates: aminimalbut functional template and a more complete template.## UsageGetting your shiny new Django project up and running, complete with SSL certificates, is as easy as following these simple steps:Installdjango-yadpt-starterutilitypip install django-yadpt-starterCreate your project structuredjango-yadpt-starter.py -e ENVIRONMENT PROJECT_NAMEENVIRONMENTmust be eitherproductionordev_(SSL certificates are only created production)_PROJECT_NAMEis the name you wish to give your project. Bear in mind that this name will be used throughout the Docker environment (volumes, containers, networks, etc.)Add your beautifully crafted code and then start theDocker Containers. Please note that choosing your environment properly is very important for your docker-compose “.yml” . If you are still developing use dev.yml (Dev mode does not use Nginx). The default one is for Production, so do not use this one on your local machine while developing otherwise you will run into errors.cd path/to/PROJECT_NAME
docker-compose -f {env}.yml build
docker-compose -f {env}.yml up -dAt the moment you will probably run into some errors (because of issuehttps://github.com/psychok7/django-yadpt-starter/issues/13) and to fix them you must manually go into the docker container and delete the content of the database as explained. After that just rundocker-compose up -d –force-recreate.There is no step 5, just enjoy!Note:django-yadpt-startercan be run as many times as you like in order to create multiple environments, there are however some caveats:PROJECT_NAMEmust be something unique to ensure that volumes and containers don’t collide;Since certbot is using the [–standalone](https://certbot.eff.org/docs/using.html#standalone) plugin which binds to ports80and443, you need to stop any running containers or services that may already be bound to those ports;### Migrating existing code from one Environment to another.If you have running code already deployed and eventually want to switch machines or have the same code running on another machine (from dev to production for example) you can do it manually. But before that, make sure the project you created from thedevenvironment has everything it needs, like for example theserver_nameinnginx.confis filled and you also have your domain inletsencrypt.conf. The easiest way might still be you creating an empty project with theproductionenvironment in your final machine so that all theses gaps can be automatically filled and then copy that folder to your local machine and add your existing code into it and push it to your git repository (or push it directly to git from your prod server if you have write permissions). This is still something we haven’t really found an easy way to solve, nevertheless once you learn the project structure this migration becomes fast and painless. So after filling in just:` 1.docker-compose-fstaging.yml build 2.docker-compose-fstaging.yml up # will throw errors, but it's ok 3.docker-compose-fstaging.yml stop 4. docker volume ls # And get the name volume to pass to the the follwing command. e.g: smal_smal_https_certs 5. docker run-it--rm-v{named_volume from step4}:/etc/letsencrypt-p80:80-p443:443 palobo/certbot:1.1 certonly-t-n--standalone--preferred-challengeshttp-01--email{email}--agree-tos-d{domain} 6.docker-compose-fstaging.yml build 7.docker-compose-fstaging.yml up # Everything should be fine now. `### Advanced Usagedjango-yadpt-starterwill ask you for adomainname. If you require more than one domain (ex. domain.com and www.domain.com) then simply run through the startup script and then, before starting the containers, rundocker run -it –rm -v {project_name}_https_certs:/etc/letsencrypt -p 80:80 -p 443:443 palobo/certbot:1.1 certonly -t -n –standalone –agree-tos -d {domain} -d {domain} -d {domain} -m myemail@example.comIf for some reason you decide to add a new domain to the list of existing domains, you will need to use theexpandand replace the existing certificate with a new certificate. Remember to re-add all the domains that where there already with the new one.docker run -it –rm -v {project_name}_https_certs:/etc/letsencrypt -p 80:80 -p 443:443 palobo/certbot:1.1 certonly -t -n –standalone –expand –agree-tos -d {domain} -d {domain} -d {domain} -m myemail@example.com## Free HTTPS (SSL/TLS) for websites (Let’s Encrypt certificates) using CertbotFor environments where a certificate is generated (staging or production), [Certbot](https://certbot.eff.org) is used to generate a a [Let’s Encrypt](https://letsencrypt.org) certificate. The only requirement is that you already have DNS setup so that you Django app is already reachable.Note:Given there is a daily cron job which checks to see if the certificate is up for renewal, it’s essential the container is always kept running.## Used Third Party Appshttps://github.com/docker/dockerhttps://github.com/docker/composehttps://github.com/fusionbox/django-authtoolshttps://github.com/django-extensions/django-extensionshttps://github.com/django-dbbackup/django-dbbackuphttps://github.com/brack3t/django-braceshttps://github.com/sebleier/django-redis-cachehttps://github.com/getsentry/raven-pythonhttps://github.com/kennethreitz/requestshttps://github.com/nedbat/coveragepyhttps://github.com/certbot/certbotSee the files included in the project_template directory for an example.