The purpose of this article was to address issues I had come across when trying to deploy Ghost to AWS t1.micro instance. The ti.micro instance lacks the memory overhead and cpu priority to properly execute a server-side npm install. This resulted in server build errors including ENOENT.
Download the latest release of Ghost
run npm install --production
verify Ghost runs npm start
If you would like to have persistent storage, download and install ghost-s3-storage. Follow the instructions on creating the directory for Creating the storage module. The next step, we will cover how to configure this using environmental variables.
option_settings: - option_name: NODE_ENV value: production - option_name: URL value: http://domain.com - option_name: IAM_ACCESS_KEY value: AK... - option_name: IAM_SECRET_KEY value: 5..8g - option_name: S3_BUCKET_NAME value: BUCKET NAME - option_name: S3_BUCKET_REGION value: us-east-1 packages: yum: gcc:  gcc-c++:  openssl-devel: 
Second file is created to override some of the deployment processes
files: "/opt/elasticbeanstalk/env.vars" : mode: "000775" owner: root group: users content: | #export lines expose variables to other scripts export NPM_CONFIG_LOGLEVEL=error export NODE_PATH=`ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin "/opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh" : mode: "000775" owner: root group: users content: | #!/bin/bash . /opt/elasticbeanstalk/env.vars #prevent running npm install during appdeploy "/opt/elasticbeanstalk/hooks/configdeploy/pre/50npm.sh" : mode: "000666" owner: root group: users content: | #no need to run npm install during configdeploy
Head on over to Caffeine Coding - Ghost on Elastic Beanstalk pt. 1 and read about setting up IAM Users and an S3 Bucket. Once you have created your bucket, update the environment.config values with the correct
Due to the limits of t1.micro, we have to include all of node_modules during our deploy. The files will need to be zipped and then uploaded into Elastic Beanstalk.
./.ebextensions ./content ./core ./node_modules ./config.js ./Gruntfile.js ./index.js ./npm-shrinkwrap.json ./package.json
In Amazon Elastic Beanstalk, create a new Node.js - Single Instance using RDS. Upload your new ZIP file. The instance should be available.
This was my first NodeJS script deployed to any public cloud. There was a lot of trial/error and lessons learned. In the end, this was the method that finally worked for me. I am now able to update my single instance and experiment with my template and code tweaks.
A big thanks to Caffeine Coding for their article on setting up GhostBlog for AWS. It was both current and very informative.
Here is the code source