GithubHelp home page GithubHelp logo

sashagoebbels / cookiecutter-django-docker-compose Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 17 KB

A cookiecutter template for a basic Django app running inside a docker-compose environment with a web and a PostgreSQL based database service

Python 78.15% Dockerfile 21.85%

cookiecutter-django-docker-compose's Introduction

Django + docker-compose

Bootstrap your django project inside docker with PostgreSQL support.

What will I get?

  • Dockerfile for Django development
  • docker-compose.yml file with 2 services: web (Django) and db (PostgreSQL)
  • .gitignore file with support for python and Jetbrains software
  • .gitlab and .github directories with issue and pull/merge request templates in each

Usage

Prerequisite

Install cookiecutter:

pip install cookiecutter

Create your project

cookiecutter https://github.com/vgoebbels/cookiecutter-django-docker-compose.git

Bootstrapping will take some time because the script has to wait for the PostgreSQL container to come up properly to spin up the django container.

What it does:

  • Ask you for a project name, slug and description as well as an app name.
  • Build the images
  • Run django-admin startproject with the project name provided
  • Patch the PostgreSQL connection information into settings.py
  • Append a path of / for LOGIN_REDIRECT_URL and LOGOUT_REDIRECT_URL at the end of settings.py
  • Run manage.py startapp with the app name provided
  • Waits 25 seconds for the PostgreSQL container to come up properly and run manage.py migrate
  • Run manage.py createsuperuser (will ask you interactively for admin user settings)
  • Shut down all the cvontainers

To spin up the project after this, change into the project directory and run:

docker-compose up -d

Known problems

On some hosts the PostgreSQL container comes up too slowly. This leads to an error message in the Python container about the database not being accessible.

If you encounter this pronlem, shut down and restart the Python container with:

docker-compose stop web
docker-compose up -d web

To prevent this from happening again, start both services manually with some delay by:

docker-compose up -d db

docker-compose up -d web

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.