Skip to content

Instantly share code, notes, and snippets.

@chris
Created May 13, 2011 05:55
Show Gist options
  • Save chris/970051 to your computer and use it in GitHub Desktop.
Save chris/970051 to your computer and use it in GitHub Desktop.
Chef recipe to install node.js on Engine Yard AppCloud
#
# Cookbook Name:: nodejs
# Recipe:: default
#
# Build and install node.js
#
if ['app','app_master','solo'].include?(node[:instance_role])
version_tag = "v0.4.8"
source_base_dir = "/data/nodejs"
source_dir = "#{source_base_dir}/#{version_tag}"
install_dir = "/usr/local/bin"
ey_cloud_report "node.js" do
message "Setting up node.js"
end
ey_cloud_report "nodejs" do
message "configuring nodejs #{version_tag}"
end
directory "#{source_base_dir}" do
owner 'root'
group 'root'
mode 0755
recursive true
end
# download nodejs source and checkout specific version
execute "fetch nodejs from GitHub" do
command "git clone https://github.com/joyent/node.git #{source_dir} && cd #{source_dir} && git checkout #{version_tag}"
not_if { FileTest.exists?(source_dir) }
end
# compile nodejs
execute "configure nodejs" do
command "cd #{source_dir} && ./configure"
not_if { FileTest.exists?("#{source_dir}/node") }
end
execute "build nodejs" do
command "cd #{source_dir} && make"
not_if { FileTest.exists?("#{source_dir}/node") }
end
execute "symlink nodejs" do
command "ln -s #{source_dir}/node #{install_dir}"
not_if { FileTest.exists?("#{install_dir}/node") }
end
end
@chris
Copy link
Author

chris commented Jul 24, 2011

cessner, thanks for the comment. I just updated the recipe to the one we currently use. It uses a bit newer (but not the very latest) Node.js version, and fixes some issues with running this if you already had Node installed. This works properly for us on Engine Yard's AppCloud stack, but may or may not elsewhere.

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