Skip to content

Latest commit

 

History

History
63 lines (39 loc) · 2.94 KB

README.md

File metadata and controls

63 lines (39 loc) · 2.94 KB

Django-generic APP on Docker

Python 3.5|3.6

Deploy simple django base app with docker.

Prerequisites

  • Docker, is a tool designed to make it easier to create, deploy, and run applications by using containers.
  • Django, a high-level Python Web framework.
  • VirtualEnv a tool to create isolated Python environments, to have Django commands available.

Repository structure

  • The folder django-docker-generic contains two very important files, a Dockerfile to run docker-command build and the .dockerignore file that contains a ignore regex patern to deploy django project on Docker securely.

TL;DR;

Download the files Dockerfile and .dockerignore; Run the build of the image with the Docker commands, inside of you django-proyect folder. Here are some examples:

# my-django-project-folder/ #: docker build --build-arg PROJECT_NAME=my-django-project-folder -t my-image-name .

# my-django-project-folder/ #: docker run --rm -it -p 80:8000 -e PROJECT_NAME=my-django-project-folder my-image-name:latest

Then access from you web-browser to 0.0.0.0:80

Changelog

0.2

  • Modified the Dockerfile.
    • Add build argument to plan projet folder structure on build.
    • Change order from commands to optimize builds after adding argument.
  • Modified the .dockerignore.
    • Adjust ignore files and folder.

0.1

Remarks

Enviroment Variables Availables

  • PROJECT_NAME: name of the Django-proyect to load project settings (mandatory).
  • HOST: net address to bind Gunicorn to serve the app (def 0.0.0.0).
  • PORT: network port to bind Gunicorn to serve the app (def 80).
  • WORKERS: Gunicorn procesess for better performance(def 3).
  • USER: django user to login (def admin).
  • PSWD: django pass to login (def admin).

Python Essential tools used:

  • Gunicorn: Python WSGI HTTP Server for UNIX.
  • Whitenoise: Radically simplified static file serving for Python web apps.

Please let me know if it works.