If you don't know, now you know: Media Goblin is an open-source, decentralized media sharing app that runs on the web. Openshift is Red Hat's open-source Platform as a Service. You can use it for free to get web apps running really quickly. For example, follow this guide to deploy Media Goblin in about six commands.
You'll need git, ssh, an Openshift account, and the Openshift client tools installed. If you need to set up an Openshift account, you can do it here. Here we go:
Deploy the quickstart:
rhc app create -a mediagoblin -t diy-0.1
rhc-ctl-app -a mediagoblin -e add-postgresql-8.4
cd mediagoblin
git remote add upstream -m master git://github.com/stenwt/mediagoblin-quickstart-openshift.git
git pull -s recursive -X theirs upstream master
git push
When this completes, you should see something like:
remote: -> Initializing main mediagoblin tables... done.
remote: -> Initializing media type "mediagoblin.media_types.image"... done.
To ssh://ac2b5ec0accc495182b27eb6211c839f@mg-sten.rhcloud.com/~/git/mg.git/
a3bd0b1..e91441b master -> master
Browse to your app, it should be running!
Wait one second, though, that was 6 commands, and I said six-ish. That's because we still have to create a user. Grab the ssh url from the output above:
ssh ac2b5ec0accc495182b27eb6211c839f@mg-sten.rhcloud.com
cd $OPENSHIFT_REPO_DIR
. setpath
./bin/gmg adduser
Username: test
Password:
Email: test@test.com
Ok, now you're really done. Log into your Media Goblin and have a look. There's a bunch more here, but feel free to skip it.
Building the quickstart (mostly for my own reference)
rhc-create-app -a mediagoblin -t diy-0.1
rhc-ctl-app -a mediagoblin -e add-postgresql-8.4
cd mediagoblin/
git remote add upstream -m master git://gitorious.org/mediagoblin/mediagoblin.git
git pull -s recursive -X theirs upstream master
Media Goblin includes a fairly extensive .gitignore; pare it down to just:
*.pyc
*.pyo
*~
*.swp
Create ./setpath:
export PYTHON_EGG_CACHE=$OPENSHIFT_TMP_DIR/.python-eggs
export PYTHONPATH="$OPENSHIFT_REPO_DIR/lib/python2.6/site-packages:$OPENSHIFT_REPO_DIR"
edit .openshift/action_hooks/build:
if [ -f $OPENSHIFT_REPO_DIR/rebuild ]
then
cd $OPENSHIFT_REPO_DIR/
. setpath
virtualenv .
./bin/easy_install lxml
./bin/easy_install pil
./bin/easy_install psycopg2
./bin/python setup.py develop
fi
Send up the source to Openshift to be built:
touch rebuild; git add rebuild setpath
git commit -am "push unconfigured source to rebuild"
git push
This will take a while, go make yourself a sandwich.
When it's done, copy the built files from openshift back to your local working copy:
rsync -rv --delete --size-only --exclude=.git* --exclude=*pyc mediagoblin:app-root/repo/ ./
git status should show:
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# bin/
# lib/
# mediagoblin.egg-info/
Add those in:
git add bin lib mediagoblin.egg-info
Remove the rebuild flag file:
git rm rebuild
Fix python path:
grep -r "\#\!/var" * | cut -f 1 -d: | xargs -n1 sed -i "s#\#\!/var.*#\#\!/usr/bin/python#"
edit .openshift/action_hooks/deploy:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/bin/bash
## Where to store uploads:
STORAGE=${OPENSHIFT_DATA_DIR}gmg-public
cd $OPENSHIFT_REPO_DIR/
## MG recommends not editing these files in place
cp paste.ini paste_local.ini
cp mediagoblin.ini mediagoblin_local.ini
## if not already done, add a paster config
if [ $(grep -c openshift paste_local.ini) -ne 1 ]
then
echo "[server:openshift]" >> paste_local.ini
echo "use = egg:Paste#http" >> paste_local.ini
echo "host = $OPENSHIFT_INTERNAL_IP" >> paste_local.ini
echo "port = 8080" >> paste_local.ini
else ## if the config is there, update the IP address
sed "/\[server:openshift\]/{N;N;s/host.*/host\ =\ $OPENSHIFT_INTERNAL_IP/}" paste_local.ini
fi
## stuff the SQL config into mediagoblin.ini
sed -i "s#^.*sql_engine\ =\ postgresql.*#sql_engine\ =\ $OPENSHIFT_POSTGRESQL_DB_URL$OPENSHIFT_APP_NAME#" mediagoblin_local.ini
## point the GMG file storage at the data dir, so it doesn't get wiped out on every git push
[ -d $OPENSHIFT_DATA_DIR/gmg-public ] || mkdir -p $OPENSHIFT_DATA_DIR/gmg-public
sed -i "s#^base_dir.*public#base_dir\ =\ $STORAGE#" mediagoblin_local.ini
sed -i "s#^document_root.*public/#document_root\ =\ $STORAGE#" paste_local.ini
|
edit .openshift/action_hooks/post_deploy:
1 2 3 4 5 6 | #!/bin/bash
cd $OPENSHIFT_REPO_DIR/
## apply database config
. setpath
virtualenv .
./bin/gmg dbupdate
|
edit .openshift/action_hooks/start:
1 2 3 4 5 | #!/bin/bash
cd $OPENSHIFT_REPO_DIR/
. setpath
virtualenv .
./lazyserver.sh --server-name=openshift >> $OPENSHIFT_DIY_LOG_DIR/server.log 2>&1 &
|
edit .openshift/action_hooks/stop:
1 2 3 | #!/bin/bash
ps -ef | awk '/[p]aster/ {print $2}' | xargs -n1 kill
exit 0
|
commit, push, and verify, then push to Github.
