项目作者: altixco

项目描述 :
Django 3.1 + Postgres 11 + Dokku config (Production Ready)
高级语言: Python
项目地址: git://github.com/altixco/django-postgres-dokku.git
创建时间: 2019-09-27T23:47:52Z
项目社区:https://github.com/altixco/django-postgres-dokku

开源协议:

下载


project_name

Django 3.1.1 + Postgres 11 + Dokku config (Production Ready)

Documentation

Directory Tree

  1. ├── main (Main application of the project, use it to add main templates, statics and root routes)
  2. ├── fixtures
  3. ├── dev.json (Useful dev fixtures, by default it creates an `admin` user with password `admin`)
  4. └── initial.json (Initial fixture loaded on each startup of the project)
  5. ├── migrations
  6. ├── static (Add here the main statics of the app)
  7. ├── templates (Add here the main templates of the app)
  8. ├── admin.py
  9. ├── apps.py
  10. ├── models.py (Main models like City, Config)
  11. ├── tests.py (We hope you will put some tests here :D)
  12. ├── urls.py (Main urls, place the home page here)
  13. └── views.py
  14. ├── media
  15. ├── project_name
  16. ├── settings
  17. ├── partials
  18. └── util.py (Useful functions to be used in settings)
  19. ├── common.py (Common settings for different environments)
  20. ├── development.py (Settings for the development environment)
  21. └── production.py (Settings for production)
  22. ├── urls.py
  23. └── wsgi.py
  24. ├── scripts
  25. ├── command-dev.sh (Commands executed after the development containers are ready)
  26. └── wait-for-it.sh (Dev script to wait for the database to be ready before starting the django app)
  27. ├── .env enviroment variables (ogmpred bu git)
  28. ├── .env.example Example environment file
  29. ├── static
  30. ├── static
  31. ├── Dockerfile (Instructions to create the project image with docker)
  32. ├── Makefile (Useful commands)
  33. ├── Procfile (Dokku or Heroku file with startup command)
  34. ├── README.md (This file)
  35. ├── app.json (Dokku deployment configuration)
  36. ├── docker-compose.yml (Config to easily deploy the project in development with docker)
  37. ├── manage.py (Utility to run most django commands)
  38. ├── requirementes.txt (Python dependencies to be installed)
  39. └── requirements-dev.txt (Python dev dependencies to be installed)

How to install the template

Clone the repository, and update your origin url:

  1. git clone https://github.com/altixco/django-postgres-dokku project_name
  2. cd project_name

Merge the addons required by your project (Optional):

  1. git merge origin/rest
  2. git merge origin/webpack
  3. git merge origin/push-notifications

Rename your project files and directorys:

  1. make name=project_name init

Info: Make is required, for mac run brew install make

After this command you can already delete the init command inside the Makefile

The command before will remove the .git folder so you will have to initialize it again:

  1. git init
  2. git remote add origin <repository-url>

How to run the project

⚙️ Setup

Before running the application, copy the environment file:

  1. cp .env.example .env
  2. The project use docker, so just run:

docker-compose up

  1. > If it's first time, the images will be created. Sometimes the project doesn't run at first time because the init of postgres, just run again `docker-compose up` and it will work.
  2. *Your app will run in url `localhost:8000`*
  3. To recreate the docker images after dependencies changes run:

docker-compose up —build

  1. To remove the docker containers including database (Useful sometimes when dealing with migrations):

docker-compose down

  1. ### Accessing Administration
  2. The django admin site of the project can be accessed at `localhost:8000/admin`
  3. By default the development configuration creates a superuser with the following credentials:

Username: admin
Password: admin

  1. ## Production Deployment: ##
  2. The project is dokku ready, this are the steps to deploy it in your dokku server:
  3. #### Server Side: ####
  4. > This docs does not cover dokku setup, you should already have configured the initial dokku config including ssh keys
  5. Create app and configure postgres:

dokku apps:create project_name
dokku postgres:create project_name
dokku postgres:link project_name project_name

  1. > If you don't have dokku postgres installed, run this before:
  2. > `sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git`
  3. Create the required environment variables:

dokku config:set project_name ENVIRONMENT=production DJANGO_SECRET_KEY=….

  1. Current required environment variables are:
  2. * ENVIRONMENT
  3. * DJANGO_SECRET_KEY
  4. * EMAIL_PASSWORD
  5. Use the same command to configure secret credentials for the app
  6. #### Local Side: ####
  7. Configure the dokku remote:

git remote add production dokku@:project_name

  1. Push your changes and just wait for the magic to happens :D:

git push production master

  1. Optional: To add SSL to the app check:
  2. https://github.com/dokku/dokku-letsencrypt
  3. Optional: Additional nginx configuration (like client_max_body_size) should be placed server side in:

/home/dokku//nginx.conf.d/.conf
```

Further dokku configuration can be found here: http://dokku.viewdocs.io/dokku/