Reputation: 23098
I have a VM running on Google Compute Engine hosting a Flask application served by Apache/WSGI. This application has to be accessible on the Internet via www.my_application.com
.
What is the best way to expose the application through WSGI when inside a Docker container?
docker run
command to use?my_application.conf
need to be modified?Below is my_application.conf
:
<VirtualHost *:80>
ServerName www.my_application.com
WSGIDaemonProcess my_application user=www-data group=www-data threads=5
WSGIScriptAlias / /var/www/my_application/application.wsgi
ErrorLog /var/log/my_application.log
<Directory /var/www/my_application>
WSGIProcessGroup my_application
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Upvotes: 2
Views: 7749
Reputation: 1606
This may or may not be that relevant to you, but I made a public (and open source) Docker image with all the bells and whistles that you can use to build a Python Flask web application.
It has uWSGI for running the application, Nginx to serve HTTP and Supervisord to control them, so you don't have to learn how to install and configure all those to build your Python Flask web app.
And Google Compute Engine can run Docker: https://cloud.google.com/compute/docs/containers
It seems like uWSGI with Nginx is one of the more robust (and with great performance) ways to deploy a Python web app. Here are the benchmarks: http://nichol.as/benchmark-of-python-web-servers.
There are even some template projects you can use to bootstrap your own. And also, you don't have to clone the full project or something, you can just use it as a base image.
Docker Hub: https://hub.docker.com/r/tiangolo/uwsgi-nginx-flask/
GitHub: https://github.com/tiangolo/uwsgi-nginx-flask-docker
Upvotes: 4