A major version change within PHP Composer is currently causing issues with deploys, due to how Chef installs and configures Composer, across multiple EngineYard stacks. We are working to update our Chef recipes to avoid the problem and have come up with an overlay solution in the mean time.
Current Solution
This only applies to our supported stacks v5 (Gentoo) and v6 (Ubuntu) and will by default install composer version 1.10.6.
v5 solution
- Create the following folder structures under cookbooks:
php/recipes/
php/templates/default/
- Create composer.rb under php/recipes/ - php/recipes/composer.rb
- Inside composer.rb place the following:
# Report to Cloud dashboard
ey_cloud_report "processing php composer.rb" do
message "processing php - composer"
end
node['dna']['engineyard']['environment']['apps'].each do |app_data|
app_env_vars = fetch_environment_variables(app_data)
app_env_vars.each do |ev|
if ev[:name] =~ /^EY_COMPOSER/
custom_composer = ev[:value]
template "/tmp/composer-install.sh" do
owner node["owner_name"]
group node["owner_name"]
mode "0644"
source "composer.erb"
variables({
:user => node.engineyard.environment.ssh_username,
:composer => custom_composer
})
end
end
end
end
template "/tmp/composer-install.sh" do
owner node["owner_name"]
group node["owner_name"]
mode "0644"
source "composer.erb"
variables({
:user => node.engineyard.environment.ssh_username,
:composer => ""
})
not_if { ::File.exists?("/tmp/composer-install.sh") }
end
execute "install composer" do
command "sh /tmp/composer-install.sh && rm /tmp/composer-install.sh"
end
cookbook_file "/usr/bin/composer" do
owner node["owner_name"]
group node["owner_name"]
mode 0755
source "composer.sh"
backup 0
end
- Create composer.erb under php/templates/default/ - php/templates/default/composer.erb
- Inside composer.erb place the following:
EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', '/tmp/composer-setup.php');")"
CUSTOM_COMPOSER=<%= @composer %>
mkdir /usr/lib/php_composer
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm /tmp/composer-setup.php
exit 1
fi
if [ ! -z "$CUSTOM_COMPOSER" ]; then php -d allow_url_fopen=On /tmp/composer-setup.php --version=$CUSTOM_COMPOSER --install-dir=/usr/lib/php_composer; else php -d allow_url_fopen=On /tmp/composer-setup.php --version=1.10.6 --install-dir=/usr/lib/php_composer; fi
chown -R <%= @user %>:<%= @user %> /usr/lib/php_composer
chmod -R 755 /usr/lib/php_composer
rm /tmp/composer-setup.php
- To install a custom version please set an environmental variable.
- Go to Environment Variables under the environment
- Enter the name EY_COMPOSER and the value to your preferred version
- Press apply on the environment.
v6 solution
- Create the following folder structures under cookbooks:
php/recipes/
php/templates/default/
- Create composer.rb under php/recipes/ - php/recipes/composer.rb
- Inside composer.rb place the following:
# Report to Cloud dashboard
ey_cloud_report "processing php composer.rb" do
message "processing php - composer"
end
custom_composer = fetch_env_var(node, 'EY_COMPOSER') || ""
template "/tmp/composer-install.sh" do
owner node["owner_name"]
group node["owner_name"]
mode "0644"
source "composer.erb"
variables({
:user => node.engineyard.environment.ssh_username,
:composer => custom_composer
})
end
execute "install composer" do
command "sh /tmp/composer-install.sh && rm /tmp/composer-install.sh"
end
cookbook_file "/usr/bin/composer" do
owner node["owner_name"]
group node["owner_name"]
mode 0755
source "composer.sh"
backup 0
end
- Create composer.erb under php/templates/default/ - php/templates/default/composer.erb
- Inside composer.erb place the following:
EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', '/tmp/composer-setup.php');")"
CUSTOM_COMPOSER=<%= @composer %>
mkdir /usr/lib/php_composer
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm /tmp/composer-setup.php
exit 1
fi
if [ ! -z "$CUSTOM_COMPOSER" ]; then php -d allow_url_fopen=On /tmp/composer-setup.php --version=$CUSTOM_COMPOSER --install-dir=/usr/lib/php_composer; else php -d allow_url_fopen=On /tmp/composer-setup.php --version=1.10.6 --install-dir=/usr/lib/php_composer; fi
chown -R <%= @user %>:<%= @user %> /usr/lib/php_composer
chmod -R 755 /usr/lib/php_composer
rm /tmp/composer-setup.php
- To install a custom version please set an environmental variable.
- Go to Environment Variables under the environment
- Enter the name EY_COMPOSER and the value to your preferred version
- Press apply on the environment.
Comments
Article is closed for comments.