Package: jonah
Using Jonah, you can develop your Django application entirely within Docker.This way, your code runs in the exact
same environment, whether it’s on your machine, on the test server, or in deployment. Jonah saves you a lot of the
setup work in the beginning, letting you jump into a fully prepared, but configurable, Django Docker Project.If you are using TDD, you can include Jonah on your build server to make sure all tests pass before pushing it to your
staging or production servers.Getting StartedYou can install Jonah usingpip:> pip install jonahThen run it using thejonah <command>syntax. To start a new project, run> jonah init your_new_projectJonah will then create a new directory calledyour_new_projectin the current working directory and create an empty
Django project inside.Developing Your ProjectTo run your new empty project, runjonah develop:> cd your_new_project
> jonah developThis will build and launch the container, then launch the Django project inside the container. If you get any error
messages, check if your computer has a working and current installation of Docker. To check if your project is running,
visithttp://localhost/(port 80) in your browser.Theddpdirectory inside your project directory is transparently mounted into the container, so that any changes in
your code are directly applied to the running code. (For some changes, you might have to reload the Django server, but
more on that later.)Most of the time when developing a Django application, you don’t need to restart the development server constantly. For
changes to models, settings, or changes toadmin.py, you can reload the Django server using this command:> jonah reloadGetting A ShellNow, let’s start a new app inside the project. To do that, you can use Jonah’sshellfeature. Open a shell inside
the container like so:> jonah shellAfter a moment, you should see a new prompt looking something likeroot@a0e9d20bffdf:/code#to indicate you’re
working inside the container. Change the working directory into theddpdir and run themanage.pycommand like
you would normally:> cd ddp
> ./manage.py startapp my_new_appCongratulations! You just ran Django code inside your container. It is recommended that you runmakemigrations,migrate, and othermanage.pycommands like this as well. Typeexitto exit the container shell and return
to your regular command line.Running Testsjonah testwill run all your tests in the container and display live output.Stopping the ContainerOnce you’re calling it quits after a long day of productive coding, usejonah stopto shut down your container.
Happy coding. :)Moving an Existing Project to JonahJonah is easiest to use when you start a new project. However, it should work with any directory that has aDockerfileand ajonah.inifile. A good way to move a Django project into Jonah would probably be the following:Rename your Django project toddpCreate a new Jonah project with the name of your Django projectReplace the ddp directory inside Jonah by your ownProfitFull List of CommandsCommandDescriptioninitInitialize a new jonah project in the current directorybuildBuild the image.cleanbuildBuild the image from scratch instead of relying on cached layers.developRun dev serverreloadReload Django process on dev servershellGet a shell on the dev serverstopStop a previously running development servertestBuild and run Unit TestscompilemessagesCompile internationalization StringstagAdd git and docker tagsdeployDeploy to production. This command will ask you for a tag before pushing anything to the serverstageDeploy to stagingdirect_deployDeploy as tag “master” on production server, without warning and without asking for confirmationcleanDelete exited containers, dangling images, and volumes. Good to clean up hard drive space.To get a full list of commands, rundeploy.pywithout any arguments.ConfigurationTheinitcommand will create a number of configuration files. Here is what they are used for:FileDescriptionjonah.iniGeneral configuration for jonah, most importantly the Docker image namerequirements.txtThis file is in Pip-Syntax. Python packages found here will be installed into the Docker
container.test.shA shell script to run your tests. In many cases, this should just containmanage.py test, but maybe you want to create code coverage, or include nose, or
transform unit test results to other formats for your build server to use.jonah/apt-packages.txtThis file is in apt-get syntax. System packages that will be installed after basic system
installation is complete.jonah/supervisord.confConfig file for supervisord. By default, this runsspinup.sh, then starts
gunicorn and the Django server.jonah/nginx.confConfig file for nginx. Look at this if you want to e.g. setup different static file
handling.jonah/spinup.shA shell script to run EVERY TIME the container is spun up.jonah/finalize_build.shA shell script to run ONCE after the system installation has finished.Sidebar: Whyddp?What is the meaning of theddpdirectory?While a Jonah project can have any name, theDjango projectit encapsulatesneedsto be calledddp, so all
the scripts and calls inside Jonah know where to find the Django project, how to specify settings, etc. “DDP” stands
for “Docker Deployable Project”.While this constraint could be lifted in the future, it is not very high on our list of priorities right now. If you
feel differently, please let us know by opening or adding to an issue on GitHub.Help Out and Code of ConductWe’d like to encourage your feature requests, bug reports and pull requests. Please note that theDjango Code of Conductapplies to this project. Be friendly, welcoming, considerate, respectful, and be careful
in the words that you choose please. If you think you’ve witnessed a CoC violation, please contact Daniel.HeritageJonah is inspired byJoe Mornin’s excellent ``django-docker``.LicenseThis project is released under the MIT license. See theLICENSEfile for more info.