Skip to content

Instantly share code, notes, and snippets.

@mirstan
Forked from fightingtheboss/configuration.yml
Created January 12, 2016 05:48
Show Gist options
  • Save mirstan/8419950562926b271d0f to your computer and use it in GitHub Desktop.
Save mirstan/8419950562926b271d0f to your computer and use it in GitHub Desktop.
An Amazon Elastic Beanstalk configuration file for a Meteor project. This file needs to be saved in the .ebconfiguration/ directory at the root of your project. Deployed with `git aws.push`. Replace MONGO_URL with the URL to your MongoDB instance (I use MongoHQ).
packages:
yum:
git: []
files:
/opt/elasticbeanstalk/hooks/appdeploy/pre/51install_meteor.sh:
mode: "000755"
user: root
group: root
encoding: plain
content: |
#!/usr/bin/env bash
echo !!! Setting up METEOR dependencies
export PATH=$PATH:/usr/local/bin
echo !!! Set PATH: $PATH
ln -s /opt/elasticbeanstalk/node-install/node-v0.8.21-linux-x64/bin/node /usr/local/bin/node
ln -s /opt/elasticbeanstalk/node-install/node-v0.8.21-linux-x64/bin/node-waf /usr/local/bin/node-waf
ln -s /opt/elasticbeanstalk/node-install/node-v0.8.21-linux-x64/bin/npm /usr/local/bin/npm
echo !!! Installing Meteor
export HOME=/home/ec2-user
curl https://install.meteor.com | sh
echo !!! Installing Meteorite
npm install -g meteorite
echo !!! Creating app bundle
cd /tmp/deployment/application
mrt bundle bundle.tgz
tar xfz bundle.tgz
rm -rf bundle.tgz
cd /usr/local/bin
rm mrt npm node-waf node
container_commands:
01_nginx_worker_processes:
command: "sed -i 's/^\s*\(worker_processes\s*\)\d*.*$/\14;/' /tmp/deployment/config/#etc#nginx#nginx.conf"
02_nginx_worker_rlimit:
command: "sed -i '/^\(\(\s*\)worker_processes\s*\)\d*.*$/a worker_rlimit_nofile 8192;' /tmp/deployment/config/#etc#nginx#nginx.conf"
03_nginx_worker_connections:
command: "sed -i 's/^\(\s*worker_connections\s*\)\d*.*$/\14096;/' /tmp/deployment/config/#etc#nginx#nginx.conf"
04_nginx_keepalive_timeout:
command: "sed 's/^\(\s*keepalive_timeout\s*\)\d*.*$/\130;/' /tmp/deployment/config/#etc#nginx#nginx.conf"
05_nginx_gzip:
command: |
sed '/upstream/i \
gzip on;\
gzip_comp_level 6;\
gzip_vary on;\
gzip_min_length 1000;\
gzip_proxied any;\
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;\
gzip_buffers 16 8k;\
' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
06_nginx_static:
command: |
sed '/\s*location\s*\/.*/i \
location ~ ^/(images/|img/|javascript/|js/|css/|stylesheets/|font/|fonts/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico) {\
root /var/app/current/bundle/static;\
access_log off;\
expires max;\
}\
\
location ~* \.(js|css)$ {\
root /var/app/current/bundle/static_cacheable;\
access_log off;\
expires max;\
}\
' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
option_settings:
- option_name: ROOT_URL
value: http://pegleg.it
- option_name: MONGO_URL
value: mongodb://<user>:<password>@<mongo-server:port>/<db-name>
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeCommand
value: node bundle/main.js
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeVersion
value: 0.8.21
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: GzipCompression
value: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment