Get an account
Installing the cf tool
Before you begin, install the command line tool that is used to upload and manage your application. BlueMix uses a tool called cf command line interface.
Download cf command line interface from https://github.com/cloudfoundry/cli
The cf command is a program that you need to install. Select the appropriate installer for your operating system. After the cf command tool is installed, you can use cf -v command to verify its version as follows:
$cf -vcf version 6.0.0-90db382
Login using the cf tool
Login. Be sure to use the right endpoint. To see the end point type:
$cf –t API endpoint: https://api.ng.bluemix.net (API version: 2.2.0)Not logged in. Use 'cf login' to log in. $cf login
I had to reset mine to the beta site.
$ cf api https://api.stage1.ng.bluemix.net
Procfile is where the command is for launching your app
Web: python hello.py
Hello.py s the contents of your hello world app
import os from flask import Flask app = Flask(__name__) @app.route('/') def hello(): return 'Hello World!' port = os.getenv('VCAP_APP_PORT', '5000') if __name__ == "__main__": app.run(host='0.0.0.0', port=int(port))
Get help getting answers to your questions
Go to IBM.com forums
Prepare the environment for your chosen runtime
Python is my language of choice. Bluemix doesn’t have Python as a pre-existing runtime. You can however create your own runtime by using buildpacks that create the environment for you. In this hello world example we will use Flask as our HTTP server.
requirements.txt file describes the application prequisites.
You can push your application to Bluemix along with a Python buildpack:
You can find Python buildpacks on Github. https://github.com/ephoning/heroku-buildpack-python From this page you can click on the Download Zip file on the right column.
Unzip the file into a local directory. Extract the zip into directory named hello-python-master in the folder where cf tool was installed in.
Push App to Bluemix
cf push <YOUR_APP_NAME> -m 128M -b https://github.com/ephoning/heroku-buildpack-python.git $ c:\CloudFoundry\hello-python-master>cf push hello-python-master -m 128M -b https://github.com/ephoning/heroku-buildpack-python.git
Check the logs in the command window for errors. You likely might get some because you aren’t executing the commands in the right folder. Make sure you invoke the command where the requirements.txt file is for the helloworld.py file. If successful you should see the output below.
…-----> Uploading droplet (26M) 0 of 1 instances running, 1 starting1 of 1 instances running App started Showing health and status for app hello-python-master in org carlos.ferreira@ youremail.com / space dev as email@example.com... OK requested state: startedinstances: 1/1usage: 128M x 1 instancesurls: hello-python-master.stage1.ng.bluemix.net state since cpu memory disk#0 running 2014-05-08 09:51:17 PM 0.0% 109.4M of 128M 99M of 1G
Try your App in the browser
Open a browser and type the name of the app pre-pended to your Bluemix URL.
My app is hello-python-master
My Bluemix URL is stage1.ng.bluemix.net
Figure 1 Hello World
Check the logs in the command line window
Check your dashboard on bluemix that the app is running