Skip to content

Instantly share code, notes, and snippets.

@bookmebus
Created November 12, 2018 14:47
Show Gist options
  • Save bookmebus/adbed4d2e80810cb5f1652e5f549d844 to your computer and use it in GitHub Desktop.
Save bookmebus/adbed4d2e80810cb5f1652e5f549d844 to your computer and use it in GitHub Desktop.
Elasticbeanstalk rails 5.2.5 with reactjs, react-rails, yarn and puma
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_yarn.sh" :
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
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
. $EB_SCRIPT_DIR/use-app-ruby.sh
# yarn install
cd $EB_APP_STAGING_DIR
yarn
# mkdir /home/webapp
mkdir -p /home/webapp
chown webapp:webapp /home/webapp
chmod 700 /home/webapp
# https://stackoverflow.com/questions/48798846/deploy-rails-react-app-with-webpacker-gem-on-aws-elastic-beanstalk
commands:
# 01_install_yarn:
# command: "sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo && curl --silent --location https://rpm.nodesource.com/setup_6.x | sudo bash - && sudo yum install yarn -y"
# 02_download_nodejs:
# command: curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
# 03_install_nodejs:
# command: yum -y install nodejs
01_node_get:
# run this command from /tmp directory
cwd: /tmp
# flag -y for no-interaction installation
command: 'sudo curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -'
02_node_install:
# run this command from /tmp directory
cwd: /tmp
command: 'sudo yum -y install nodejs'
03_yarn_get:
# run this command from /tmp directory
cwd: /tmp
# don't run the command if yarn is already installed (file /usr/bin/yarn exists)
test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
# command: 'sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo'
command: 'sudo curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo'
04_yarn_install:
# run this command from /tmp directory
cwd: /tmp
test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
command: 'sudo yum -y install yarn'
packages:
yum:
htop: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment