DEV Community

Cover image for Deploying Django Apps; Containers
Paritosh
Paritosh

Posted on

Deploying Django Apps; Containers

Intro

Lately I observed some weird practices that my fellow Engineers follow for developing and especially deploying their Django application in production.

I did bit of research about best practices for a Django project development life cycle & below is what I feel the most reliable way to develop & deploy a Django application end-to-end.

I don't intend to define the coding practices...

Though trying to set the perspective of creating new project & shed some light to small details that we tend to miss that eventually lead to bad Engineering.

Unit test cases in Django

Writing test cases is a tool that developer do ignore or don't plan ahead and hence there are repeated iterations to make sure that application functionality is working fine after every major code change.

Unit tests are important if the application's scope is wide. Though this practice is being followed for larger application but overlooked for small or medium scale projects.

Code style enforcement using Flake8

Flake8 points out the errors & violations like a variable declared but never used in a class. It is very handy and helps in setting fundamental guidelines for every developer in the team.

Creating Docker images for Django application

Containerisation has huge benefits & being the torch bearer of Docker in my organisation I have figured that the best possible solution to deploy Django
applications is to create Docker images & ship them to production.

Creating a Dockerfile that define setting up python environment required by the Django application. Using this for creating Docker images is the most reliable way to ship & deploy Django application in production.

Setting Docker Registry using Harbor

In the process to get Docker adopted in my team, it was necessary to get an in-house docker registry which people can use to push the Docker images of the projects they were working on.

VMware's Harbor is an enterprise grade registry server which supports LDAP based user login to Docker registry. That is Engineers can use their existing user credentials to use in-house Docker registry.

Code review & Jenkins CI for a Django project

Code review process using conventional tools like Gerrit & Jenkins offer good features to automate code verification and Docker image creation part using above mentioned strategy.

This is the most reliable way to develop, ship & deploy applications as per my best knowledge of Django. Do share if there are any other better strategies or tools to achieve this common goal.

Top comments (0)