Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation/deployment on AWS Elastic Beanstalk issues (solved) #1122

Closed
joxws opened this issue Mar 19, 2018 · 3 comments
Closed

Installation/deployment on AWS Elastic Beanstalk issues (solved) #1122

joxws opened this issue Mar 19, 2018 · 3 comments

Comments

@joxws
Copy link

joxws commented Mar 19, 2018

I had a bunch of fun trying to get my project with canvas@1.6.9 successfully deployed in Elastic Beanstalk. Thought I should share in case it helps anyone.

Two core issues:

  1. Getting all dependencies installed on the EC2 machines that EB deploys. The wiki here describing how to get working in Amazon Linux helped with the package list.
  2. Escalating npm install to use root. (Maybe not the right solution, but early googling led me down this path).
  3. Modifying the permissions of util/has_lib.sh such that EB deployment running under root can execute this file during node-gyp rebuild.

Solution to 2 is to use unsafe perms. In the root of your project, create a file named .npmrc. Contents:

unsafe-perm=true

Solution to 1 & 3 is to use the "extensions" capabilities of EB. In the root of your project, create a folder named .ebextensions.

file 00_yum_install.config

commands:
01installdevtools:
command: "yum groupinstall "Development Tools" -y"
packages:
yum:
cairo: []
cairo-devel: []
giflib-devel: []
libjpeg-turbo-devel: []
pango: []
pango-devel: []

file 01_add_chmod_script.config

files:
/opt/elasticbeanstalk/hooks/appdeploy/pre/21chmod-canvas-haslib.sh:
content: |-
#!/usr/bin/env bash
chmod +x /tmp/deployment/application/node_modules/canvas/util/has_lib.sh
group: root
mode: "000755"
owner: root

Note: use http://www.yamllint.com/ to format correctly and copy/paste from their output - even if they say it is OK - to avoid issues where EB doesn't even run your extensions.

Hope this helps someone!

Symptom if you've fixed 1) but not 2) is below (apologies I didn't save the symptoms when dependencies aren't installed, but they are a similar node-gyp error).

/var/log/eb-activity.log
/bin/sh: ./util/has_lib.sh: Permission denied
gyp: Call to './util/has_lib.sh freetype' returned exit status 126 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/opt/elasticbeanstalk/node-install/node-v8.9.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.9.77-31.58.amzn1.x86_64
gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v8.9.3-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v8.9.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/deployment/application/node_modules/canvas
gyp ERR! node -v v8.9.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@1.6.9 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@1.6.9 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@arthurshen74
Copy link

Super, hats geklappt, danke!!!

@chain-xvi
Copy link

Dude, thanks a lot!

@jobelenus
Copy link

I get this error message, which means it looks like this script is firing "too early" in the hooks timeline. Perhaps it should be just prior to 50?

chmod: cannot access ‘/tmp/deployment/application/node_modules/canvas/util/has_lib.sh’: No such file or directory. 
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/21chmod-canvas-haslib.sh failed

I was getting this error on npm install:

EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/canvas/build' 

Even though I have an .npmrc file with the unsafe-perms=true content, and I also chmod -R ec2-user:ec2-user for the the entire tmp/ tree. Because npm install is running as the ec2-user (to the best of my understanding).

So, all in all, I cannot get this installed on ec2. Any other ideas?

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

No branches or pull requests

5 participants