This is a sample application to deploy Flask application for Cloud Foundry (CF). The contents is based on repository yuta-hono/flask-cloudfoundry-sample.
Please see blog post "Create simple Flask REST API using Cloud Foundry" for further detail.
- Cloud Foundry (Diego) or the version which Buildpack available
- select cf api url
cf api <your api URL>
- login to your space
cf login
- Push your application to CF from directory of your application on local PC
>cf push oneapp -t 600
Pip requirements, this automatically satisfied by CF in a staging phase. There is only "Flask" in the file. You can add libraries here.
The file specifies Python version to run this application by CF. See more details at Python Buildpack. Here I used "python-3.6.6", which is the latest python version of python buildpack on SAP CF as of 2018/12/12. Here is supported python version for Python Buildpack 1.6.20.
The file specifies about the specs of instance (memory/disk quota, etc).
The file specify what commands run the application. For more details, see at About Procfiles.
The simple Flask application run on CF. Important things here are:
- App
hostrequires to be set as "0.0.0.0"- CF routes the traffic from external in the router, and since all the component is scalable, CF can not restrict the access with source IPs
- App
portrequires to be set with dynamic value comes from CF envinronmental value- Since the port is dynamic value, an application can not specify a static port number. This port number requires to be set with dynamic value also