Deploy simple django base app with docker.
- 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.
- 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.
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
- 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.
- Added simple Dockerfile.
- Added simple .dockerignore.
- 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).
- Gunicorn: Python WSGI HTTP Server for UNIX.
- Whitenoise: Radically simplified static file serving for Python web apps.
Please let me know if it works.