Package: yak-yurt
Last Updated: July 18th, 2018A collection of commands for generating and modifying a Django 2.0 project bundled with production-ready Dockerfiles.Installation & SetupInstall the following dependencies:Docker for Mac/WindowsPython 2.7/3.x (Python 3.x preferred)Install from PyPIpipinstallyak-yurtAlternative: Install from gitgitclonegit@github.com:yeti/yurt.gitcdyurtpipinstall--editable.Project StructureA project created with Yurt has the following file structure:<project_name>(PROJECT_ROOT)||_docker-compose.yml|_docker-compose.remote.yml||_django_app||||_<project_name>|||_settings.py|||_wsgi.py|||_urls.py||||_manage.py||_requirements.txt||_Dockerfile.dev||_Dockerfile.remote||_envs||||_dev.env||_remote.env||_proxy||_Dockerfile|_start.sh|_<project_name>.conf|_<project_name>.ssl.confRunningyurt env addwill add:Anotherdocker-compose.*.ymlfile to the PROJECT_ROOT.Another*.envfile to PROJECT_ROOT/envsNote:<project_name>.ssl.confis provided as a convenience, but it will still take some work to get it set up.UsageGet HELP for a Yurt commandyurt[COMMAND]--helpCreating a new Django projectyurtnewThis command generates all the files necessary to have a Django project, bundled with docker-compose.yml. Without any further configuration, you can rundocker-composeto run Django’s dev servercdpath/to/projects/docker-compose.ymldocker-composeupHost ProvisioningyurtprovisionnewYurt usesdocker-machineto support automagical Docker provisioning on AWS EC2 servers as well as on generic servers.Dry runmode (which is prompted by Yurt) simply prints out thedocker-machinecommands that Yurt would call given your input (and is recommended for new users).Environment Variable ManagementYurt has some utilities for managing environment variables in the project. It only really makes sense to do this once you’ve provisioned a host with Docker (seeHost Provisioningabove ☝️).About Environment ContextsAnenvironment contextis simply the environment variables and deploy configurations that correspond to a given desired context (i.e. “staging”, “production”, “test”). Eachenvironment contextin a Yurt project consists of an environment variable file (*.env) in theenvsdirectory and the correspondingdocker-compose.*.ymlfile in the root-level directory. The environment variables of newenvironment contextsareNOTchecked into version control, so it’s important to coordinate with teams a way to export/import environment variables.Note 1:docker-compose.remote.ymlis a special file that Yurt uses as the initial template for newenvironment contexts. It can be edited butshould not be deleted.Note 2: Adding newservicestodocker-compose.remote.ymlwill propagate those new services to newenvironment contexts. For example, adding a new service likeredistodocker-compose.remote.ymlmeans that subsequent calls toyurt env addwill includeredis.Add a new environment contextcdpath/to/yurt-projectyurtenvaddExport environment variables of all environment contexts to zip filecdpath/to/yurt-projectyurtenvexport<arbitrary-name>Import environment variables of all environment contexts from zip filecdpath/to/yurt-projectyurtenvimportpath/to/env-vars.zipDeploying Django to Remote HostYurtno longerdirectly handles app deploy. To deploy, you can usedocker-composein the right machine context.
This is a guide to do so. This guide assumes you are in the root directory of a Yurt project
(i.e. the same directory asdocker-compose.yml).First: Provision a new Remote HostyurtprovisionnewIn this example, I will create a newgenerichost on a VPS at IP address11.22.33.44calledtest-host-1.Second: Change machine contexteval`docker-machineenvtest-host-1`# Or use a different name than "test-host-1" to access a different context.This tells Docker that anydockeror related command that is called is to be piped over directly to the remote host.Third: Generate the Environment ContextyurtenvaddIn this example, I definedallowed_hostsandnginx_server_nameas the IP address of the current machine context (11.22.33.44). I definedenvironmentasproduction. I also set a bunch of other variables related to Django and Postgres.Fourth: Deploydocker-compose-fdocker-compose.production.ymlup-dSimply, rundocker-composewith the correct environment context’s deploy configs. The deploy configs automatically pull the correct environment variables.ContributingRefer toCONTRIBUTING.rst