Sign inSign up

namikazebadri/django-app

By namikazebadri

•Updated over 5 years ago

Image
0

456

namikazebadri/django-app repository overview

⁠Django Project Template

Django project template with a lot of basic project must-have features, such as containerization and deployments to GCR, ECR, Dockerhub and regular old VM using Github Actions. Also Unit Test, Code Coverage, Static Analysis and Stages Flow (such as dev, staging, uat and production) are part of this project template repository.

⁠What is Inside This Template?

⁠Development Stage

⁠Requirements
  1. Python >= 3.8.5
  2. Pip >= 21.0.1
⁠Installing Dependencies

pip install -r requirements.txt

⁠Creating Container for Database Server

To start new database server, run this command:

docker-compose up -d

Check if database running correctly by accessing database from command line or PGAdmin.

⁠Migrating Database

To create migration scripts:

python manage.py makemigrations app

To execute migrations:

python manage.py migrate app

⁠Running The Application

python manage.py runserver 0.0.0.0:8080

⁠Running Test Suite

This application using pytest⁠ as the test framework and pytest-django⁠ as integration tool with Django Framework. To run unit test simply run this command.

pytest -s

⁠Running Code Coverage

This application using coverage⁠ as the code coverage tool and pytest-cov⁠ as integration tools with Pytest. To run code coverage simply run this command.

pytest --cov-report html --cov-report term --cov=app app/tests/

⁠Running Static Analysis

To run static analysis using flake8, run this command:

flake8 --config=.flake8 --count --statistics app/ core/

⁠Continues Integration

You can use build-ci status checks in the repository settings to ensure continues integration is working correctly on target branch. This status checks come from .github/workflows/onpush-ci.yml.

⁠Deployment Stage

This project template provide deployment using docker image. The deployment targets are GCR, ECR, Dockerhub or VM, you can see the workflows from this these files .github/workflows/*-deployment.yml.

⁠Build Image

To build image run this command (change the tag name & version with your preferred tag name & version).

$ docker build . -t myorganization/myimage:1.0.0

⁠Running Container from Image

To create a container from the image, run this command (change the tag name & version with your preferred tag name & version).

$ docker run -d -p 8000:8000 --network=serviceNetwork --name django-app myorganization/myimage:1.0.0

Then you can access the app from the browser with this url: http://127.0.0.1:8000

⁠Dockerhub image

This repository is proven by running build in Dockerhub, you can see the result here⁠.

Tag summary

Content type

Image

Digest

Size

184.2 MB

Last updated

over 5 years ago

docker pull namikazebadri/django-app