django-ex/README.md

78 lines
2.5 KiB
Markdown
Raw Normal View History

2015-05-29 17:19:22 +02:00
# Openshift quickstart: Django
This is a [Django](http://www.djangoproject.com) project that you can use as the starting point to develop your own and deploy it on an [OpenShift](https://github.com/openshift/origin) cluster.
2015-05-19 12:18:31 +02:00
It assumes you have access to an existing OpenShift installation.
2015-05-29 17:19:22 +02:00
## What has been done for you
This is a minimal Django 1.8 project. It was created with these steps:
1. Create a virtualenv
2. Manually install Django and other dependencies
3. `pip freeze > requirements.txt`
4. `django-admin startproject project .`
3. Manually update `project/settings.py` to configure `SECRET_KEY`, `DATABASE` and `STATIC_ROOT` entries.
2015-06-01 10:43:14 +02:00
4. `./manage.py startapp welcome`, to create the welcome page's app
2015-05-29 17:19:22 +02:00
## Local development
2015-05-19 12:18:31 +02:00
2015-05-29 17:19:22 +02:00
To run this project in your development machine, follow these steps:
2015-05-19 12:18:31 +02:00
1. (optional) Create and activate a [virtualenv](https://virtualenv.pypa.io/) (you may want to use [virtualenvwrapper](http://virtualenvwrapper.readthedocs.org/)).
2. Fork this repo and clone your fork:
2015-05-29 17:19:22 +02:00
`git clone https://github.com/openshift/django-ex.git`
2015-05-19 12:18:31 +02:00
3. Install dependencies:
2015-05-24 14:06:57 +02:00
`pip install -r requirements.txt`
4. Create a development database:
`./manage.py migrate`
2015-05-19 12:18:31 +02:00
4. If everything is alright, you should be able to start the Django development server:
2015-05-24 14:06:57 +02:00
`./manage.py runserver`
2015-05-19 12:18:31 +02:00
5. Open your browser and go to http://127.0.0.1:8000, you will be greeted with a welcome page.
2015-05-29 17:19:22 +02:00
## Special files in this repository
2015-05-19 12:18:31 +02:00
2015-06-01 12:44:15 +02:00
Apart from the regular files created by Django (`project/*`, `welcome/*`, `manage.py`), this repository contains:
2015-05-29 17:19:22 +02:00
```
2015-06-01 12:44:15 +02:00
.sti/
└── bin/ - scripts used by source-to-image
├── assemble - executed to produce a Docker image with your code and dependencies during build
└── run - executed to start your app during deployment
openshift/ - application templates for OpenShift
scripts/ - helper scripts to automate some tasks
gunicorn_conf.py - configuration for the gunicorn HTTP server
requirements.txt - list of dependencies
2015-05-29 17:19:22 +02:00
```
2015-05-19 12:18:31 +02:00
## Deploying to OpenShift
2015-05-24 14:06:57 +02:00
The file `application-template.json` contains an OpenShift application template that you can add you your OpenShift project with:
2015-05-19 12:18:31 +02:00
2015-05-24 14:06:57 +02:00
* `osc create -f application-template.json`
2015-05-19 12:18:31 +02:00
2015-05-24 14:06:57 +02:00
Now you can browse to your OpenShift web console and create a new app from the 'django-quickstart' template.
After adjusting your preferences (or accepting the defaults), your application will be built and deployed.
2015-05-19 12:18:31 +02:00
2015-05-24 14:06:57 +02:00
You will probably want to set the `GIT_REPOSITORY` parameter to point to your fork.
2015-05-29 17:19:22 +02:00
## Data persistence
[TODO]