Skip to content

Instantly share code, notes, and snippets.

@obonyojimmy
Forked from gssbzn/yarm.config
Created October 30, 2018 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obonyojimmy/abc3eb8cb176b0375638997692c9d39e to your computer and use it in GitHub Desktop.
Save obonyojimmy/abc3eb8cb176b0375638997692c9d39e to your computer and use it in GitHub Desktop.
Elastic Beanstalk Rails+Webpacker extension
# Copyright 2018 SwiftComply.com
commands:
01_node_install:
test: "[ `node --version` != 'v8.10.0' ]"
command: "curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -"
02_yarn_repo:
test: "[ ! -f /etc/yum.repos.d/yarn.repo ]"
command: "curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo"
03_yarn_install:
test: "[ ! -x /usr/bin/yarn ]"
command: "yum install -y yarn"
files:
# If this file is edited, it must be removed from EC2 instance prior to deploy.
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_yarn_install.sh" :
mode: "00555"
owner: root
group: root
content: |
#!/usr/bin/env bash
#==============================================================================
# Copyright 2018 SwiftComply.com
#
# This file is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or
# implied.
#==============================================================================
. /opt/elasticbeanstalk/hooks/common.sh
set -xe
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
. $EB_SUPPORT_DIR/envvars
cd $EB_APP_STAGING_DIR
if [ -f package.json ]; then
echo "running 'yarn install' with package.json:"
cat package.json
./bin/yarn install
else
echo "no package.json found! Skipping yarn install stage!"
fi
if [ -f yarn.lock ]; then
echo "encountered a yarn.lock, setting proper permissions"
chown $EB_APP_USER:$EB_APP_USER yarn.lock
else
echo "no yarn.lock file found, so no permissions to set on it"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment