Skip to content

Instantly share code, notes, and snippets.

@krishamoud
Last active June 3, 2019 11:18
Show Gist options
  • Save krishamoud/4e9d7344ccfe16d9aa6e to your computer and use it in GitHub Desktop.
Save krishamoud/4e9d7344ccfe16d9aa6e to your computer and use it in GitHub Desktop.
Deploy Meteor onto Elastic Beanstalk
option_settings:
- option_name: AWS_SECRET_KEY
value: -------------------------------------------
- option_name: AWS_ACCESS_KEY_ID
value: ------------------------------
- option_name: PORT
value: 8081
- option_name: MONGO_URL
value: mongodb://user:password@endpoint:27017/db
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: ProxyServer
value: nginx
- namespace: aws:elasticbeanstalk:container:nodejs:staticfiles
option_name: /public
value: /public
Bundling commands:
meteor bundle bundle.tgz
mv bundle.tgz ..
cd ..
tar -zxvf bundle.tgz
sudo cp -a bundle/. ../<project_name>-production/bundle/
cd bundle
rm -rf programs/server/node_modules/fibers/
{
"name": "appName",
"version": "0.0.1",
"scripts": {
"start": "node main.js"
},
"dependencies": {
"fibers": "1.0.1",
"forever": "*"
}
}
@JackAdams
Copy link

If you used a Mac to create the archive to upload to EBS and you're getting errors like this: YAML exception: unacceptable character '' (0x0) special characters are not allowed in "<reader>", position 0, you might need to remove the __MACOSX directory that the Mac zipping process produces inside the archive. In the terminal, go to the folder where your Archive.zip file is and type: zip -d Archive.zip __MACOSX/* -- then upload Archive.zip to EBS.

@JackAdams
Copy link

Another problem I encountered was that there was an error if the ROOT_URL wasn't set. Adding this to the app.config file solved the problem:

  - option_name: ROOT_URL
    value: http://appName-env.elasticbeanstalk.com

Or you can just add the ROOT_URL environment property under "Configuration > Software Configuration" on the AWS EBS console if you've already deployed without it set.

@ulerch
Copy link

ulerch commented Dec 16, 2014

Do you have already deployed a Meteor 1.0 version with Elastic Beanstalk? I would be interested to get an update, since the process you described doesn't work anymore (or didn't for me at least). Thanks.

@JackAdams
Copy link

It's not easy right now, but it can be done. Here's the problem: Meteor 1.0.3.1 uses node version 0.10.33 but AWS EBS currently only supports node version 0.10.31.

To overcome this, you need to open bundle/programs/server/boot.js and change line 11 to var MIN_NODE_VERSION = 'v0.10.31';. (Not sure what the possible consequences of doing that are, but I've deployed a fairly large, complex app to EBS using that stunt and didn't notice any problems.)

You'll also need to add a few more dependencies in package.json, like "underscore": "*", "source-map-support": "*", "semver": "*", "bcrypt": "*". (bcrypt is only needed if you've built on a different platform, like a mac, and consequently had to remove the bundle/programs/server/npm/npm-bcrypt directory).

@isAlmogK
Copy link

isAlmogK commented Mar 5, 2015

It would be great Meteor 1.0.3.1 without the workaround

@JacquesRobin
Copy link

  1. No need to run the nmp module demeteorizer? https://www.npmjs.com/package/demeteorizer

  2. Does a meteor app developed on a Windows machine run "as is" when deployed on a Linux machine on an AWS beanstalk?

@whitesidest
Copy link

Does this work with Meteor 1.3? I can't seem to get it working.

@molinto
Copy link

molinto commented Jun 30, 2016

Same here :(

@justindra
Copy link

justindra commented Jul 7, 2016

I've gotten it to work Meteor 1.3. Sort of... It all deploys no problem at all. The trick for me was to run npm install inside of bundle/programs/server folder then remove bcrypt and fibers from node_modules.

Although there are problems with using Meteor.settings, as EBS doesn't allow JSON to be used for the env variables.

The other problem I'm having is none of my subscriptions are working as WebSockets seem to be blocked. I keep receiving the error below.

WebSocket connection to 'ws://app-name.ap-southeast-2.elasticbeanstalk.com/sockjs/173/coo8rji6/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400

@JacquesRobin I developed this on Windows and ran it on Linux on AWS EBS.

@Spiegelberg
Copy link

Spiegelberg commented Jul 8, 2016

@justindra i found a google group here: https://groups.google.com/forum/#!topic/meteor-talk/VxMQzpVFpME they talk about the websocket setup. and there is also a stackoverflow tip for the nginx config that can serve the websocket here:
http://stackoverflow.com/questions/27084124/how-do-i-customize-nginx-on-aws-elastic-beanstalk-to-loadbalance-meteor/27308730#27308730

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment