Skip to content

viewflow/django-skinny-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

Django Skinny Deploy

Simple, single file deploy a Django project to an Ubuntu host. Full-automatic, copy-paste Nginx/Gunicorn/Let's Encrypt HTTPS set up in minutes. Tested on Ubuntu 18.04 LTS/19.10 and Debian 10 images

              

Read full story on Medium

Why?

Because I didn't find any drop-and-run solution not overburdened with a lot of files for a simple project.

Prerequisites

  • Get your Virtual Private Server running (Digital Ocean, Linode, Vultr or on any other provider)
  • Buy and set up your domain (GoDaddy, Gandi, ...)

Ensure that your server is up and running and you can connect to them over ssh via domain name

What does this script do?

  • Postgresql/Nginx/Gunicorn installed and configured on the server
  • All code from a local directory synced to /srv/yourdomain.com on the server
  • yourdomain-com user and yourdomain-com database created on the Postgresql server
  • Let's Encrypt certificates requested, systemd timer installed for automatic renewal

https://yourdomain.com - becomes ready to serve.

Quick Start

The repository contains a quick django project template. It's just a raw django 3.0 startproject template with Pipenv and django-environ enabled. No extra heady sugar added.

python3 -m pip install --user django
django-admin.py startproject --template=https://github.com/viewflow/django-skinny-deploy/archive/template.zip mysite

For an existing project, you need to install pipenv, and modify project settings to use django-environ. Detailed instructions available in this article.

Deploy

To work on the proeject you need to have Pipenv and Ansible tools installed. I prefer to have pipenv installed for a user, and ansible as a development project dependency.

python3 -m pip install --user pipenv
pipenv -d install ansible
pipenv run ansible-playbook -i yourdomain.com, -u root deploy.yml

Please note the comma after the domain name. It's required and tells ansible that we have provided a domain name, instead of an inventory file name.

During the first deployment you will be asked for an email address for Let's Encrypt certificate registration.

That's all!

Update existing deployment

pipenv run ansible-playbook -i yourdomain.com, -u root deploy.yml -tags=update

Troubleshooting

Run ansible-playbook with -vvv flag:

Check service status on the server console:

$ service nginx status
$ service gunicorn_yourdomain_com status

Check logs at:

/var/nginx/logs

Contributing

Have an idea how to make this script smarter, smaller and cleaner? Pull requests are welcome!

License

Zero-Clause BSD (0BSD)

Copyright (C) 2019 by Mikhail Podgurskiy <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

About

Simple, single-file deploy Django to an Ubuntu host

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published