Skip to content

Commit

Permalink
modernize bootstrap script
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Feb 29, 2024
1 parent c4ff4ec commit 7729495
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,33 @@ OFF='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'

set -e # Prevent any kind of script failures

# if any of the following env vars are set, use them for the APP_ENV value
if [ -n "$APP_ENV" ]; then
export APP_ENV="$APP_ENV"
elif [ -n "$ENV" ]; then
export APP_ENV="$ENV"
elif [ -n "$ENVIRONMENT" ]; then
export APP_ENV="$ENVIRONMENT"
elif [ -n "$RAILS_ENV" ]; then
export APP_ENV="$RAILS_ENV"
elif [ -n "$RACK_ENV" ]; then
export APP_ENV="$RACK_ENV"
fi

# set the working directory to the root of the project
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"

# set the ruby version to the one specified in the .ruby-version file
[ -z "$RBENV_VERSION" ] && export RBENV_VERSION=$(cat "$DIR/.ruby-version")

# set the app environment to development if it's not set
[ -z "$APP_ENV" ] && export APP_ENV="development"

# set the path to include the rbenv shims if they exist
[ -d "/usr/share/rbenv/shims" ] && export PATH=/usr/share/rbenv/shims:$PATH

TRASHDIR=$(mktemp -d /tmp/bootstrap.XXXXXXXXXXXXXXXXX)
Expand All @@ -22,11 +43,12 @@ cleanup() {
trap cleanup EXIT

# Bootstrap gem dependencies.
echo -e "💎 ${BLUE}Installing Gems...${OFF}"
if [ "$APP_ENV" == "production" ]; then
bundle install --path vendor/gems --local --without development
bundle binstubs --all
echo -e "💎 ${BLUE}Installing Gems for ${GREEN}production${BLUE}...${OFF}"
BUNDLE_WITHOUT=development bundle install --local
BUNDLE_WITHOUT=development bundle binstubs --all
else
bundle install --path vendor/gems --local --with development
echo -e "💎 ${BLUE}Installing Gems for ${PURPLE}development${BLUE}...${OFF}"
bundle install --local
bundle binstubs --all
fi
fi

0 comments on commit 7729495

Please sign in to comment.