1
votes

I am trying to deploy a node.js react based isomorphic application using a Dockerfile linked up to Elastic Beanstalk.

When I run my docker build locally I am able to do so successfully. I have noticed however that the npm install command is taking a fair amount of time to complete.

When trying to deploy the application using the eb deploy command it is pretty much crashing the Amazon service or I get an error like this:

ERROR: Timed out while waiting for command to Complete

My guess is that this is down to my node_modules folder being 300MB big. I have also tried adding an artifact declaration into the config.yml file and deploying that way but get the same error.

Is there a best practice way of deploying a node application to AWS Beanstalk or is the best way to manually setup an EC2 instance and relying on Code Commit git hooks?

My Dockerfile is below:

FROM node:argon 
ADD package.json /tmp/package.json
RUN npm config set registry https://registry.npmjs.org/
RUN npm set progress=false
RUN cd /tmp && npm install --silent
RUN mkdir -p /usr/src/app && cp -a /tmp/node_modules /usr/src/app

WORKDIR /usr/src/app
ADD . /usr/src/app

EXPOSE 8000

CMD npm run build && npm run start

...and this is my config.yml file:

branch-defaults:
  develop:
    environment: staging
  master:
    environment: production
global:
  application_name: website-2016
  default_ec2_keyname: key-pair
  default_platform: 64bit Amazon Linux 2015.09 v2.0.6 running Docker 1.7.1
  default_region: eu-west-1
  profile: eb-cli
  sc: git
1

1 Answers

1
votes
  1. You should change your platform to a more current one (I'm using docker 1.9.1, and there might be newer versions)
  2. I'm using an image from docker hub to deploy my apps into beanstalk. I build them using our CI servers and then run a deploy command that pulls the image from docker hub. This can save you a lot of build errors (and build time) and is actually more in touch with the Docker philosophy of immutable infrastructure.
  3. 300MB for node_modules is not small but should present no problem. We deploy this size of dependencies and code regularly.