Skip to content

Instantly share code, notes, and snippets.

@connyay
Last active August 29, 2015 14:10
Show Gist options
  • Save connyay/76102b76413588f68d12 to your computer and use it in GitHub Desktop.
Save connyay/76102b76413588f68d12 to your computer and use it in GitHub Desktop.
PencilBlue config for OpenShift
#!/bin/bash
# .openshift/action_hooks/build
# Change home directory (npm puts a lot of cache and tmp directories here)
HOME=$OPENSHIFT_REPO_DIR
cd $OPENSHIFT_REPO_DIR
if [ "$OPENSHIFT_GEAR_UUID"=="$OPENSHIFT_APP_UUID" ]; then
# Main gear - cache node_modules for quicker pushes
mkdir -p "$OPENSHIFT_DATA_DIR"node_modules
ln -s "$OPENSHIFT_DATA_DIR"node_modules node_modules
fi
npm install --loglevel error
var config = {};
var env = process.env;
if (env.NODE_ENV === "production") {
var useMemory = {
"use_memory": true,
"use_cache": false
};
var useMemoryAndCache = {
"use_memory": true,
"use_cache": true
};
// OpenShift config settings
config = {
"siteName": "PencilBlue on OpenShift",
"siteRoot": "http://" + env.OPENSHIFT_GEAR_DNS,
"siteIP": env.OPENSHIFT_NODEDIY_IP,
"sitePort": env.OPENSHIFT_NODEDIY_PORT,
"log_level": "info",
"db": {
"type": "mongo",
"servers": [
env.OPENSHIFT_MONGODB_DB_URL
],
"name": env.OPENSHIFT_APP_NAME,
"writeConcern": 1
},
"cache": {
"fake": true,
"host": "localhost",
"port": 6379
},
"settings": useMemory,
"templates": useMemory,
"plugins": {
"caching": useMemory
}
};
if (env.OPENSHIFT_REDIS_DB_HOST || env.OPENSHIFT_REDIS_HOST) {
// OpenShift Redis config
// ENV vars will have REDIS_DB_* when the app is in a scaled environment
config.cache = {
"host": env.OPENSHIFT_REDIS_DB_HOST || env.OPENSHIFT_REDIS_HOST,
"port": env.OPENSHIFT_REDIS_DB_PORT || env.OPENSHIFT_REDIS_PORT,
"auth_pass": env.OPENSHIFT_REDIS_DB_PASSWORD || env.REDIS_PASSWORD
};
config.settings = useMemoryAndCache;
config.templates = useMemoryAndCache;
config.plugins.caching = useMemoryAndCache;
}
if (env.OPENSHIFT_HAPROXY_VERSION) {
// Scaled application
config.cluster = {
"self_managed": false
};
}
} else {
// local dev settings
config = {
"siteName": "PencilBlue Local",
"siteRoot": "http://localhost:8080",
"siteIP": "0.0.0.0",
"sitePort": 8080,
"log_level": "info",
"db": {
"type": "mongo",
"servers": [
"mongodb://localhost:27017/pencilblue/"
],
"name": "pencilblue",
"writeConcern": 1
}
}
}
module.exports = config;
git remote add upstream https://github.com/pencilblue/pencilblue.git
git fetch upstream
git reset --hard upstream/master
curl -O https://gist.githubusercontent.com/connyay/76102b76413588f68d12/raw/config.js
mkdir -p .openshift/action_hooks
curl -o .openshift/action_hooks/build https://gist.githubusercontent.com/connyay/76102b76413588f68d12/raw/build
chmod +x .openshift/action_hooks/build
git add -f config.js && git add -A && git commit -m 'Hello PencilBlue!' && git push origin master -f
echo 'All finished!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment