From 772949510668ebe7bccc80be29cc955b01bc8f72 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Wed, 28 Feb 2024 22:21:21 -0700 Subject: [PATCH] modernize bootstrap script --- script/bootstrap | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index bcba6fa..3cd5402 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -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) @@ -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 \ No newline at end of file +fi