GithubHelp home page GithubHelp logo

jmfederico / cookiecutter-django-docker Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 54 KB

An opinionated Cookiecutter template for running Django in Docker

License: BSD 3-Clause Clear License

Python 5.83% Dockerfile 45.83% Shell 48.35%

cookiecutter-django-docker's Introduction

Docker for Django Cookiecutter

An opinionated Cookiecutter template for running Django in Docker. Optimized for Cookiecutter Django.

Features

  • Uses PostgreSQL as database.
  • It is Webpack ready!
  • Uses Caddy as web-server (optionally with Cloudflare plugin).
  • Serves on HTTPS.
  • Poetry as package manager.
  • Includes a development mail server.
  • Includes example dotenv files compatible with dotenver.
  • Auto runs migrations on Django image.
  • Allows for custom SSL certificates to be used.

How to use

If you are not using the recommended Cookiecutter Django template, use the following instructions as a guide on how to use this cookiecutter.

Run the following commands inside you root projects directory.

# Bake cookie!
cookiecutter gh:jmfederico/cookiecutter-django-docker
# Automatically generate dotenv files
docker run --rm -v "`pwd`:/var/lib/dotenver/" jmfederico/dotenver
# Initialize poetry project
poetry init
poetry add django
poetry add psycopg2
# Create your Django project
poetry run django-admin startproject MY-PROJECT .

Now is a good idea to modify your settings.py file to use environmental variables:

SECRET_KEY = os.environ["SECRET_KEY"]

EMAIL_HOST = os.environ["EMAIL_HOST"]
EMAIL_PORT = os.environ["EMAIL_PORT"]

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": os.environ["DATABASE_NAME"],
        "USER": os.environ["DATABASE_USER"],
        "PASSWORD": os.environ["DATABASE_PASSWORD"],
        "HOST": os.environ["DATABASE_HOST"],
        "PORT": os.environ["DATABASE_PORT"],
    }
}
# Build and run Docker images
docker-compose build
docker-compose up -d

Now you can visit https://localhost/

Not using Webpack?

If you are not using Webpack you should delete the Webpack container from the docker-compose.yml file.

Running commands

The recommended way to run commands is inside the Django container:

# Create Django migrations
docker-compose run --rm django ./manage.py makemigrations

cookiecutter-django-docker's People

Contributors

jmfederico avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.