Skip to content

Latest commit

 

History

History
119 lines (78 loc) · 2.07 KB

README.md

File metadata and controls

119 lines (78 loc) · 2.07 KB

pcfdjango

This purpose of this project is to act as a template for Django applications deployed to Cloud Foundry environments.

Running locally

  1. 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
  1. Create and activate virtualenv for local development
pip install virtualenv
virtualenv ~/.envs/pcfdjango
source ~/.envs/pcfdjango/bin/activate
  1. Install project dependencies
pip install -r requirements.txt
  1. Apply database migrations
python manage.py migrate --settings=settings.local
  1. Run project
python manage.py runserver --settings=settings.local
  1. Validate project is working
http://localhost:8000/

Apply DJANGO_SETTINGS_MODULE environment variable (Optional)

It is possible to avoid having to pass the settings flag to the manage.py script by using an environment variable. See details here

Pre-Deployment

  1. Create cloud foundry account
  2. Download cf cli and follow instructions on the page.

Deployment

  1. Login to cf cli
cf login -a https://api.run.pivotal.io
  1. From the project's root directory, issue the command to push the applications
cf push

Maintenance / management

Run Tasks

Docs

cf run-task pcfdjango "python --version"

Troubleshooting

  • 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

Misc

Generate a new SECRET_KEY

Each deployment environment should have a different key.

from django.core.management.utils import get_random_secret_key
get_random_secret_key()