/Docker-Django-Template

This repository contains docker file for deploying django app on nginx server for production use.

Primary LanguagePythonISC LicenseISC

Deployment Docker of Django, PostgreSQL database, NginX, Gunicorn

Hits

This is a Docker setup for deploying your web application based on Django. It also contains tox file for testing your app.

Buy Me a Coffee at ko-fi.com

Requirements

You need to install Docker and Docker-Compose.

Production checklist

make sure your django app is configures for production use using this link.

Build

docker-compose build or make build.

Django models in database

docker-compose run --rm djangoapp /bin/bash -c 'cd hello; ./manage.py makemigrations'.

Migrate database

docker-compose run --rm djangoapp /bin/bash -c 'cd hello; ./manage.py migrate'.

Database and static volumes

The static files are mounted wih the volumes of the docker-compose files! However, if you change the static files make sure, you remove the volumes with docker volume prune or run docker compsose down -v. Those commands remove the volumes and if you run docker compose build again the volumes will be mounted again correctly 😄 You can inspect all listed mounted files in the menu.

Run

Remember to pass DJANGO_SETTINGS_MODULE in when you run it: DJANGO_SETTINGS_MODULE=hello.settings.development docker compose up. or set it in the config/service/.env

Tests

  • make checksafety
  • make checkstyle
  • make test
  • make coverage

Reference

Example using Docker, Django, multiple Postgres databases, NginX, Gunicorn, pipenv, GitLab CI and tox

License

Software licensed under the ISC license.