How to deploy python app on IBM cloud

Intro

Back in a days, when I’ve been wanted to develop and host some web application I used one PaaS called Openshift. They were offering free tier platform with 3 limited instances but it was OK for my purposes. But one day they decided to shut down this platform and move users to new one – not so free, way too complex (for simple applications) and enterprisey. Then I didn’t tried Heroku for somewhat reason but instead moved to VPS so this problem became slightly irrelevant. But eventually I’ve found that there is a PaaS with free tier and https (openshift hasn’t had this) and decided to use it for some projects.

Preparations

First of all, install CLI utility from this page. For Windows version, earlier than 10, it’s possible (probably) to use generic CloudFoundry utility

manifest.yml

---
applications:
- name: myappname
random-route: true
instances: 1
memory: 64M

What does this all means?

---

It’s not placeholder, it’s required marker in manifest.yml

name

(Obviously) name of your application, must be unique among your apps. If you haven’t created app with such name in web interface, it’ll be created automatically on push and also it’ll be used as prefix of application hostname (see also random-route)

random-route

Honestly, I haven’t used it with false, but I’m sure it defines if app will use hostname like myappname-sudden-conscription.that-region.mybluemix.net

instances

Also I haven’t used this, but I think it specifies application instances

memory

This parameter obviously specifies maximal amount of memory used. Lite plan has restirction - 256M for all instances.

Procfile

web: python app.py

This describes how will your app be started.

Probably related docs

Related docs

runtime.txt

python-3.6.4

This specifies version of runtime. Utility will warn if you are using obsolete or absent runtime.

requirements.txt

Well, it’s just generic pip requirements. You can produce it with pip freeze > requirements.txt or write by hand.

Services (TBD)

Prepare code

You should use port passed in PORT environment variable (generally, it’s 8080). There will be a test connection to this port during deploy, if connection will fail or time out deployment fails.

Deploy

Run ibmcloud cf push in location where all this files and code located