Hey, I had to put a Meteor app up on Heroku w/o using the “horse” buildpack. I have 3 meteor apps in one git repo, with symlinks sharing code, so horse wasn’t going to pull it.
Anyways, here’s what I did. It took some time to put together so I thought I’d share it. If you’ve done something like that and have lessons to share, comments welcome!
Here’s how I organized it:
~/kittenunicorn-meteor/all - shared code
~/kittenunicorn-meteor/admin - first app
~/kittenunicorn-meteor/borrower - second app
~/kittenunicorn-meteor/broker - third app
~/kittenunicorn-meteor/dist - .gitignored path for built apps
~/kittenunicorn-ops - ops deploy script and settings.json
- Build each app
# Build admin app
# this file is ~/kittenunicorn-meteor/admin/build.sh
# Npm install if not already.
[ ! -d "node_modules" ] && meteor npm install
# Meteor build
meteor build \
--directory ../dist/admin \
--architecture os.linux.x86_64 \
--server-only || exit 1
- Deploy to Heroku
# This script in ~/kittenunicorn-ops along with production settings.json and package.json below
APP="${1:?Missing parameter app: admin, broker, borrower}"
HEROKU_APP=kittenunicorn-$APP
# Configure
heroku features:enable http-session-affinity --app $HEROKU_APP
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs --app $HEROKU_APP
heroku config:set --app $HEROKU_APP \
ROOT_URL=https://app.kittenunicorn.ca \
MONGO_URL="$(heroku config:get MONGODB_URI --app $HEROKU_APP)" \
METEOR_SETTINGS="$(cat settings.json)" \
# Deploy
cp package.json ../kittenunicorn-meteor/dist/$APP
pushd ../kittenunicorn-meteor/dist/$APP
git init
git add --all .
git commit -qam "Deploy $APP"
heroku git:remote --app $HEROKU_APP
git push -f heroku master
popd
This package.json helps Heroku’s standard nodejs buildpack start the Meteor app.
{
"name": "bundle",
"version": "1.0.0",
"description": "This is a Meteor application bundle. It has only one external dependency: Node.js v4.8.4. To run the application:",
"main": "main.js",
"engines": {
"node": "4.8.4",
"npm": "2.15.11"
},
"scripts": {
"heroku-prebuild": "cd bundle/programs/server && npm install -q",
"start": "cd bundle && node main.js"
}
}
Hope this helps someone. Any lessons you’ve learned doing something like this?
Thanks!
Mike