visit sample url here : https://patpicha111.eu-gb.cf.appdomain.cloud/onlinecourse/ Learning Objectives Understand how to prepare your Django app for Cloud Foundry Deployment Deploy your app on IBM Cloud Foundry Pre-requisites You will need an IBM Cloud account to do this lab.
$ ibmcloud login -u youremail -p yourpassword
$ ibmcloud cf install
$ ibmcloud target -o yourorg -s yourspace
$ ibmcloud cf domains
wget "#link to download project" or git clone 'HTTP' or open project from local unzip 'file-name.zip' rm 'file-name.zip'
$ibmcloud cf domains $pip3 install -r requirements.txt (you maybe need to update dependensies like $ pip install --upgrade pip )
$ python3 manage.py makemigrations $ python3 manage.py migrate $ python3 manage.py runserver
To serve those static files, we will need another webserver for better load balancing management. Cloud Foundry provides a Staticfile buildpack supported by nginx server
web: gunicorn myproject.wsgi
applications:
- name: onlinecourse <*app name>
routes:
- route: yourhost.us-south.cf.appdomain.cloud <*hostname.domainname> memory: 128M buildpack: python_buildpack
- name: onlinecourse-nginx <*app name.static server>
routes:
- route: yourhost.us-south.cf.appdomain.cloud/static <*hostname.domainname> memory: 128M buildpack: staticfile_buildpack
Find ALLOWED_HOSTS list in myproject/settings.py and append the host using the route entry in manifest.yml
ALLOWED_HOSTS = ['yourhostname.domainname']
$ ibmcloud cf push
Waiting for app to start...
sample url : yluo.us-south.cf.appdomain.cloud/onlinecourse You may also try to access a static file such as yluo.us-south.cf.appdomain.cloud/onlinecourse/static/media/course_images/django.png