Skip to content

Commit

Permalink
Try to upgrade Heroku buildpack for Plone 5
Browse files Browse the repository at this point in the history
  • Loading branch information
datakurre committed Apr 16, 2015
1 parent 1b77ace commit 9336c4e
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 5 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
work: python configure_zopeconf.py; bin/instance run test.py
6 changes: 1 addition & 5 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
{
"name": "Plone Mosaic on Heroku",
"description": "A Plone Mosaic preview site hosted on Heroku. Login with admin:secret.",
"description": "A Plone Mosaic technology preview on Heroku. Login with admin:admin.",
"repository": "https://github.com/plone/plone.app.mosaic",
"logo": "http://www.coactivate.org/projects/plone-marketing/plone-logo-guidelines/plone-vertical-logo.png",
"keywords": ["plone", "python", "cms"],
"website": "http://plone.org",
"env": {
"BUILDPACK_URL": "https://github.com/niteoweb/heroku-buildpack-plone",
"BUILDOUT_CFG": "heroku.cfg"
},
"addons": [
"heroku-postgresql:hobby-dev",
"mailgun"
Expand Down
102 changes: 102 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env bash

set -eo pipefail

# Heroku has opinions on indentation, let's respect them
indent() {
sed -u 's/^/ /'
}

BUILD_DIR=$1 # -> temp dir that contains whatever is in the git repo
CACHE_DIR=$2 # -> use this dir for caching between compiles
ENV_DIR=$3 # -> environment variables are stored as files inside here
INSTALL_DIR="$BUILD_DIR/.heroku/vendor/buildout" # -> after buildout is
# finished, copy results to this dir so they get compressed into a Heroku slug
UI_URL=https://launchpad.net/plone/5.0/5.0a2/+download/Plone-5.0a2-UnifiedInstaller.tgz
UI_TARBALL=Plone-5.0a2-UnifiedInstaller.tgz
UI_DIR=Plone-5.0a2-UnifiedInstaller.tgz


# make sure dirs exist
mkdir -p $CACHE_DIR
mkdir -p $INSTALL_DIR

echo "-----> Use build cache"
if [ -d $CACHE_DIR/bin ]; then
echo "Get buildout results from the previous build" | indent
cp -r $CACHE_DIR/bin $BUILD_DIR/
cp -r $CACHE_DIR/eggs $BUILD_DIR/
cp -r $CACHE_DIR/parts $BUILD_DIR/
cp -r $CACHE_DIR/var $BUILD_DIR/
else
echo "Cache empty, let's fix that" | indent
echo "Prime with Unified Installer cache" | indent
curl -OL $UI_URL
echo "Unpacking Installer" | indent
tar xfz $UI_TARBALL
cd $UI_DIR
echo "Unpacking Installer cache" | indent
tar xfj packages/buildout-cache.tar.bz2
echo "Moving cache eggs to build directory" | indent
cp -r buildout-cache/eggs $BUILD_DIR/
echo "Clean up Installer files" | indent
cd ..
rm -rf $UI_TARBALL $UI_DIR

fi

echo "-----> Read BUILDOUT_CFG from env vars, or use default"
if [ -f $ENV_DIR/BUILDOUT_CFG ]; then
export "BUILDOUT_CFG=$(cat $ENV_DIR/BUILDOUT_CFG)"
echo "Found ${BUILDOUT_CFG}" | indent
else
export "BUILDOUT_CFG=heroku.cfg"
echo "Using default: heroku.cfg" | indent
fi

echo "-----> Read BUILDOUT_VERBOSITY from env vars, or use default"
if [ -f $ENV_DIR/BUILDOUT_VERBOSITY ]; then
export "BUILDOUT_VERBOSITY=$(cat $ENV_DIR/BUILDOUT_VERBOSITY)"
echo "Use verbosity: ${BUILDOUT_VERBOSITY}" | indent
else
export "BUILDOUT_VERBOSITY="
echo "Use default buildout verbosity" | indent
fi

echo "-----> Read BOOTSTRAP_PY_URL from env vars, or use default"
if [ -f $ENV_DIR/BOOTSTRAP_PY_URL ]; then
export "BOOTSTRAP_PY_URL=$(cat $ENV_DIR/BOOTSTRAP_PY_URL)"
echo "Use custom bootstrap.py: ${BOOTSTRAP_PY_URL}" | indent
else
export "BOOTSTRAP_PY_URL=http://downloads.buildout.org/2/bootstrap.py"
echo "Use default bootstrap.py: ${BOOTSTRAP_PY_URL}" | indent
fi

cd $BUILD_DIR
echo "-----> Bootstrap buildout"
curl -o bootstrap.py -L "${BOOTSTRAP_PY_URL}"
python bootstrap.py -c $BUILDOUT_CFG
echo "-----> Run bin/buildout -c ${BUILDOUT_CFG} ${BUILDOUT_VERBOSITY}"
bin/buildout -c $BUILDOUT_CFG $BUILDOUT_VERBOSITY

echo "-----> Fix paths in zope.conf"
sed "s|${BUILD_DIR}|/app|" parts/instance/etc/zope.conf > zope.conf.new
mv zope.conf.new parts/instance/etc/zope.conf

echo "-----> Copy results to cache"
cp -r $BUILD_DIR/bin $CACHE_DIR
cp -r $BUILD_DIR/eggs $CACHE_DIR
cp -r $BUILD_DIR/parts $CACHE_DIR
cp -r $BUILD_DIR/var $CACHE_DIR

echo "-----> Copy results to slug"
cp -r $BUILD_DIR/bin $INSTALL_DIR
cp -r $BUILD_DIR/eggs $INSTALL_DIR
cp -r $BUILD_DIR/parts $INSTALL_DIR
cp -r $BUILD_DIR/var $INSTALL_DIR

echo "-----> Copy configure_zopeconf.py script to slug"
curl -OL "https://raw.githubusercontent.com/plone/heroku-buildpack-plone/master/configure_zopeconf.py"
cp -r $BUILD_DIR/configure_zopeconf.py $INSTALL_DIR

echo "Done" | indent
7 changes: 7 additions & 0 deletions bin/detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# bin/detect <build-dir>

BUILD_DIR=$1
[ -f $BUILD_DIR/heroku.cfg ] || exit 1 # fail fast if no heroku.cfg

echo Plone
10 changes: 10 additions & 0 deletions bin/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# bin/release <build-dir>

cat << EOF
---
addons:
- heroku-postgresql:dev
default_process_types:
web: python configure_zopeconf.py; bin/instance console
EOF

0 comments on commit 9336c4e

Please sign in to comment.