|
files: |
|
# Make the appropriate directories |
|
"/opt/elasticbeanstalk/hooks/appdeploy/pre/020_bootstrap.sh": |
|
mode: "000755" |
|
owner: root |
|
group: root |
|
content: | |
|
#!/usr/bin/env bash |
|
# /opt/elasticbeanstalk/hooks/appdeploy/pre/01a_bootstrap.sh |
|
|
|
. $(/opt/elasticbeanstalk/bin/get-config container -k support_dir)/envvars |
|
|
|
# LOCAL VARIABLES |
|
export EB_CONFIG_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user) |
|
export EB_CONFIG_APP_BASE=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)/../ |
|
export EB_CONFIG_APP_ONDECK=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir) |
|
export EB_CONFIG_APP_SUPPORT=$(/opt/elasticbeanstalk/bin/get-config container -k app_asset_dir)/../ |
|
|
|
# Create directories in the application ondeck directory |
|
mkdir -p $EB_CONFIG_APP_ONDECK/vendor $EB_CONFIG_APP_ONDECK/public $EB_CONFIG_APP_ONDECK/tmp |
|
# Create directories in the support directory |
|
mkdir -p $EB_CONFIG_APP_SUPPORT/vendor_bundle $EB_CONFIG_APP_SUPPORT/assets |
|
# Remove the log directory to use support directory |
|
rm -rf $EB_CONFIG_APP_ONDECK/log |
|
# Set the vendor directory properly |
|
chmod go-w $EB_CONFIG_APP_ONDECK/vendor |
|
# Set the tmp directory properly |
|
chmod 777 $EB_CONFIG_APP_ONDECK/tmp |
|
|
|
# Simlink those directories |
|
ln -s $EB_CONFIG_APP_SUPPORT/vendor_bundle $EB_CONFIG_APP_ONDECK/vendor/bundle |
|
ln -sf $EB_CONFIG_APP_SUPPORT/assets $EB_CONFIG_APP_ONDECK/public |
|
ln -sf $EB_CONFIG_APP_SUPPORT/pids $EB_CONFIG_APP_ONDECK/tmp/pids |
|
ln -sf $EB_CONFIG_APP_SUPPORT/logs $EB_CONFIG_APP_ONDECK/log |
|
|
|
# Add log files |
|
touch $EB_CONFIG_APP_ONDECK/log/$RACK_ENV.log |
|
touch $EB_CONFIG_APP_ONDECK/log/cron_log.log |
|
touch $EB_CONFIG_APP_ONDECK/log/cron_error.log |
|
|
|
# Change ownership of the Application Base Directory |
|
chown -h $EB_CONFIG_APP_USER:$EB_CONFIG_APP_USER -R $EB_CONFIG_APP_BASE |
|
|
|
true |
|
encoding: plain |
|
# Bundle install using deployment |
|
"/opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install_deployment.sh": |
|
mode: "000755" |
|
owner: root |
|
group: root |
|
content: | |
|
#!/usr/bin/env bash |
|
|
|
. $(/opt/elasticbeanstalk/bin/get-config container -k support_dir)/envvars |
|
. $(/opt/elasticbeanstalk/bin/get-config container -k script_dir)/use-app-ruby.sh |
|
|
|
export EB_CONFIG_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user) |
|
export EB_CONFIG_APP_ONDECK=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir) |
|
|
|
cd $EB_CONFIG_APP_ONDECK |
|
if [ -f Gemfile ]; then |
|
echo "running 'bundle install --deployment' with Gemfile:" |
|
cat Gemfile |
|
|
|
if [ -d $EB_CONFIG_APP_ONDECK/vendor/cache ]; then |
|
bundle install --local --deployment |
|
chown -h -R $EB_CONFIG_APP_USER:$EB_CONFIG_APP_USER $EB_CONFIG_APP_ONDECK/vendor/cache |
|
# Incase there is a gem that is missing from the cache |
|
bundle install --deployment |
|
else |
|
bundle install --deployment |
|
fi |
|
|
|
if [ $? != 0 ]; then |
|
echo "ERROR: bundle install failed!" |
|
exit 1 |
|
else |
|
echo "bundle install succeeded" |
|
fi |
|
else |
|
echo "no Gemfile found! Skipping bundle install stage!" |
|
fi |
|
|
|
if [ -f Gemfile.lock ]; then |
|
echo "encountered a Gemfile.lock, setting proper permissions" |
|
chown -h $EB_CONFIG_APP_USER:$EB_CONFIG_APP_USER Gemfile.lock |
|
else |
|
echo "no Gemfile.lock file found, so no permissions to set on it" |
|
fi |
|
|
|
true |
|
encoding: plain |
|
commands: |
|
# Backups the existing bundle command |
|
01_backup_existing_bundle_command: |
|
test: test -f /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh |
|
cwd: /opt/elasticbeanstalk/hooks/appdeploy/pre |
|
command: mv 10_bundle_install.sh 10_bundle_install.sh.bak |