johnhamelink
8/26/2015 - 11:05 AM

deploy_production.sh

#!/usr/bin/env bash

#ssh -t emerald@emerald-beta.scottishgreens.org.uk "/srv/emerald/bin/deploy.sh"
DEPLOY_USER="root"
APP_NAME="emerald"
ENV_FILE="../src/.env.production"
DEPENDS="-d nodejs"
EXCLUDES="-x .git -x *.log"
VERSION="-v $(git rev-parse --short HEAD)"

# Install FPM
gem install fpm

cd ../src

mkdir -p ../init

# Retrieve all gems and deposit them in src/vendor/bundle
bundle package --all
bundle install --local

# Export upstart scripts to src/vendor/init,

bundle exec foreman export upstart \
  -u $DEPLOY_USER \
  -l /var/log \
  -a $APP_NAME \
  -d /var/www/${APP_NAME} \
  -f Procfile \
  -e $ENV_FILE \
  ../init

cd ..

# Build debian package
fpm -n $APP_NAME \
    -s dir \
    -t deb \
    -a all \
    -m "<jenkins@greens.scot>" \
    -C src \
    $EXCLUDES \
    $DEPENDS \
    $VERSION \
    .=/var/www/${APP_NAME} \
    ../init=/etc