Django (Python3), uWSGI and Nginx with Alpine Linux
This Dockerfile takes an existing Django app and deploys it for production using uWSGI and Nginx. I used most of the source code from https://github.com/dockerfiles/django-uwsgi-nginx, but I modified it to use Alpine instead of Ubuntu, the former being much lighter and in my opinion much cleaner.
How to deploy your Django App
Copy the root of your Django project into the app folder, make sure to include a
requirements.txt file. You need to modify the following files:
- [uwsgi.ini] Line module=your_app.wsgi:application. your_app needs to be the name of your django project, i.e. the folder name where wsgi.py lives.
- [nginx-app.conf] Lines referring to static and media content. Use their full paths.
docker build -t webapp . docker run -d -p 8113:8113 webapp
Accesing localhost:8113 should then work.