Deploy Your Application

Handling Deployments with Babel

NPM Script

To Deploy

Deploy your app with Babel. This command with compile your server and client javascript separately in temporary folders. It returns a zip file that is ready to use for deployments.
$ npm run build:server

AWS Deployments

You will need an EC2 that is at least a t2.small for your multi-threaded Node server to run. Multi threads require more space than a single thread option. Deploy a t2.micro for a single threaded server. Rails on Node uses 8 threads by default for scale.

How It Works

Bash Script

The npm script runs bash on the build.sh file in your root directory. The scripts starts with a fresh build. It build compiles your server with babel for server side accessible assets in a temporary folder called deploy-src and compiles it into a folder called build. It then builds your assets for production on the client. Then you must transfer all of your non-javascript files into the build directory before it is zipped and destroys all of your temporary build directories. Anything added on should be transferred in this file.

As you build this file needs to be updated

Example of transferring over non-javascript files and folders

# build.sh# all bash commands[14] cp -R ./package.json ./build/package.json[15] cp -R ./app.json ./build/app.json[16] cp -R ./views ./build/views[17] cp -R ./openssl ./build/openssl[18] cp -R ./bootstrap ./build/bootstrap[19] cp -R ./assets/img ./build/assets/img[20] rm -rf ./build/assets/dist[21] cp -R ./assets/dist ./build/assets/dist[22] cp -R ./assets/manifest.json ./build/assets/manifest.json