Skip to content

Instantly share code, notes, and snippets.

@mihaiserban
Created March 15, 2019 21:25
Show Gist options
  • Save mihaiserban/63a1102daabba8ce333d4c550b97c76c to your computer and use it in GitHub Desktop.
Save mihaiserban/63a1102daabba8ce333d4c550b97c76c to your computer and use it in GitHub Desktop.
deploy Next.JS on AWS Elastic Beanstalk using YARN as package manager
node_modules
# .ebextensions/01-yarn.config
# More info: https://davidcalhoun.me/writing/using-yarn-on-elastic-beanstalk thanks to @david_calhoun
files:
/opt/elasticbeanstalk/hooks/appdeploy/pre/41_install_yarn.sh:
mode: "000775"
owner: root
group: root
content: |
#!/bin/bash
wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo;
curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -;
yum -y install yarn;
/opt/elasticbeanstalk/hooks/appdeploy/pre/51_install_packages.sh:
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
app="$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)";
cd "${app}";
yarn install --production=false;
# .circleci/config.yml
version: 2
jobs:
deploy_aws_production:
# This is a directory where all your repo content will be placed.
# Name is not that important at this case.
working_directory: ~/app
# Docker environment where we gonna run our build deployment scripts
docker:
- image: circleci/node:8.11
steps:
- checkout
# !!! This installs AWS Elastic Beanstalk CLI 'awsebcli' !!!
- run:
name: Installing deployment dependencies
working_directory: /
command: |
sudo apt-get -y -qq update
sudo apt-get install python-pip python-dev build-essential
sudo pip install awsebcli==3.14.11
# !!! This runs a deployment
- run:
name: Deploying
command: eb deploy MY_EB_APP_ENVIRONMENT
workflows:
version: 2
deploy_aws_production:
jobs:
- deploy_aws_production:
filters:
branches:
only: master
# .elasticbeanstalk/config.yml
branch-defaults:
master:
environment: MY_EB_APP_ENVIRONMENT
global:
application_name: MY_EB_APP_NAME
default_ec2_keyname: EC2_KEYNAME
default_platform: Node.js running on 64bit Amazon Linux/4.8.1
default_region: MY_REGION
sc: git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment