Skip to content

alireza8n/django-backend

Repository files navigation

Django Backend (Boilerplate)

Code style: black

A boilerplate built with Django, Postgres, Nginx, etc.

.env

Before anything, you should make your own environment variables. To do that firstly, run the command line below on your terminal:

cat .env.EXAMPLE > .env

now its build a .env file fill the gaps based on your project.

Code Style

We use black for our code-style!

It's already written in requirements you just need to run commandline below.

black .

Run via Docker Compose locally for Development

To run the project for development purpose run the commandline below:

docker-compose -f docker-compose.yml -f docker-compose.dev.yml up

You also can make a alias for this command.

Deploy via Docker Swarm

To run the project with docker swarm, you need to initialize docker swarm and add some secrets, then deploy the project.

Initialize docker swarm

docker swarm init

Docker Swarm Document

Add secret

echo "YOUR_SECRET" | docker secret create secret-name -

Docker Secret Document

The secrets you need to add is listed here.

Secret name Description
db-name Name of the database
db-user user of the database
db-pass password of the database
access-key storage's access key
secret-key storage's secret key
nginx.crt The Nginx's certificate
nginx.key The Nginx's private key
dhparam.pem

Run the command line below to make nginx ssl

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout nginx.key -out nginx.crt
sudo openssl dhparam -out dhparam.pem 2048

Make SSL certificate for Nginx

Deploy Swarm

docker stack deploy --orchestrator swarm -c docker-compose.yml -c docker-compose.swarm.yml <project_name>

Docker Stack Document

Manage your services

docker service ls

Docker Service Document

Contributing

See CONTRIBUTING.

Thanks to all the people who already contributed!

About

django nginx postgres boilerplate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published