Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,28 @@ extract_mongo_url() {
}

extract_root_url() {
#echo "Pulling ROOT_URL from VCAP_APPLICATION"
DOMAIN=`echo $VCAP_APPLICATION | $jq '.uris[0]' | sed -e 's/^"//' -e 's/"$//'`
export ROOT_URL="http://$DOMAIN"
#echo "ROOT_URL: $ROOT_URL"
if [ -z "${ROOT_URL}" ]; then
#echo "Pulling ROOT_URL from VCAP_APPLICATION"
DOMAIN=`echo $VCAP_APPLICATION | $jq '.uris[0]' | sed -e 's/^"//' -e 's/"$//'`
export ROOT_URL="http://$DOMAIN"
#echo "ROOT_URL: $ROOT_URL"
fi
}

extract_couchdb_url() {
if [ -z "${COUCHDB_URL}" ]; then
#echo "Pulling COUCHDB_URL from VCAP_SERVICES"
# Find the first service key that contains "cloudant", then grab the 'url' (or 'uri') key beneath it.
export COUCHDB_URL=`echo $VCAP_SERVICES | $jq 'to_entries|map(select(.key|contains("cloudant")))[0]|.value[0].credentials|if .url then .url else .uri end|. // empty'`
fi
}

extract_mongo_url
extract_root_url
extract_couchdb_url

cat <<-YAML
---
default_process_types:
web: MONGO_URL=$MONGO_URL ROOT_URL=$ROOT_URL vendor/node/bin/node deploy/bundle/main.js
web: MONGO_URL=$MONGO_URL COUCHDB_URL=$COUCHDB_URL ROOT_URL=$ROOT_URL vendor/node/bin/node deploy/bundle/main.js
YAML