This image comes in two varieties depending on what Python version you require.
2.7, 2, latest3.6, 3docker run -d -v /path/to/project:/app -p 80:80 relvacode/flask-microservice
All dependencies will be installed on start-up and uWSGI will automatically reload the Python application after a change is detected (20 second interval).
Use this in your Dockerfile:
FROM relvacode/flask-microservice
When your image is built it will add the build context to /app and install any apt and pip dependencies during build time.
This is the recommended method for production deployments.
/api/app/staticServes Python application in /app/app/api.py
The home directory where applications are served is /app.
Under this directory your application should have this folder structure
/app
app/ - This is where your Python code goes
api.py - Your main flask application filestatic/ - Your static content such as .html, .js, .css filesrequirements.apt - apt requirements, separated by newlinerequirements.pip - pip requirements, separated by newlineUWSGI_ENTRYPOINTThis sets what Python file/module in /app/app to serve using uWSGI. Do not include the file extension.
Defaults to api which equates to /app/app/api.py
UWSGI_APPLICATIONThis sets what variable inside UWSGI_ENTRYPOINT points to the the uWSGI (Flask) application.
Defaults to app.
UWSGI_CHDIRChange to this directory before loading the Python application.
Defaults to /app/app.
To enable error logging of application errors to the container log you should add the PROPAGATE_EXCEPTIONS parameter to the Flask configuration.
from flask import Flask
app = Flask(__name__)
app.config['PROPAGATE_EXCEPTIONS'] = True
Content type
Image
Digest
Size
168.4 MB
Last updated
over 7 years ago
docker pull relvacode/flask-microservice