capistrano-exts 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Guardfile +13 -0
- data/Rakefile +9 -0
- data/capistrano-exts.gemspec +35 -0
- data/examples/php_fpm/deploy/development.rb +121 -0
- data/examples/php_fpm/deploy/production.rb +121 -0
- data/examples/php_fpm/deploy/staging.rb +121 -0
- data/examples/php_fpm/deploy.rb +38 -0
- data/examples/rails_passenger/deploy/development.rb +121 -0
- data/examples/rails_passenger/deploy/production.rb +121 -0
- data/examples/rails_passenger/deploy/staging.rb +121 -0
- data/examples/rails_passenger/deploy.rb +38 -0
- data/examples/rails_reverse_proxy/deploy/development.rb +121 -0
- data/examples/rails_reverse_proxy/deploy/production.rb +121 -0
- data/examples/rails_reverse_proxy/deploy/staging.rb +121 -0
- data/examples/rails_reverse_proxy/deploy.rb +38 -0
- data/lib/capistrano-exts/core_ext/string/filters.rb +12 -0
- data/lib/capistrano-exts/core_ext.rb +10 -0
- data/lib/capistrano-exts/receipts/base.rb +22 -0
- data/lib/capistrano-exts/receipts/contao.rb +81 -0
- data/lib/capistrano-exts/receipts/functions.rb +55 -0
- data/lib/capistrano-exts/receipts/git.rb +37 -0
- data/lib/capistrano-exts/receipts/god.rb +30 -0
- data/lib/capistrano-exts/receipts/multistage.rb +90 -0
- data/lib/capistrano-exts/receipts/mysql.rb +214 -0
- data/lib/capistrano-exts/receipts/rails.rb +45 -0
- data/lib/capistrano-exts/receipts/servers/db_server.rb +19 -0
- data/lib/capistrano-exts/receipts/servers/web_server/apache.rb +55 -0
- data/lib/capistrano-exts/receipts/servers/web_server/nginx.rb +81 -0
- data/lib/capistrano-exts/receipts/servers/web_server.rb +112 -0
- data/lib/capistrano-exts/receipts/servers.rb +51 -0
- data/lib/capistrano-exts/receipts/unicorn.rb +27 -0
- data/lib/capistrano-exts/receipts.rb +17 -0
- data/lib/capistrano-exts/servers/utils/erb.rb +16 -0
- data/lib/capistrano-exts/servers/utils/variables.rb +25 -0
- data/lib/capistrano-exts/servers/web_server/nginx.rb +20 -0
- data/lib/capistrano-exts/servers/web_server.rb +69 -0
- data/lib/capistrano-exts/templates/multistage.rb +118 -0
- data/lib/capistrano-exts/templates/web_servers/nginx.conf.erb +95 -0
- data/lib/capistrano-exts/version.rb +12 -0
- data/lib/capistrano-exts.rb +14 -0
- data/spec/rendered_templates/nginx_php_fpm.conf +58 -0
- data/spec/requests/nginx_spec.rb +38 -0
- data/spec/servers/web_server/nginx_spec.rb +179 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/factories.rb +1 -0
- metadata +220 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'bundler' do
|
5
|
+
watch('Gemfile')
|
6
|
+
watch(/^.+\.gemspec/)
|
7
|
+
end
|
8
|
+
|
9
|
+
guard 'rspec', version: 2 do
|
10
|
+
watch(%r{^spec/.+_spec\.rb$})
|
11
|
+
watch(%r{^lib/capistrano-exts/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
12
|
+
watch('spec/spec_helper.rb') { "spec/" }
|
13
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "capistrano-exts/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "capistrano-exts"
|
7
|
+
s.version = Capistrano::Extensions::Version::STRING.dup
|
8
|
+
s.authors = ["Wael Nasreddine"]
|
9
|
+
s.email = ["wael.nasreddine@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/Extensions/capistrano-exts"
|
11
|
+
s.summary = %q{Handy extensions for Capistrano}
|
12
|
+
s.description = s.summary
|
13
|
+
|
14
|
+
s.rubyforge_project = "capistrano-exts"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# Run-time dependencies
|
22
|
+
s.add_dependency('capistrano', '>=2.8.0')
|
23
|
+
s.add_dependency('i18n', '>=0.6.0')
|
24
|
+
s.add_dependency('activesupport', '>=3.1.0')
|
25
|
+
|
26
|
+
# Development dependencies
|
27
|
+
s.add_development_dependency('rspec', '>=2.6.0')
|
28
|
+
s.add_development_dependency('mocha', '>=0.2.12')
|
29
|
+
s.add_development_dependency('factory_girl', '>=2.0.5')
|
30
|
+
s.add_development_dependency('faker19', '>=1.0.5')
|
31
|
+
s.add_development_dependency('guard', '>=0.6.2')
|
32
|
+
s.add_development_dependency('guard-bundler', '>=0.1.3')
|
33
|
+
s.add_development_dependency('guard-rspec', '>=0.4.3')
|
34
|
+
s.add_development_dependency('growl_notify', '0.0.1')
|
35
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# DEVELOPMENT-specific deployment configuration
|
2
|
+
# please put general deployment config in config/deploy.rb
|
3
|
+
|
4
|
+
# Here you can set the server which you would like to, each server
|
5
|
+
# each role can have multiple servers, each server defined as user@server.com:port
|
6
|
+
# => port can be omiped and it defaults to 22
|
7
|
+
role :web, 'root@example_dev_web.com:22'
|
8
|
+
role :app, 'root@example_dev_app.com:22'
|
9
|
+
role :db, 'root@example_dev_db.com:22', primary: true
|
10
|
+
|
11
|
+
# The project's branch to use
|
12
|
+
# Uncomment and edit this if you're using git, for other SCM's please refer
|
13
|
+
# to capistrano's documentation
|
14
|
+
set :branch, "master"
|
15
|
+
|
16
|
+
# Use sudo ?
|
17
|
+
set :use_sudo, false
|
18
|
+
|
19
|
+
# Define deployments options
|
20
|
+
set :deploy_to, "/home/vhosts/#{application}"
|
21
|
+
set :deploy_via, :remote_cache
|
22
|
+
set :logs_path, "#{deploy_to}/logs"
|
23
|
+
set :public_path, -> { "#{current_path}/public" }
|
24
|
+
|
25
|
+
# Keep only the last 5 releases
|
26
|
+
set :keep_releases, 5
|
27
|
+
|
28
|
+
# Using RVM? Set this to the ruby version/gemset to use
|
29
|
+
set :rvm_ruby_string, "1.9.2"
|
30
|
+
|
31
|
+
# Mysql credentials
|
32
|
+
set :mysql_credentials_file, -> { "#{deploy_to}/.mysql_password"}
|
33
|
+
set :mysql_credentials_host_regex, /hostname: (.*)$/o
|
34
|
+
set :mysql_credentials_host_regex_match, 1
|
35
|
+
set :mysql_credentials_user_regex, /username: (.*)$/o
|
36
|
+
set :mysql_credentials_user_regex_match, 1
|
37
|
+
set :mysql_credentials_pass_regex, /password: (.*)$/o
|
38
|
+
set :mysql_credentials_pass_regex_match, 1
|
39
|
+
set :mysql_root_credentials_file, "/root/.mysql_password"
|
40
|
+
set :mysql_root_credentials_host_regex, /hostname: (.*)$/o
|
41
|
+
set :mysql_root_credentials_host_regex_match, 1
|
42
|
+
set :mysql_root_credentials_user_regex, /username: (.*)$/o
|
43
|
+
set :mysql_root_credentials_user_regex_match, 1
|
44
|
+
set :mysql_root_credentials_pass_regex, /password: (.*)$/o
|
45
|
+
set :mysql_root_credentials_pass_regex_match, 1
|
46
|
+
|
47
|
+
#############
|
48
|
+
# Web server
|
49
|
+
#
|
50
|
+
|
51
|
+
# Which web server to use?
|
52
|
+
# valid options: :nginx and :apache
|
53
|
+
set :web_server_app, :nginx
|
54
|
+
|
55
|
+
# Server specific configurations
|
56
|
+
# Uncomment as necessary, default option are as follow
|
57
|
+
# set :nginx_init_path, '/etc/init.d/nginx'
|
58
|
+
# set :apache_init_path, '/etc/init.d/apache2'
|
59
|
+
|
60
|
+
# Absolute path to this application's web server configuration
|
61
|
+
# This gem suppose that you are already including files from the folder you're placing
|
62
|
+
# the config file in, if not the application won't be up after deployment
|
63
|
+
set :web_conf_file, -> { "/etc/nginx/#{fetch(:stage).to_s}/#{fetch :application}.conf" }
|
64
|
+
|
65
|
+
# Which port does the server runs on ?
|
66
|
+
set :web_server_listen_port, 80
|
67
|
+
|
68
|
+
# What is the application url ?
|
69
|
+
# THis is used for Virtual Hosts
|
70
|
+
set :application_url, %w(example.com www.example.com)
|
71
|
+
|
72
|
+
# What are the names of the indexes
|
73
|
+
set :web_server_indexes, %w(index.php index.html)
|
74
|
+
|
75
|
+
# HTTP Basic Authentifications
|
76
|
+
# Uncomment this if you would like to add HTTP Basic authentifications,
|
77
|
+
#
|
78
|
+
# Change the 'web_server_auth_file' to the absolute path of the htpasswd file
|
79
|
+
# web_server_auth_credentials is an array of user/password hashes, you can use
|
80
|
+
# gen_pass(length) in a Proc to generate a new password as shown below
|
81
|
+
#
|
82
|
+
set :web_server_auth_file, -> { "/etc/nginx/htpasswds/#{fetch :application}.crypt" }
|
83
|
+
set :web_server_auth_credentials, [
|
84
|
+
{user: 'user1', password: 'pass1'},
|
85
|
+
{user: 'user2', password: -> { gen_pass(8) } },
|
86
|
+
]
|
87
|
+
|
88
|
+
# Enable mode rewrite ?
|
89
|
+
set :web_server_mod_rewrite, true
|
90
|
+
|
91
|
+
# Which server mode to operate on?
|
92
|
+
# Valid options:
|
93
|
+
#
|
94
|
+
# For Nginx:
|
95
|
+
# => :rails_reverse_proxy, :rails_passenger, :php_fpm
|
96
|
+
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
+
# => :rails_passenger runs rails apps
|
98
|
+
# => :php_fpm is used to deliver websites written using PHP
|
99
|
+
#
|
100
|
+
# For Apache
|
101
|
+
# =>
|
102
|
+
set :web_server_mode, :php_fpm
|
103
|
+
|
104
|
+
# Server mode specific configurations
|
105
|
+
# Uncomment and edit the one depending on the enabled mode
|
106
|
+
# php_fpm settings
|
107
|
+
# => On which host, php-fpm is running ?
|
108
|
+
set :php_fpm_host, 'localhost'
|
109
|
+
# => Which port ?
|
110
|
+
set :php_fpm_port, '9000'
|
111
|
+
|
112
|
+
# reverse_proxy settings (Unicorn for example)
|
113
|
+
# => On which host the proxy is running ?
|
114
|
+
# set :reverse_proxy_server_address, 'localhost'
|
115
|
+
# => On which port ?
|
116
|
+
# set :reverse_proxy_server_port, 45410
|
117
|
+
# => What is the path to the socket file
|
118
|
+
# set :reverse_proxy_socket, -> { "#{shared_path}/sockets/unicorn.sock"}
|
119
|
+
|
120
|
+
#
|
121
|
+
#############
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# DEVELOPMENT-specific deployment configuration
|
2
|
+
# please put general deployment config in config/deploy.rb
|
3
|
+
|
4
|
+
# Here you can set the server which you would like to, each server
|
5
|
+
# each role can have multiple servers, each server defined as user@server.com:port
|
6
|
+
# => port can be omiped and it defaults to 22
|
7
|
+
role :web, 'root@example_prod_web.com:22'
|
8
|
+
role :app, 'root@example_prod_app.com:22'
|
9
|
+
role :db, 'root@example_prod_db.com:22', primary: true
|
10
|
+
|
11
|
+
# The project's branch to use
|
12
|
+
# Uncomment and edit this if you're using git, for other SCM's please refer
|
13
|
+
# to capistrano's documentation
|
14
|
+
set :branch, "production"
|
15
|
+
|
16
|
+
# Use sudo ?
|
17
|
+
set :use_sudo, false
|
18
|
+
|
19
|
+
# Define deployments options
|
20
|
+
set :deploy_to, "/home/vhosts/#{application}"
|
21
|
+
set :deploy_via, :remote_cache
|
22
|
+
set :logs_path, "#{deploy_to}/logs"
|
23
|
+
set :public_path, -> { "#{current_path}/public" }
|
24
|
+
|
25
|
+
# Keep only the last 5 releases
|
26
|
+
set :keep_releases, 5
|
27
|
+
|
28
|
+
# Using RVM? Set this to the ruby version/gemset to use
|
29
|
+
set :rvm_ruby_string, "1.9.2"
|
30
|
+
|
31
|
+
# Mysql credentials
|
32
|
+
set :mysql_credentials_file, -> { "#{deploy_to}/.mysql_password"}
|
33
|
+
set :mysql_credentials_host_regex, /hostname: (.*)$/o
|
34
|
+
set :mysql_credentials_host_regex_match, 1
|
35
|
+
set :mysql_credentials_user_regex, /username: (.*)$/o
|
36
|
+
set :mysql_credentials_user_regex_match, 1
|
37
|
+
set :mysql_credentials_pass_regex, /password: (.*)$/o
|
38
|
+
set :mysql_credentials_pass_regex_match, 1
|
39
|
+
set :mysql_root_credentials_file, "/root/.mysql_password"
|
40
|
+
set :mysql_root_credentials_host_regex, /hostname: (.*)$/o
|
41
|
+
set :mysql_root_credentials_host_regex_match, 1
|
42
|
+
set :mysql_root_credentials_user_regex, /username: (.*)$/o
|
43
|
+
set :mysql_root_credentials_user_regex_match, 1
|
44
|
+
set :mysql_root_credentials_pass_regex, /password: (.*)$/o
|
45
|
+
set :mysql_root_credentials_pass_regex_match, 1
|
46
|
+
|
47
|
+
#############
|
48
|
+
# Web server
|
49
|
+
#
|
50
|
+
|
51
|
+
# Which web server to use?
|
52
|
+
# valid options: :nginx and :apache
|
53
|
+
set :web_server_app, :nginx
|
54
|
+
|
55
|
+
# Server specific configurations
|
56
|
+
# Uncomment as necessary, default option are as follow
|
57
|
+
# set :nginx_init_path, '/etc/init.d/nginx'
|
58
|
+
# set :apache_init_path, '/etc/init.d/apache2'
|
59
|
+
|
60
|
+
# Absolute path to this application's web server configuration
|
61
|
+
# This gem suppose that you are already including files from the folder you're placing
|
62
|
+
# the config file in, if not the application won't be up after deployment
|
63
|
+
set :web_conf_file, -> { "/etc/nginx/#{fetch(:stage).to_s}/#{fetch :application}.conf" }
|
64
|
+
|
65
|
+
# Which port does the server runs on ?
|
66
|
+
set :web_server_listen_port, 80
|
67
|
+
|
68
|
+
# What is the application url ?
|
69
|
+
# THis is used for Virtual Hosts
|
70
|
+
set :application_url, %w(example.com www.example.com)
|
71
|
+
|
72
|
+
# What are the names of the indexes
|
73
|
+
set :web_server_indexes, %w(index.php index.html)
|
74
|
+
|
75
|
+
# HTTP Basic Authentifications
|
76
|
+
# Uncomment this if you would like to add HTTP Basic authentifications,
|
77
|
+
#
|
78
|
+
# Change the 'web_server_auth_file' to the absolute path of the htpasswd file
|
79
|
+
# web_server_auth_credentials is an array of user/password hashes, you can use
|
80
|
+
# gen_pass(length) in a Proc to generate a new password as shown below
|
81
|
+
#
|
82
|
+
# set :web_server_auth_file, -> { "/etc/nginx/htpasswds/#{fetch :application}.crypt" }
|
83
|
+
# set :web_server_auth_credentials, [
|
84
|
+
# {user: 'user1', password: 'pass1'},
|
85
|
+
# {user: 'user2', password: -> { gen_pass(8) } },
|
86
|
+
# ]
|
87
|
+
|
88
|
+
# Enable mode rewrite ?
|
89
|
+
set :web_server_mod_rewrite, true
|
90
|
+
|
91
|
+
# Which server mode to operate on?
|
92
|
+
# Valid options:
|
93
|
+
#
|
94
|
+
# For Nginx:
|
95
|
+
# => :rails_reverse_proxy, :rails_passenger, :php_fpm
|
96
|
+
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
+
# => :rails_passenger runs rails apps
|
98
|
+
# => :php_fpm is used to deliver websites written using PHP
|
99
|
+
#
|
100
|
+
# For Apache
|
101
|
+
# =>
|
102
|
+
set :web_server_mode, :php_fpm
|
103
|
+
|
104
|
+
# Server mode specific configurations
|
105
|
+
# Uncomment and edit the one depending on the enabled mode
|
106
|
+
# php_fpm settings
|
107
|
+
# => On which host, php-fpm is running ?
|
108
|
+
set :php_fpm_host, 'localhost'
|
109
|
+
# => Which port ?
|
110
|
+
set :php_fpm_port, '9000'
|
111
|
+
|
112
|
+
# reverse_proxy settings (Unicorn for example)
|
113
|
+
# => On which host the proxy is running ?
|
114
|
+
# set :reverse_proxy_server_address, 'localhost'
|
115
|
+
# => On which port ?
|
116
|
+
# set :reverse_proxy_server_port, 45410
|
117
|
+
# => What is the path to the socket file
|
118
|
+
# set :reverse_proxy_socket, -> { "#{shared_path}/sockets/unicorn.sock"}
|
119
|
+
|
120
|
+
#
|
121
|
+
#############
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# DEVELOPMENT-specific deployment configuration
|
2
|
+
# please put general deployment config in config/deploy.rb
|
3
|
+
|
4
|
+
# Here you can set the server which you would like to, each server
|
5
|
+
# each role can have multiple servers, each server defined as user@server.com:port
|
6
|
+
# => port can be omiped and it defaults to 22
|
7
|
+
role :web, 'root@example_staging_web.com:22'
|
8
|
+
role :app, 'root@example_staging_app.com:22'
|
9
|
+
role :db, 'root@example_staging_db.com:22', primary: true
|
10
|
+
|
11
|
+
# The project's branch to use
|
12
|
+
# Uncomment and edit this if you're using git, for other SCM's please refer
|
13
|
+
# to capistrano's documentation
|
14
|
+
set :branch, "staging"
|
15
|
+
|
16
|
+
# Use sudo ?
|
17
|
+
set :use_sudo, false
|
18
|
+
|
19
|
+
# Define deployments options
|
20
|
+
set :deploy_to, "/home/vhosts/#{application}"
|
21
|
+
set :deploy_via, :remote_cache
|
22
|
+
set :logs_path, "#{deploy_to}/logs"
|
23
|
+
set :public_path, -> { "#{current_path}/public" }
|
24
|
+
|
25
|
+
# Keep only the last 5 releases
|
26
|
+
set :keep_releases, 5
|
27
|
+
|
28
|
+
# Using RVM? Set this to the ruby version/gemset to use
|
29
|
+
set :rvm_ruby_string, "1.9.2"
|
30
|
+
|
31
|
+
# Mysql credentials
|
32
|
+
set :mysql_credentials_file, -> { "#{deploy_to}/.mysql_password"}
|
33
|
+
set :mysql_credentials_host_regex, /hostname: (.*)$/o
|
34
|
+
set :mysql_credentials_host_regex_match, 1
|
35
|
+
set :mysql_credentials_user_regex, /username: (.*)$/o
|
36
|
+
set :mysql_credentials_user_regex_match, 1
|
37
|
+
set :mysql_credentials_pass_regex, /password: (.*)$/o
|
38
|
+
set :mysql_credentials_pass_regex_match, 1
|
39
|
+
set :mysql_root_credentials_file, "/root/.mysql_password"
|
40
|
+
set :mysql_root_credentials_host_regex, /hostname: (.*)$/o
|
41
|
+
set :mysql_root_credentials_host_regex_match, 1
|
42
|
+
set :mysql_root_credentials_user_regex, /username: (.*)$/o
|
43
|
+
set :mysql_root_credentials_user_regex_match, 1
|
44
|
+
set :mysql_root_credentials_pass_regex, /password: (.*)$/o
|
45
|
+
set :mysql_root_credentials_pass_regex_match, 1
|
46
|
+
|
47
|
+
#############
|
48
|
+
# Web server
|
49
|
+
#
|
50
|
+
|
51
|
+
# Which web server to use?
|
52
|
+
# valid options: :nginx and :apache
|
53
|
+
set :web_server_app, :nginx
|
54
|
+
|
55
|
+
# Server specific configurations
|
56
|
+
# Uncomment as necessary, default option are as follow
|
57
|
+
# set :nginx_init_path, '/etc/init.d/nginx'
|
58
|
+
# set :apache_init_path, '/etc/init.d/apache2'
|
59
|
+
|
60
|
+
# Absolute path to this application's web server configuration
|
61
|
+
# This gem suppose that you are already including files from the folder you're placing
|
62
|
+
# the config file in, if not the application won't be up after deployment
|
63
|
+
set :web_conf_file, -> { "/etc/nginx/#{fetch(:stage).to_s}/#{fetch :application}.conf" }
|
64
|
+
|
65
|
+
# Which port does the server runs on ?
|
66
|
+
set :web_server_listen_port, 80
|
67
|
+
|
68
|
+
# What is the application url ?
|
69
|
+
# THis is used for Virtual Hosts
|
70
|
+
set :application_url, %w(example.com www.example.com)
|
71
|
+
|
72
|
+
# What are the names of the indexes
|
73
|
+
set :web_server_indexes, %w(index.php index.html)
|
74
|
+
|
75
|
+
# HTTP Basic Authentifications
|
76
|
+
# Uncomment this if you would like to add HTTP Basic authentifications,
|
77
|
+
#
|
78
|
+
# Change the 'web_server_auth_file' to the absolute path of the htpasswd file
|
79
|
+
# web_server_auth_credentials is an array of user/password hashes, you can use
|
80
|
+
# gen_pass(length) in a Proc to generate a new password as shown below
|
81
|
+
#
|
82
|
+
# set :web_server_auth_file, -> { "/etc/nginx/htpasswds/#{fetch :application}.crypt" }
|
83
|
+
# set :web_server_auth_credentials, [
|
84
|
+
# {user: 'user1', password: 'pass1'},
|
85
|
+
# {user: 'user2', password: -> { gen_pass(8) } },
|
86
|
+
# ]
|
87
|
+
|
88
|
+
# Enable mode rewrite ?
|
89
|
+
set :web_server_mod_rewrite, true
|
90
|
+
|
91
|
+
# Which server mode to operate on?
|
92
|
+
# Valid options:
|
93
|
+
#
|
94
|
+
# For Nginx:
|
95
|
+
# => :rails_reverse_proxy, :rails_passenger, :php_fpm
|
96
|
+
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
+
# => :rails_passenger runs rails apps
|
98
|
+
# => :php_fpm is used to deliver websites written using PHP
|
99
|
+
#
|
100
|
+
# For Apache
|
101
|
+
# =>
|
102
|
+
set :web_server_mode, :php_fpm
|
103
|
+
|
104
|
+
# Server mode specific configurations
|
105
|
+
# Uncomment and edit the one depending on the enabled mode
|
106
|
+
# php_fpm settings
|
107
|
+
# => On which host, php-fpm is running ?
|
108
|
+
set :php_fpm_host, 'localhost'
|
109
|
+
# => Which port ?
|
110
|
+
set :php_fpm_port, '9000'
|
111
|
+
|
112
|
+
# reverse_proxy settings (Unicorn for example)
|
113
|
+
# => On which host the proxy is running ?
|
114
|
+
# set :reverse_proxy_server_address, 'localhost'
|
115
|
+
# => On which port ?
|
116
|
+
# set :reverse_proxy_server_port, 45410
|
117
|
+
# => What is the path to the socket file
|
118
|
+
# set :reverse_proxy_socket, -> { "#{shared_path}/sockets/unicorn.sock"}
|
119
|
+
|
120
|
+
#
|
121
|
+
#############
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Adding necessary paths
|
2
|
+
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
|
3
|
+
|
4
|
+
#####################
|
5
|
+
## CHANGE AFTER ME ##
|
6
|
+
#####################
|
7
|
+
|
8
|
+
set :application, "example_app"
|
9
|
+
set :repository, "git://github.com/example/example_app.git"
|
10
|
+
set :scm, :git
|
11
|
+
set :git_enable_submodules, 1
|
12
|
+
|
13
|
+
# Stages
|
14
|
+
set :stages, [:development, :staging, :production]
|
15
|
+
set :default_stage, :development
|
16
|
+
|
17
|
+
# Capistrano extensions
|
18
|
+
set :capistrano_extensions, [:multistage, :git, :base, :mysql, :contao, :servers]
|
19
|
+
|
20
|
+
default_run_options[:pty] = true
|
21
|
+
ssh_options[:forward_agent] = true
|
22
|
+
|
23
|
+
##################
|
24
|
+
## DEPENDENCIES ##
|
25
|
+
##################
|
26
|
+
|
27
|
+
after "deploy", "deploy:cleanup" # keeps only last 5 releases
|
28
|
+
|
29
|
+
###########################
|
30
|
+
## DO NOT TOUCH AFTER ME ##
|
31
|
+
###########################
|
32
|
+
|
33
|
+
# Require capistrano-exts
|
34
|
+
require 'capistrano-exts'
|
35
|
+
|
36
|
+
# rvm bootstrap
|
37
|
+
# Comment this if ruby is not installed on the server!
|
38
|
+
# require "rvm/capistrano"
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# DEVELOPMENT-specific deployment configuration
|
2
|
+
# please put general deployment config in config/deploy.rb
|
3
|
+
|
4
|
+
# Here you can set the server which you would like to, each server
|
5
|
+
# each role can have multiple servers, each server defined as user@server.com:port
|
6
|
+
# => port can be omiped and it defaults to 22
|
7
|
+
role :web, 'root@example_dev_web.com:22'
|
8
|
+
role :app, 'root@example_dev_app.com:22'
|
9
|
+
role :db, 'root@example_dev_db.com:22', primary: true
|
10
|
+
|
11
|
+
# The project's branch to use
|
12
|
+
# Uncomment and edit this if you're using git, for other SCM's please refer
|
13
|
+
# to capistrano's documentation
|
14
|
+
set :branch, "master"
|
15
|
+
|
16
|
+
# Use sudo ?
|
17
|
+
set :use_sudo, false
|
18
|
+
|
19
|
+
# Define deployments options
|
20
|
+
set :deploy_to, "/home/vhosts/#{application}"
|
21
|
+
set :deploy_via, :remote_cache
|
22
|
+
set :logs_path, "#{deploy_to}/logs"
|
23
|
+
set :public_path, -> { "#{current_path}/public" }
|
24
|
+
|
25
|
+
# Keep only the last 5 releases
|
26
|
+
set :keep_releases, 5
|
27
|
+
|
28
|
+
# Using RVM? Set this to the ruby version/gemset to use
|
29
|
+
set :rvm_ruby_string, "1.9.2"
|
30
|
+
|
31
|
+
# Mysql credentials
|
32
|
+
set :mysql_credentials_file, -> { "#{deploy_to}/.mysql_password"}
|
33
|
+
set :mysql_credentials_host_regex, /hostname: (.*)$/o
|
34
|
+
set :mysql_credentials_host_regex_match, 1
|
35
|
+
set :mysql_credentials_user_regex, /username: (.*)$/o
|
36
|
+
set :mysql_credentials_user_regex_match, 1
|
37
|
+
set :mysql_credentials_pass_regex, /password: (.*)$/o
|
38
|
+
set :mysql_credentials_pass_regex_match, 1
|
39
|
+
set :mysql_root_credentials_file, "/root/.mysql_password"
|
40
|
+
set :mysql_root_credentials_host_regex, /hostname: (.*)$/o
|
41
|
+
set :mysql_root_credentials_host_regex_match, 1
|
42
|
+
set :mysql_root_credentials_user_regex, /username: (.*)$/o
|
43
|
+
set :mysql_root_credentials_user_regex_match, 1
|
44
|
+
set :mysql_root_credentials_pass_regex, /password: (.*)$/o
|
45
|
+
set :mysql_root_credentials_pass_regex_match, 1
|
46
|
+
|
47
|
+
#############
|
48
|
+
# Web server
|
49
|
+
#
|
50
|
+
|
51
|
+
# Which web server to use?
|
52
|
+
# valid options: :nginx and :apache
|
53
|
+
set :web_server_app, :nginx
|
54
|
+
|
55
|
+
# Server specific configurations
|
56
|
+
# Uncomment as necessary, default option are as follow
|
57
|
+
# set :nginx_init_path, '/etc/init.d/nginx'
|
58
|
+
# set :apache_init_path, '/etc/init.d/apache2'
|
59
|
+
|
60
|
+
# Absolute path to this application's web server configuration
|
61
|
+
# This gem suppose that you are already including files from the folder you're placing
|
62
|
+
# the config file in, if not the application won't be up after deployment
|
63
|
+
set :web_conf_file, -> { "/etc/nginx/#{fetch(:stage).to_s}/#{fetch :application}.conf" }
|
64
|
+
|
65
|
+
# Which port does the server runs on ?
|
66
|
+
set :web_server_listen_port, 80
|
67
|
+
|
68
|
+
# What is the application url ?
|
69
|
+
# THis is used for Virtual Hosts
|
70
|
+
set :application_url, %w(example.com www.example.com)
|
71
|
+
|
72
|
+
# What are the names of the indexes
|
73
|
+
set :web_server_indexes, %w(index.php index.html)
|
74
|
+
|
75
|
+
# HTTP Basic Authentifications
|
76
|
+
# Uncomment this if you would like to add HTTP Basic authentifications,
|
77
|
+
#
|
78
|
+
# Change the 'web_server_auth_file' to the absolute path of the htpasswd file
|
79
|
+
# web_server_auth_credentials is an array of user/password hashes, you can use
|
80
|
+
# gen_pass(length) in a Proc to generate a new password as shown below
|
81
|
+
#
|
82
|
+
set :web_server_auth_file, -> { "/etc/nginx/htpasswds/#{fetch :application}.crypt" }
|
83
|
+
set :web_server_auth_credentials, [
|
84
|
+
{user: 'user1', password: 'pass1'},
|
85
|
+
{user: 'user2', password: -> { gen_pass(8) } },
|
86
|
+
]
|
87
|
+
|
88
|
+
# Enable mode rewrite ?
|
89
|
+
set :web_server_mod_rewrite, true
|
90
|
+
|
91
|
+
# Which server mode to operate on?
|
92
|
+
# Valid options:
|
93
|
+
#
|
94
|
+
# For Nginx:
|
95
|
+
# => :rails_reverse_proxy, :rails_passenger, :php_fpm
|
96
|
+
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
+
# => :rails_passenger runs rails apps
|
98
|
+
# => :php_fpm is used to deliver websites written using PHP
|
99
|
+
#
|
100
|
+
# For Apache
|
101
|
+
# =>
|
102
|
+
set :web_server_mode, :rails_passenger
|
103
|
+
|
104
|
+
# Server mode specific configurations
|
105
|
+
# Uncomment and edit the one depending on the enabled mode
|
106
|
+
# php_fpm settings
|
107
|
+
# => On which host, php-fpm is running ?
|
108
|
+
# set :php_fpm_host, 'localhost'
|
109
|
+
# => Which port ?
|
110
|
+
# set :php_fpm_port, '9000'
|
111
|
+
|
112
|
+
# reverse_proxy settings (Unicorn for example)
|
113
|
+
# => On which host the proxy is running ?
|
114
|
+
# set :reverse_proxy_server_address, 'localhost'
|
115
|
+
# => On which port ?
|
116
|
+
# set :reverse_proxy_server_port, 45410
|
117
|
+
# => What is the path to the socket file
|
118
|
+
# set :reverse_proxy_socket, -> { "#{shared_path}/sockets/unicorn.sock"}
|
119
|
+
|
120
|
+
#
|
121
|
+
#############
|