This purpose of this project is to act as a template for Django applications deployed to Cloud Foundry environments.
- Clone project and navigate to root directory where the project was cloned.
mkdir /Users/$(whoami)/Dev/
cd /Users/$(whoami)/Dev/
git clone https://github.com/rpdedeus/pcfdjango.git
cd pcfdjango
- Create and activate virtualenv for local development
pip install virtualenv
virtualenv ~/.envs/pcfdjango
source ~/.envs/pcfdjango/bin/activate
- Install project dependencies
pip install -r requirements.txt
- Apply database migrations
python manage.py migrate --settings=settings.local
- Run project
python manage.py runserver --settings=settings.local
- Validate project is working
http://localhost:8000/
It is possible to avoid having to pass the settings flag to the manage.py script by using an environment variable. See details here
- Create cloud foundry account
- Download cf cli and follow instructions on the page.
- Login to cf cli
cf login -a https://api.run.pivotal.io
- From the project's root directory, issue the command to push the applications
cf push
cf run-task pcfdjango "python --version"
- Tail logs
cf logs pcfdjango
- Validate app status
View all apps in the current org/space
cf apps
or
View specific app in the current org/space
cf apps pcfdjango
- ssh into container
cf ssh pcfdjango
Each deployment environment should have a different key.
from django.core.management.utils import get_random_secret_key
get_random_secret_key()