djevops: Self-host Django easily
djevops is a command-line tool for deploying your Django web app to a Linux VPS. It runs and manages all necessary components (database, Redis, etc.) on your server.
Unlike other tools, djevops does not use Docker. This makes it possible to "push to prod" in seconds. Compared to Ansible, djevops' specialization on Django lets you write significantly less code. The flip side is that djevops is less general.
To get started with djevops, all you need is SSH root access to a Linux VPS running Ubuntu or Debian. Install djevops on your local machine with pip install djevops . Then, execute djevops init in your Django app's Git repository. You get a config file that looks similar to the following:
server: 1.2.3.4 git: repo: githubuser/mydjangoapp branch: main services: web: type: django env: clear: ALLOWED_HOSTS: your.website.com secret: - DJANGO_SECRET_KEY db: type: sqlite mail: host: smtp.gmail.com user: SMTP_USER password: SMTP_PASSWORD
Secrets such as DJANGO_SECRET_KEY or SMTP_PASSWORD can be specified as constants in file deploy/secrets.py .
Most config values are optional. Fill in the ones you want and run djevops deploy . djevops then clones your Git repo on the server and starts all services. As you work on your Django app and push new commits to Git, simply run djevops deploy again to apply them to your server.
Features
Automatic SSL certificates djevops generates and automatically renews SSL certificates for any domains you specify in Django setting ALLOWED_HOSTS . The domains need to be tied to your server's IP address.
Error emails If you filled in the mail section in the config file, then you can make Django email you when errors occur. To do so, set ADMINS in Django's settings.py as follows: ADMINS = [('Your Name', '[email protected])] Error emails require Django setting DEBUG to be False .
... continue reading