capistrano/symfony
Fork: 65 Star: 353 (更新于 2024-11-16 00:56:43)
license: MIT
Language: Ruby .
Capistrano tasks for deploying the Symfony standard edition
最后发布版本: 2.0.0 ( 2019-12-07 23:58:57)
Capistrano::Symfony
Symfony 4 specific tasks for Capistrano v3 (inspired by capifony).
It leverages the following capistrano tasks to deploy a Symfony app
Version information
Version 1.x
This version is built for Symfony 2 and 3.
Go to Version 1 documentation.
Version 2.x
This version is built for Symfony 4.
You are currently on the Version 2 branch.
Installation
Specify your dependencies:
# Gemfile
source 'https://rubygems.org'
gem 'capistrano', '~> 3.11'
gem 'capistrano-symfony', '~> 2.0.0'
Install your dependencies:
bundle install
When capistrano
and capistrano-symfony
is installed. Run the following command
to set up your local files:
cap install
Make Capistrano aware of 'capistrano/symfony'
by requiring capistrano-symfony in your
new Capfile after require "capistrano/deploy"
.
# Capfile
# ...
require "capistrano/symfony"
If you use composer you might want this:
require "capistrano/composer"
Usage
cap staging deploy
cap production deploy
Settings
If you are using a standard Symfony Flex application that follows the best practises
then you do not need to change/add anything to your deploy.rb
other than what is
required from Capistrano.
We do however expose the following settings (shown with default evaluated values)
that can be modified to suit your project. Please refer to lib/capistrano/symfony/defaults.rb
to see exactly how the defaults are set up.
# symfony-standard edition directories
set :bin_path, "bin"
set :config_path, "config"
set :var_path, "var"
set :web_path, "public"
# The next settings are lazily evaluated from the above values, so take care
# when modifying them
set :log_path, "var/log"
set :cache_path, "var/cache"
set :symfony_console_path, "bin/console"
set :symfony_console_flags, "--no-debug"
# asset management
set :assets_install_path, "public"
set :assets_install_flags, '--symlink'
# Share files/directories between releases
set :linked_dirs, ["var/log"]
set :linked_files, []
# To use a .env file:
#set :linked_files, [".env"]
# Set correct permissions between releases, this is turned off by default
set :file_permissions_paths, ["var"]
set :permission_method, false
# Role filtering
set :symfony_roles, :all
set :symfony_deploy_roles, :all
# Add extra environment variables:
set :default_env, {
'APP_ENV' => 'prod'
'SECRET' => 'foobar'
}
Flow
capistrano-symfony hooks into the flow offered by capistrano. It adds to that flow like so
-
symfony:create_cache_dir
-
symfony:set_permissions
-
symfony:cache:warmup
deploy
|__ deploy:starting
| |__ [before]
| | |__ deploy:ensure_stage
| | |__ deploy:set_shared_assets
| |__ deploy:check
|__ deploy:started
|__ deploy:updating
| |__ git:create_release
| |__ deploy:symlink:shared
| |__ symfony:create_cache_dir
| |__ symfony:set_permissions
| |__ symfony:make_console_executable
|__ deploy:updated
| |__ symfony:cache:warmup
|__ deploy:publishing
| |__ deploy:symlink:release
| |__ deploy:restart
|__ deploy:published
|__ deploy:finishing
| |__ deploy:cleanup
|__ deploy:finished
|__ deploy:log_revision
File permissions
Set the permission_method
variable to one of :chmod
, :acl
, or :chgrp
in
your deploy.rb
to handle the common scenario of a web user and the deploy user
being different.
Both will need access to the files/directories such as var/cache
and public/uploads
(if you handle uploads). Set file_permissions_users
to your webserver user
Example:
# deploy.rb
set :permission_method, :acl
set :file_permissions_users, ["nginx"]
set :file_permissions_paths, ["var", "public/uploads"]
Note: Using :acl
requires that setfacl
be available on your deployment target.
Note: If you are getting an error like setfacl: Option -m: Invalid argument near character 3
,
it means that the users in file_permissions_users
do not exist on your deployment
target.
See the symfony documentation and the file permission capistrano plugin for reference.
Integrated common tasks
The following common tasks are available:
-
symfony:assets:install
So you can use them with hooks in your project's deploy.rb
like this:
after 'deploy:updated', 'symfony:assets:install'
before 'deploy:updated', 'symfony:build_bootstrap'
Using the Symfony console
A task wrapping the symfony console is provided, making it easy to create tasks that call console methods.
For example if you have installed the DoctrineMigrationsBundle in your project you may want to run migrations during a deploy.
namespace :deploy do
task :migrate do
symfony_console('doctrine:migrations:migrate', '--no-interaction')
end
end
If you want to execute a command on a host with a given role you can use the Capistrano
on
DSL, additionally using within
from Capistrano will change the directory
namespace :deploy do
task :migrate do
on roles(:db) do
symfony_console('doctrine:migrations:migrate', '--no-interaction')
end
end
end
Using composer
If you use composer you can install capistrano/composer
. Here are some short
instructions. Read more at capistrano/composer.
First run the following command to download the library:
gem install capistrano-composer
Then make sure your Capfile includes the following:
require 'capistrano/composer'
To download the composer.phar executable add the following to your deploy.rb
:
# First define deploy target:
set :deploy_to, "/home/sites/com.example"
# Install composer if it does not exist
SSHKit.config.command_map[:composer] = "php #{shared_path.join("composer.phar")}"
namespace :deploy do
after :starting, 'composer:install_executable'
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
最近版本更新:(数据更新于 2024-09-16 17:16:09)
2019-12-07 23:58:57 2.0.0
2018-09-22 17:10:07 2.0.0-alfa2
2018-09-11 05:02:43 2.0.0-alfa1
2018-09-07 04:54:19 1.0.0
2018-03-06 16:51:18 1.0.0.rc3
2016-03-06 18:44:56 1.0.0.rc2
2016-03-06 18:32:39 1.0.0.rc1
2014-07-29 22:32:45 0.2.0
capistrano/symfony同语言 Ruby最近更新仓库
2024-11-11 23:51:28 docusealco/docuseal
2024-10-25 21:50:52 maybe-finance/maybe
2024-10-15 12:03:41 capistrano/sshkit
2024-10-07 22:52:44 sous-chefs/postgresql
2024-10-06 00:01:30 rails/solid_queue
2024-09-26 23:26:21 dependabot/dependabot-core