Permalink
Browse files

Adding readme

  • Loading branch information...
1 parent 22cda76 commit 09cc800e60263566a53da901689a18b9eafcb299 Mike McGrath committed Aug 4, 2011
Showing with 214 additions and 0 deletions.
  1. +79 −0 .openshift/action_hooks/build
  2. +92 −0 README
  3. 0 data/.gitkeep
  4. 0 libs/.gitkeep
  5. +10 −0 setup.py
  6. +21 −0 wsgi/application
  7. +12 −0 wsgi/static/README
@@ -0,0 +1,79 @@
+#!/bin/bash
+# This is a simple build script, place your post-deploy but pre-start commands
+# in this script. This script gets executed directly, so it could be python,
+# php, ruby, etc.
+
+# Edit the below values, the only required change is DOMAIN_NAME
+# These values are _ONLY_ used at install time.
+DOMAIN_NAME="CHANGEME" # This is required to be set
+DATABASE_NAME="reviewboard"
+DATABASE_TYPE="mysql"
+REVIEWBOARD_ADMIN="admin"
+REVIEWBOARD_ADMIN_PASSWORD="OpenShiftAdmin" # Used only at install time
+REVIEWBOARD_ADMIN_EMAIL="example@example.com"
+export PYTHON_EGG_CACHE="$OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME/tmp/egg_cache"
+
+set -e
+
+if [ $DOMAIN_NAME == "CHANGEME" ]
+then
+ echo 1>&2
+ echo 1>&2
+ echo "IMPORTANT !! IMPORTANT !! IMPORTANT !!" 1>&2
+ echo "DOMAIN_NAME is not set! Please edit this file in your git repo:" 1>&2
+ echo " .openshift/action_hooks/build"
+ echo "Change DOMAIN_NAME to whatever your \$app-\$username.rhcloud.com domain is" 1>&2
+ echo 1>&2
+ echo 1>&2
+ exit 9
+fi
+
+if [ -z $OPENSHIFT_DB_HOST ]
+then
+ echo 1>&2
+ echo 1>&2
+ echo "Could not find mysql database. Please run:" 1>&2
+ echo "rhc-ctl-app -a $OPENSHIFT_APP_NAME -e add-mysql-5.1" 1>&2
+ echo "then make a sample commit (add whitespace somewhere) and re-push" 1>&2
+ echo 1>&2
+ echo 1>&2
+ exit 5
+fi
+
+# Check for db, create if it does not exist
+mysql -u "$OPENSHIFT_DB_USERNAME" --password="$OPENSHIFT_DB_PASSWORD" -h "$OPENSHIFT_DB_HOST" -e "select * from accounts_profile;" reviewboardd > /dev/null 2>&1 || mysqladmin -u "$OPENSHIFT_DB_USERNAME" --password="$OPENSHIFT_DB_PASSWORD" -h "$OPENSHIFT_DB_HOST" create "$DATABASE_NAME"
+
+if [ -d $OPENSHIFT_DATA_DIR$OPENSHIFT_APP_NAME ]
+then
+ rb-site upgrade --noinput $OPENSHIFT_DATA_DIR$OPENSHIFT_APP_NAME/
+else
+ rb-site install --domain-name="$DOMAIN_NAME" \
+ --db-name="$DATABASE_NAME" \
+ --db-type="$DATABASE_TYPE" \
+ --db-host="$OPENSHIFT_DB_HOST" \
+ --db-user="$OPENSHIFT_DB_USERNAME" \
+ --db-pass="$OPENSHIFT_DB_PASSWORD" \
+ --site-root="/" \
+ --media-url="static/media/" \
+ --admin-user="$REVIEWBOARD_ADMIN" \
+ --admin-password="$REVIEWBOARD_ADMIN_PASSWORD" \
+ --admin-email="$REVIEWBOARD_ADMIN_EMAIL" \
+ --web-server-type="apache" \
+ --python-loader=wsgi \
+ --cache-type="file" \
+ --cache-info="file:///tmp/reviewboard_cache" \
+ --noinput $OPENSHIFT_DATA_DIR$OPENSHIFT_APP_NAME/
+
+ echo 1>&2
+ echo 1>&2
+ echo "ReviewBoard installation complete! You may now log in to https://$DOMAIN_NAME/" 1>&2
+ echo "ReviewBoard Admin Username: $REVIEWBOARD_ADMIN" 1>&2
+ echo "ReviewBoard Admin Password: $REVIEWBOARD_ADMIN_PASSWORD" 1>&2
+ echo "Don't forget to change your password from the default!" 1>&2
+ echo 1>&2
+ echo 1>&2
+fi
+
+# Setup symlinks to properly display static content
+ln -s ../../../data/$OPENSHIFT_APP_NAME/htdocs/media/ $OPENSHIFT_REPO_DIR/wsgi/static/media
+ln -s ../../../data/$OPENSHIFT_APP_NAME/htdocs/errordocs/ $OPENSHIFT_REPO_DIR/wsgi/static/errordocs
View
92 README
@@ -0,0 +1,92 @@
+OpenShift - ReviewBoard
+=====================
+
+This repository is designed to be used with http://openshift.redhat.com/
+applications. To use, just follow the quickstart below.
+
+
+Quickstart
+==========
+
+1) Create an account at http://openshift.redhat.com/
+2) Create a wsgi-3.2 application and attach mysql to it:
+ $ rhc-create-app -a reviewboard -t wsgi-3.2
+ $ rhc-ctl-app -a reviewboard -e add-mysql-5.1
+3) Add this upstream reviewboard repo
+ $ cd reviewboard
+ $ git remote add upstream -m master git://github.com/openshift/reviewboard-example.git
+ $ git pull -s recursive -X theirs upstream master
+4) Edit .openshift/action_hooks/build and set DOMAIN_NAME to your reviewboard-$DOMNAME.rhcloud.com domain
+ $ vi .openshift/action_hooks/build
+5) Then push the repo upstream
+ $ git push
+6) That's it, you can now checkout your application at:
+ http://reviewboard-$yourlogin.rhcloud.com
+7) Default Admin Username: Admin
+ Default Password: OpenShiftAdmin
+
+Updates
+=======
+
+In order to update or upgrade to the latest reviewboard, you'll need to re-pull
+and re-push.
+
+1) Pull from upstream:
+ $ cd reviewboard/
+ $ git pull -s recursive -X theirs upstream master
+2) Push the new changes upstream
+ $ git push
+
+Note: When new releases are pushed from the reviewboard dev team, your app will
+automatically download them on your next git push.
+
+
+Repo layout
+===========
+wsgi/ - Externally exposed wsgi code goes
+libs/ - Additional libraries
+data/ - For not-externally exposed wsgi code
+setup.py - Standard setup.py, specify deps here
+../data - For persistent data (also env var: OPENSHIFT_DATA_DIR)
+.openshift/action_hooks/build - Script that gets run every push, just prior to
+ starting your app
+
+
+Environment Variables
+=====================
+
+OpenShift Express provides several environment variables to reference for ease
+of use. The following list are some common variables but far from exhaustive:
+
+ os.environ['OPENSHIFT_APP_NAME'] - Application name
+ os.environ['OPENSHIFT_APP_DIR'] - Application dir
+ os.environ['OPENSHIFT_DATA_DIR'] - For persistent storage (between pushes)
+ os.environ['OPENSHIFT_TMP_DIR'] - Temp storage (unmodified files deleted after 10 days)
+
+When embedding a database using rhc-ctl-app, you can reference environment
+variables for username, host and password:
+
+ os.environ['OPENSHIFT_DB_HOST'] - DB host
+ os.environ['OPENSHIFT_DB_PORT'] - DB Port
+ os.environ['OPENSHIFT_DB_USERNAME'] - DB Username
+ os.environ['OPENSHIFT_DB_PASSWORD'] - DB Password
+
+To get a full list of environment variables, simply add a line in your
+.openshift/action_hooks/build script that says "export" and push.
+
+
+Notes about layout
+==================
+Please leave wsgi, libs and data directories but feel free to create additional
+directories if needed.
+
+Note: Every time you push, everything in your remote repo dir gets recreated
+please store long term items (like an sqlite database) in ../data which will
+persist between pushes of your repo.
+
+
+Notes about setup.py
+====================
+
+Adding deps to the install_requires will have the openshift server actually
+install those deps at git push time.
View
No changes.
View
No changes.
View
@@ -0,0 +1,10 @@
+from setuptools import setup
+
+setup(name='YourAppName',
+ version='1.0',
+ description='OpenShift App',
+ author='Your Name',
+ author_email='example@example.com',
+ url='http://www.python.org/sigs/distutils-sig/',
+ install_requires=['ReviewBoard'],
+ )
View
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+import os, sys
+
+virtenv = os.environ['APPDIR'] + '/virtenv/'
+datadir = os.environ['OPENSHIFT_DATA_DIR']
+appname = os.environ['OPENSHIFT_APP_NAME']
+os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.6/site-packages')
+virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
+try:
+ execfile(virtualenv, dict(__file__=virtualenv))
+except IOError:
+ pass
+
+os.environ['DJANGO_SETTINGS_MODULE'] = "reviewboard.settings"
+os.environ['PYTHON_EGG_CACHE'] = datadir + "/" + appname + "/tmp/egg_cache"
+os.environ['HOME'] = datadir + "/" + appname + "/data"
+
+sys.path = [datadir + '/' + appname + '/conf'] + sys.path
+
+import django.core.handlers.wsgi
+application = django.core.handlers.wsgi.WSGIHandler()
View
@@ -0,0 +1,12 @@
+Public, static content goes here. Users can create rewrite rules to link to
+content in the static dir. For example, django commonly uses /media/
+directories for static content. For example in a .htaccess file in a
+wsgi/.htaccess location, developers could put:
+
+RewriteEngine On
+RewriteRule ^application/media/(.+)$ /static/media/$1 [L]
+
+Then copy the media/* content to yourapp/wsgi/static/media/ and it should
+just work.
+
+Note: The ^application/ part of the URI match is required.

0 comments on commit 09cc800

Please sign in to comment.