Start working with a chef and start composer installation during deployment

We plan to deploy several Laravel4 PHP-based applications on Amazon with OpsWorks, which requires a few things:

  • Get code from git
  • Download composer .phar from getcomposer.com
  • Run php composer.phar install
  • Change permissions for several specific folders

I am completely fresh that he comes to the chef, so they are initially looking for a place where you can do the basics of the chef, and then any pointers will be appreciated how to achieve the above tasks.

+5
source share
6 answers

I am not a chef (I usually use Puppet), but try the following:

Git capture code

, wget (. ).

- , . http://docs.opscode.com/resource_deploy.html

deploy_revision "/path/to/application" do
  repo 'ssh://name-of-git-repo/repos/repo.git'
  migrate false
  purge_before_symlink %w{one two folder/three}
  create_dirs_before_symlink []
  symlinks(
    "one"   => "one",
    "two"   => "two",
    "three" => "folder/three"
  )
  before_restart do
    # some Ruby code
  end
  notifies :restart, "service[foo]"
  notifies :restart, "service[bar]"
end

.phar getcomposer.com

wget.

: http://cookingclouds.com/2012/06/23/chef-simple-cookbook-example/

wget , tar . , .

# Run a bash shell -  download and extract composer
bash "install_composer" do
     user "root"
     cwd "/folder/to/extact/to"
     code <<-EOH
       wget http://getcomposer.com/composer.tar.gz
       tar -xzf composer.tar.gz
       chown -R user:group /folder/to/extact/to
     EOH
     not_if "test -d /folder/to/extact/to"
end

php composer.phar install

http://docs.opscode.com/resource_execute.html

execute "composer install" do
  command "php composer.phar install && touch /var/log/.php_composer_installed"
  creates "/var/log/.php_composer_installed"
  action :run
end

, "", .

http://docs.opscode.com/resource.html

directory "/tmp/folder" do
  owner "root"
  group "root"
  mode 0755
  action :create
end

, . - , .

, -, , ( , ). http://docs.opscode.com/search.html

+2

. compose.phar, remote_file , wget bash script.

+2

post-receive git - :

GIT_WORK_TREE=/path/to/your/site
cd /path/to/your/site
curl -sS https://getcomposer.org/installer | php
php composer.phar install
# do your stuff here 

.

0

. , Laravel 4 OpsWorks.

0

composer.phar , $PATH:

remote_file '/usr/bin/composer' do
    source 'http://getcomposer.org/composer.phar'
    mode '0755'
    action :create_if_missing
end
0

Laravel OpsWorks. , ...

, - ? , X- 100% - ?

- - WTF.

Now I have made sure that the code in my project repository will be deployed 100%, as it is. Do not load external modules on the production server.

-1
source

All Articles