capdrupal 0.9.7 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +19 -0
- data/.gitkeep +0 -0
- data/CHANGELOG.md +14 -0
- data/CONTRIBUTING.md +44 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +250 -0
- data/Rakefile +4 -0
- data/capdrupal.gemspec +23 -24
- data/docs/maintainers.md +16 -0
- data/lib/capdrupal.rb +226 -197
- metadata +54 -29
- data/README.markdown +0 -176
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '042712619fa7d2d53940074bc660a4d7694d5fe35cbb1485a4cfddee98985ba9'
|
4
|
+
data.tar.gz: 36af6488a30d9d1614148a2db60ed2b3af2db7b1eb508d09b9d405fa86c8ba30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b40858994b05c1a630a6eb6395e238b0ab714a642e7e4f569ddf5792e7629d89b855d13606523f435628e2ca0c97c47be8b0e14eb59070cd732ab32689684c
|
7
|
+
data.tar.gz: a3bd3657a97322ed2e235db1b6aed11efb573e6a396352e53ecb24a8350c2bc9c0cef94af2faee177283ba791f23f3f8a80bab4f8b98011eab50262fb684fff1
|
data/.gitignore
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
## JetBrains template
|
2
|
+
.idea/
|
3
|
+
|
4
|
+
## Environment normalization:
|
5
|
+
/.bundle/
|
6
|
+
/vendor/bundle
|
7
|
+
/lib/bundler/man/
|
8
|
+
|
9
|
+
Gemfile.lock
|
10
|
+
.ruby-version
|
11
|
+
.ruby-gemset
|
12
|
+
|
13
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
14
|
+
.rvmrc
|
15
|
+
|
16
|
+
## macOS template
|
17
|
+
.DS_Store
|
18
|
+
.AppleDouble
|
19
|
+
.LSOverride
|
data/.gitkeep
ADDED
File without changes
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Capdrupal Changelog
|
2
|
+
|
3
|
+
## 3.0.0 (2020-08-07)
|
4
|
+
- Support for Drupal 8 & Drupal 9
|
5
|
+
- Complete code refactoring
|
6
|
+
|
7
|
+
## 0.11.0 (2016-01-21)
|
8
|
+
- Support for Drupal 8 & Drupal 9
|
9
|
+
|
10
|
+
## 0.10.0 (2015-04-24)
|
11
|
+
- Task `deploy` do not clear cache, revert features, updatedb, etc. For this use `deploy:full` task
|
12
|
+
|
13
|
+
## 0.9.6 (2014-06-14)
|
14
|
+
* Fix capistrano deps
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Developing on Capdrupal
|
2
|
+
|
3
|
+
* Issues should be filed at
|
4
|
+
https://github.com/antistatique/capdrupal/issues
|
5
|
+
* Pull requests can be made against
|
6
|
+
https://github.com/antistatique/capdrupal/pulls
|
7
|
+
|
8
|
+
## 📦 Repositories
|
9
|
+
|
10
|
+
Github repo
|
11
|
+
|
12
|
+
```bash
|
13
|
+
git remote add github https://github.com/antistatique/capdrupal.git
|
14
|
+
```
|
15
|
+
|
16
|
+
## 🔧 Prerequisites
|
17
|
+
|
18
|
+
First of all, you will need to have the following tools installed
|
19
|
+
globally on your environment:
|
20
|
+
|
21
|
+
* ruby
|
22
|
+
* bundle
|
23
|
+
* capistrano
|
24
|
+
* gem
|
25
|
+
|
26
|
+
## 💎 Specify local.capdrupal Ruby gems in your Gemfile
|
27
|
+
|
28
|
+
For local development, you will need to use on your local checkout of `capdrupal`.
|
29
|
+
To achieve this goal, you may update your project `Gemfile` and use `gem "capdrupal", path: "/path/to/capdrupal"`.
|
30
|
+
|
31
|
+
Please **don't do that** as explain here https://rossta.net/blog/how-to-specify-local-ruby-gems-in-your-gemfile.html
|
32
|
+
|
33
|
+
Instead, use the `bundle config local` and declare a new `local.capdrupal` gem:
|
34
|
+
|
35
|
+
```bash
|
36
|
+
bundle config local.capdrupal /path/to/capdrupal
|
37
|
+
```
|
38
|
+
|
39
|
+
Though convenient, using the `:path` option in our Gemfile to point to a local gem elsewhere on our machine sets us
|
40
|
+
up for three potential problems without automated prevention:
|
41
|
+
|
42
|
+
* Committing a nonexistent lookup path on other machines
|
43
|
+
* Failing to point to the correct repository branch
|
44
|
+
* Failing to point to an existing git reference
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Antistatique SA
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
# Capdrupal
|
2
|
+
|
3
|
+
This gem provides a number of tasks which are useful for deploying & managing Drupal projects with [Capistrano](https://github.com/capistrano/capistrano).
|
4
|
+
|
5
|
+
# Capdrupal version
|
6
|
+
|
7
|
+
Capdrupal Gem Version | Branch | Capistrano Version | Drupal Version
|
8
|
+
--------------------- | ------ | ------------------ | --------------
|
9
|
+
0.11.0 | d7 | 2 | 7.x
|
10
|
+
3.x | main | 3.x | 8.x
|
11
|
+
3.x | main | 3.x | 9.x
|
12
|
+
|
13
|
+
## Prerequisites
|
14
|
+
|
15
|
+
By default, Capdrupal will use **Drush** to run every Drupal commands. Therefore, your Drupal project **must** to require
|
16
|
+
`drush/drush`.
|
17
|
+
|
18
|
+
You may add Drush as a dependency using `composer require drush/drush` in your Drupal project. Read more at [drush/drush](https://github.com/drush-ops/drush).
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'capdrupal', '~>8.0'
|
26
|
+
```
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
```shell
|
31
|
+
bundle
|
32
|
+
```
|
33
|
+
|
34
|
+
Or install it yourself if [gems](http://rubygems.org) is installed on your system:
|
35
|
+
|
36
|
+
```shell
|
37
|
+
gem install capdrupal
|
38
|
+
```
|
39
|
+
|
40
|
+
## Configuration
|
41
|
+
|
42
|
+
First, go to your project directory and launch Capistrano.
|
43
|
+
|
44
|
+
```shell
|
45
|
+
cd path/to/your/drupal/project/
|
46
|
+
cap install
|
47
|
+
```
|
48
|
+
|
49
|
+
Capistrano will create the following skeleton
|
50
|
+
|
51
|
+
```
|
52
|
+
.
|
53
|
+
├── Capfile
|
54
|
+
├── config
|
55
|
+
│ └── deploy.rb
|
56
|
+
│ └── deploy
|
57
|
+
│ └── production.rb
|
58
|
+
│ └── staging.rb
|
59
|
+
├── lib
|
60
|
+
│ └── capistrano
|
61
|
+
│ └── tasks
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
Create two files `Capfile` and `config/deploy.rb`. Open `Capfile` and set the dependencies.
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
# Load DSL and set up stages.
|
69
|
+
require 'capistrano/setup'
|
70
|
+
|
71
|
+
# Include default deployment tasks.
|
72
|
+
require 'capistrano/deploy'
|
73
|
+
|
74
|
+
# Composer is needed to install drush on the server.
|
75
|
+
require 'capistrano/composer'
|
76
|
+
|
77
|
+
# Drupal Tasks.
|
78
|
+
require 'capdrupal/capistrano'
|
79
|
+
|
80
|
+
# Load custom tasks from `lib/capistrano/tasks` if you have any defined.
|
81
|
+
Dir.glob('config/capistrano/tasks/*.rake').each { |r| import r }
|
82
|
+
```
|
83
|
+
|
84
|
+
Then, go to `config/deploy.rb` to set the parameters of your project. First you have to define the general information about the user, server and the app himself.
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
set :application, 'application-name'
|
88
|
+
set :repo_url, 'git@github.com:company/application.git'
|
89
|
+
|
90
|
+
server 'ssh.example.org', user: 'username', roles: %w{app db web}
|
91
|
+
```
|
92
|
+
|
93
|
+
The specific Drupal information
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
set :install_composer, true
|
97
|
+
set :install_drush, true
|
98
|
+
|
99
|
+
set :app_path, 'web'
|
100
|
+
set :config_path, 'config/sync'
|
101
|
+
|
102
|
+
# Setup the backup before/after failed strategy.
|
103
|
+
set :backup_path, 'backups'
|
104
|
+
set :keep_backups, 5
|
105
|
+
|
106
|
+
# Link file settings.php
|
107
|
+
set :linked_files, fetch(:linked_files, []).push("#{fetch(:app_path)}/sites/default/settings.php", "drush/drush.yml")
|
108
|
+
|
109
|
+
# Link dirs files and private-files
|
110
|
+
set :linked_dirs, fetch(:linked_dirs, []).push("#{fetch(:app_path)}/sites/default/files")
|
111
|
+
```
|
112
|
+
|
113
|
+
Then, all the others information related to your Git repository or debug level
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
# Default value for :scm is :git
|
117
|
+
set :scm, :git
|
118
|
+
|
119
|
+
# Default value for :log_level is :debug
|
120
|
+
set :log_level, :debug
|
121
|
+
```
|
122
|
+
|
123
|
+
Finally, set the deployment to use the proper Drupal 8 strategy
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
namespace :deploy do
|
127
|
+
# Ensure everything is ready to deploy.
|
128
|
+
after "deploy:check:directories", "drupal:db:backup:check"
|
129
|
+
|
130
|
+
# Backup the database before starting a deployment and rollback on fail.
|
131
|
+
# after :updated, "drupal:db:backup"
|
132
|
+
# before :failed, "drupal:db:rollback"
|
133
|
+
# before :cleanup, "drupal:db:backup:cleanup"
|
134
|
+
|
135
|
+
# Set the maintenance Mode on your Drupal online project when deploying.
|
136
|
+
after :updated, "drupal:maintenance:on"
|
137
|
+
|
138
|
+
# Must updatedb before import configurations, E.g. when composer install new
|
139
|
+
# version of Drupal and need updatedb scheme before importing new config.
|
140
|
+
# This is executed without raise on error, because sometimes we need to do drush config-import before updatedb.
|
141
|
+
after :updated, "drupal:updatedb:silence"
|
142
|
+
|
143
|
+
# Remove the cache after the database update
|
144
|
+
after :updated, "drupal:cache:clear"
|
145
|
+
after :updated, "drupal:config:import"
|
146
|
+
|
147
|
+
# Update the database after configurations has been imported.
|
148
|
+
after :updated, "drupal:updatedb"
|
149
|
+
|
150
|
+
# Clear your Drupal 8 cache.
|
151
|
+
after :updated, "drupal:cache:clear"
|
152
|
+
|
153
|
+
# Disable the maintence on the Drupal project.
|
154
|
+
after :updated, "drupal:maintenance:off"
|
155
|
+
|
156
|
+
# Ensure permissions are properly set.
|
157
|
+
after :updated, "drupal:permissions:recommended"
|
158
|
+
after :updated, "drupal:permissions:writable_shared"
|
159
|
+
|
160
|
+
# Fix the release permissions (due to Drupal restrictive permissions)
|
161
|
+
# before deletting old release.
|
162
|
+
before :cleanup, "drupal:permissions:cleanup"
|
163
|
+
end
|
164
|
+
```
|
165
|
+
|
166
|
+
You may now can configure your `staging.rb` and `production.rb` strategy, has you will certainly deploy on different environment
|
167
|
+
|
168
|
+
```shell
|
169
|
+
vi config/deploy/staging.rb
|
170
|
+
```
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
# staging.example.org
|
174
|
+
set :deploy_to, '/var/www/staging.example.org'
|
175
|
+
|
176
|
+
# set a branch for this release
|
177
|
+
set :branch, 'dev'
|
178
|
+
|
179
|
+
# Map composer and drush commands
|
180
|
+
# NOTE: If stage have different deploy_to
|
181
|
+
# you have to copy those line for each <stage_name>.rb
|
182
|
+
# See https://github.com/capistrano/composer/issues/22
|
183
|
+
SSHKit.config.command_map[:composer] = -> { shared_path.join('composer.phar') }
|
184
|
+
SSHKit.config.command_map[:drush] = -> { release_path.join('vendor/bin/drush') }
|
185
|
+
```
|
186
|
+
|
187
|
+
```shell
|
188
|
+
vi config/deploy/production.rb
|
189
|
+
```
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
# www.example.org
|
193
|
+
set :deploy_to, '/var/www/example.org'
|
194
|
+
|
195
|
+
# set a branch for this release
|
196
|
+
set :branch, 'master'
|
197
|
+
|
198
|
+
# Map composer and drush commands
|
199
|
+
# NOTE: If stage have different deploy_to
|
200
|
+
# you have to copy those line for each <stage_name>.rb
|
201
|
+
# See https://github.com/capistrano/composer/issues/22
|
202
|
+
SSHKit.config.command_map[:composer] = -> { shared_path.join('composer.phar') }
|
203
|
+
SSHKit.config.command_map[:drush] = -> { release_path.join('vendor/bin/drush') }
|
204
|
+
```
|
205
|
+
|
206
|
+
Awesome, your configuration is complete !
|
207
|
+
|
208
|
+
## Usage
|
209
|
+
|
210
|
+
So, after configuration come action ! The first time, you have to run this command with the choosing stage.
|
211
|
+
|
212
|
+
```shell
|
213
|
+
cap [staging|production] deploy:setup
|
214
|
+
```
|
215
|
+
|
216
|
+
In fact, Capistrano create directories and symlink to the targeted server. The `shared` directory contains all shared files of your app who don't need to be change. `Releases` contains the different releases of your app with a number define in `deploy.rb` and finally `current` is the symlink who target the right release.
|
217
|
+
|
218
|
+
```
|
219
|
+
example.org
|
220
|
+
├── current -> /home/example.org/releases/20130527070530
|
221
|
+
├── releases
|
222
|
+
│ ├── 20130527065508
|
223
|
+
│ ├── 20130527065907
|
224
|
+
│ └── 20130527070530
|
225
|
+
└── shared
|
226
|
+
```
|
227
|
+
|
228
|
+
Now, every time you want to deploy your app !
|
229
|
+
|
230
|
+
```
|
231
|
+
cap [staging|production] deploy
|
232
|
+
```
|
233
|
+
|
234
|
+
And if some troubles occur, just launch the rollback command to return to the previous release.
|
235
|
+
|
236
|
+
```
|
237
|
+
cap [staging|production] deploy:rollback
|
238
|
+
```
|
239
|
+
|
240
|
+
You should then be able to proceed as you would usually, you may want to familiarise yourself with the truncated list of tasks, you can get a full list with:
|
241
|
+
|
242
|
+
```
|
243
|
+
cap -T
|
244
|
+
```
|
245
|
+
|
246
|
+
## Credits
|
247
|
+
|
248
|
+
Inspired by [capistrano-drupal](https://github.com/previousnext/capistrano-drupal).
|
249
|
+
|
250
|
+
Made by [Antistatique](https://antistatique.net) who's always looking for new talented developers ! Just mail us on [job@antistatique.net](mailto:job@antistatique.net).
|
data/Rakefile
ADDED
data/capdrupal.gemspec
CHANGED
@@ -1,30 +1,29 @@
|
|
1
|
-
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
2
3
|
|
3
|
-
Gem::Specification.new do |
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'capdrupal'
|
6
|
+
spec.version = '3.0.0'
|
7
|
+
spec.authors = ['Kevin Wenger', 'Yann Lugrin', 'Gilles Doge', 'Toni Fisler', 'Simon Perdrisat', 'Robert Wohleb', 'Kim Pepper']
|
8
|
+
spec.email = ['hello@antistatique.net']
|
9
|
+
|
10
|
+
spec.description = <<-DESC
|
11
|
+
A set of tasks for deploying Drupal 9, Drupal 8 and Drupal 7 projects with Capistrano and the help of Drush.
|
10
12
|
DESC
|
11
|
-
|
13
|
+
spec.summary = 'A set of tasks for deploying and managing Drupal projects with Capistrano'
|
14
|
+
spec.homepage = %q{http://github.com/antistatique/capdrupal/}
|
15
|
+
spec.license = 'MIT'
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
"capdrupal.gemspec",
|
20
|
-
"lib/capdrupal.rb"
|
21
|
-
]
|
22
|
-
s.require_path = 'lib'
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
spec.add_dependency 'capistrano', '~> 3.5'
|
25
|
+
spec.add_dependency 'capistrano-composer', '~> 0.0.6'
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
s.homepage = %q{http://github.com/antistatique/capdrupal/}
|
27
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0.0'
|
30
29
|
end
|
data/docs/maintainers.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Documentation for maintainers
|
2
|
+
|
3
|
+
Since this is a Ruby tool used by PHP programmers it might be a good idea to document
|
4
|
+
some things.
|
5
|
+
|
6
|
+
## Making a release
|
7
|
+
|
8
|
+
Checklist for making a release:
|
9
|
+
|
10
|
+
- Write changelog
|
11
|
+
- Update version number in `capdrupal.gemspec`
|
12
|
+
- Make a [new release with GitHub](https://github.com/antistatique/capdrupal/releases/new)
|
13
|
+
- Build the gem with `gem build capdrupal.gemspec`
|
14
|
+
- Push the gem to rubygems.org: `gem push capdrupal-X.X.X.gem`
|
15
|
+
- Add the `capdrupal-X.X.X.gem` to the GitHub release
|
16
|
+
|
data/lib/capdrupal.rb
CHANGED
@@ -1,257 +1,286 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
_cset :scm, :git
|
13
|
-
_cset :deploy_via, :remote_cache
|
14
|
-
_cset :branch, "master"
|
15
|
-
_cset :git_enable_submodules, true
|
16
|
-
|
17
|
-
_cset :download_drush, false
|
18
|
-
_cset(:drush_cmd) { download_drush ? "#{shared_path}/drush/drush" : "drush" }
|
19
|
-
|
20
|
-
_cset :runner_group, "www-data"
|
21
|
-
_cset :group_writable, false
|
1
|
+
namespace :load do
|
2
|
+
task :defaults do
|
3
|
+
set :app_path, 'web'
|
4
|
+
set :config_path, 'config/sync'
|
5
|
+
set :backup_path, 'backups'
|
6
|
+
set :keep_backups, 5
|
7
|
+
set :enable_modules, []
|
8
|
+
set :disable_modules, []
|
9
|
+
end
|
10
|
+
end
|
22
11
|
|
23
|
-
|
24
|
-
|
25
|
-
|
12
|
+
namespace :drush do
|
13
|
+
desc "Install Drush - only once for bootstraping"
|
14
|
+
task :install do
|
15
|
+
on roles(:app) do
|
16
|
+
within shared_path do
|
17
|
+
execute :composer, 'require drush/drush'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
26
22
|
|
27
|
-
|
28
|
-
_cset :remote_tmp_dir, "/tmp"
|
23
|
+
namespace :drupal do
|
29
24
|
|
30
|
-
|
31
|
-
|
25
|
+
desc 'Run any drush command'
|
26
|
+
task :drush do
|
27
|
+
ask(:drush_command, "Drush command you want to run (eg. 'cache-clear css-js'). Type 'help' to have a list of avaible drush commands.")
|
28
|
+
on roles(:app) do
|
29
|
+
within release_path.join(fetch(:app_path)) do
|
30
|
+
execute :drush, fetch(:drush_command)
|
31
|
+
end
|
32
|
+
end
|
32
33
|
end
|
33
34
|
|
34
|
-
|
35
|
+
namespace :db do
|
36
|
+
desc "Revert the current release drupal site database backup"
|
37
|
+
task :rollback do
|
38
|
+
on roles(:app) do
|
39
|
+
within release_path.join(fetch(:app_path)) do
|
40
|
+
backup = "#{shared_path}/#{fetch(:backup_path)}/#{fetch(:stage)}_#{release_timestamp}"
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
end
|
42
|
+
# Unzip the file for rollback.
|
43
|
+
execute "gunzip #{backup}.gz"
|
39
44
|
|
40
|
-
|
45
|
+
unless test "[ -f #{backup} ]"
|
46
|
+
warn "backup file #{backup} does not exist."
|
47
|
+
next
|
48
|
+
end
|
41
49
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
drush.feature_revert
|
46
|
-
drush.site_online
|
47
|
-
drush.cache_clear
|
48
|
-
end
|
50
|
+
# Revert from backup.
|
51
|
+
execute :drush, 'sql:drop --yes'
|
52
|
+
execute :drush, "sql:cli < #{backup}"
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
namespace :deploy do
|
54
|
-
desc <<-DESC
|
55
|
-
Prepares one or more servers for deployment. Before you can use any \
|
56
|
-
of the Capistrano deployment tasks with your project, you will need to \
|
57
|
-
make sure all of your servers have been prepared with `cap deploy:setup'. When \
|
58
|
-
you add a new server to your cluster, you can easily run the setup task \
|
59
|
-
on just that server by specifying the HOSTS environment variable:
|
60
|
-
|
61
|
-
$ cap HOSTS=new.server.com deploy:setup
|
62
|
-
|
63
|
-
It is safe to run this task on servers that have already been set up; it \
|
64
|
-
will not destroy any deployed revisions or data.
|
65
|
-
DESC
|
66
|
-
task :setup, :except => { :no_release => true } do
|
67
|
-
dirs = [deploy_to, releases_path, shared_path].join(' ')
|
68
|
-
run "#{try_sudo} mkdir -p #{releases_path} #{shared_path}"
|
69
|
-
run "#{try_sudo} chown -R #{user}:#{runner_group} #{deploy_to}"
|
70
|
-
if shared_children.size > 0
|
71
|
-
sub_dirs = shared_children.map { |d| File.join(shared_path, d) }
|
72
|
-
run "#{try_sudo} mkdir -p #{sub_dirs.join(' ')}"
|
73
|
-
run "#{try_sudo} chmod 2775 #{sub_dirs.join(' ')}"
|
54
|
+
# Delete the unziped backup.
|
55
|
+
execute :rm, backup
|
56
|
+
end
|
74
57
|
end
|
75
58
|
end
|
76
|
-
end
|
77
59
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
run "#{try_sudo} mkdir -p #{shared_path}/#{link}"
|
85
|
-
run "#{try_sudo} sh -c 'if [ -d #{release_path}/#{link} ] ; then rm -rf #{release_path}/#{link}; fi'"
|
86
|
-
run "#{try_sudo} ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
|
60
|
+
desc "Backup drupal site database"
|
61
|
+
task :backup do
|
62
|
+
on roles(:app) do
|
63
|
+
within release_path.join(fetch(:app_path)) do
|
64
|
+
backup_destination = "#{shared_path}/#{fetch(:backup_path)}/#{fetch(:stage)}_#{release_timestamp}"
|
65
|
+
execute :drush, "sql:dump --result-file=#{backup_destination} --gzip"
|
87
66
|
end
|
88
67
|
end
|
68
|
+
end
|
89
69
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
run "#{try_sudo} touch #{shared_path}/#{link}"
|
96
|
-
run "#{try_sudo} ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
|
70
|
+
namespace :backup do
|
71
|
+
desc "Check required files and directories exist"
|
72
|
+
task :check do
|
73
|
+
on release_roles :all do
|
74
|
+
execute :mkdir, "-p", "#{shared_path}/#{fetch(:backup_path)}"
|
97
75
|
end
|
98
76
|
end
|
99
|
-
end
|
100
|
-
end
|
101
77
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
78
|
+
desc "Clean up old drupal site database backup"
|
79
|
+
task :cleanup do
|
80
|
+
on roles(:app) do
|
81
|
+
within release_path.join(fetch(:app_path)) do
|
82
|
+
backup_path = "#{shared_path}/#{fetch(:backup_path)}"
|
83
|
+
keep_backups = fetch(:keep_backups, 5)
|
107
84
|
|
108
|
-
|
109
|
-
|
85
|
+
# Fetch every file from the backup directory, oldest on top.
|
86
|
+
backups = capture(:ls, "-ltrx", backup_path).split
|
87
|
+
info "Keeping #{keep_backups} of #{backups.count} backup dump on #{backup_path}."
|
110
88
|
|
111
|
-
|
112
|
-
|
113
|
-
remote_files_dir = "#{current_path}/#{app_path}/sites/default/files/"
|
114
|
-
local_files_dir = "#{app_path}/sites/default/files/"
|
89
|
+
# If we found less file than the keep number finish the task here
|
90
|
+
next "" unless backups.count > keep_backups.to_i
|
115
91
|
|
116
|
-
|
92
|
+
# Calculate number of file to delete.
|
93
|
+
to_delete = backups.count - keep_backups.to_i
|
117
94
|
|
95
|
+
# Loop throught file to delete (oldest files on top).
|
96
|
+
backups[0, to_delete].map do |backup|
|
97
|
+
execute :rm, "#{backup_path}/#{backup}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
118
102
|
end
|
119
103
|
end
|
120
104
|
|
121
|
-
namespace :
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
if exists?(:stage)
|
129
|
-
tag = "#{stage}_#{tag}"
|
105
|
+
namespace :cache do
|
106
|
+
desc 'Clear all caches'
|
107
|
+
task :clear do
|
108
|
+
on roles(:app) do
|
109
|
+
within release_path.join(fetch(:app_path)) do
|
110
|
+
execute :drush, 'cr'
|
111
|
+
end
|
130
112
|
end
|
131
|
-
puts `git tag #{tag} #{revision} -m "Deployed by #{user} <#{email}>"`
|
132
|
-
puts `git push origin tag #{tag}`
|
133
113
|
end
|
114
|
+
end
|
134
115
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
116
|
+
namespace :module do
|
117
|
+
desc 'Enable module(s)'
|
118
|
+
task :enable do
|
119
|
+
on roles(:app) do
|
120
|
+
within release_path.join(fetch(:app_path)) do
|
121
|
+
for mod in fetch(:enable_modules)
|
122
|
+
execute :drush, "en '#{mod}' -y"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
143
126
|
end
|
144
127
|
|
145
|
-
desc
|
146
|
-
task :
|
147
|
-
|
148
|
-
|
128
|
+
desc 'Disable module(s)'
|
129
|
+
task :disable do
|
130
|
+
on roles(:app) do
|
131
|
+
within release_path.join(fetch(:app_path)) do
|
132
|
+
for mod in fetch(:disable_modules)
|
133
|
+
execute :drush, "pmu '#{mod}' -y"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
149
137
|
end
|
138
|
+
end
|
150
139
|
|
151
|
-
|
152
|
-
|
153
|
-
|
140
|
+
namespace :maintenance do
|
141
|
+
desc "Set maintenance mode"
|
142
|
+
task :on do
|
143
|
+
on roles(:app) do
|
144
|
+
within release_path.join(fetch(:app_path)) do
|
145
|
+
execute :drush, "state:set system.maintenance_mode 1 -y"
|
146
|
+
execute :drush, 'cr', raise_on_non_zero_exit: false
|
147
|
+
end
|
148
|
+
end
|
154
149
|
end
|
155
150
|
|
156
|
-
desc "
|
157
|
-
task :
|
158
|
-
|
151
|
+
desc "Remove maintenance mode"
|
152
|
+
task :off do
|
153
|
+
on roles(:app) do
|
154
|
+
within release_path.join(fetch(:app_path)) do
|
155
|
+
execute :drush, "state:set system.maintenance_mode 0 -y"
|
156
|
+
execute :drush, 'cr'
|
157
|
+
end
|
158
|
+
end
|
159
159
|
end
|
160
|
+
end
|
160
161
|
|
161
|
-
|
162
|
-
|
163
|
-
|
162
|
+
desc 'Update database with migrations scripts'
|
163
|
+
task :updatedb do
|
164
|
+
on roles(:app) do
|
165
|
+
within release_path.join(fetch(:app_path)) do
|
166
|
+
execute :drush, 'updatedb -y'
|
167
|
+
end
|
164
168
|
end
|
169
|
+
end
|
165
170
|
|
166
|
-
|
167
|
-
|
168
|
-
|
171
|
+
namespace :updatedb do
|
172
|
+
desc 'Update database with migrations scripts'
|
173
|
+
task :silence do
|
174
|
+
on roles(:app) do
|
175
|
+
within release_path.join(fetch(:app_path)) do
|
176
|
+
execute :drush, 'updatedb -y', raise_on_non_zero_exit: false
|
177
|
+
end
|
178
|
+
end
|
169
179
|
end
|
180
|
+
end
|
170
181
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
182
|
+
desc 'Apply pending entity schema updates'
|
183
|
+
task :entup do
|
184
|
+
on roles(:app) do
|
185
|
+
within release_path.join(fetch(:app_path)) do
|
186
|
+
execute :drush, 'entup -y'
|
187
|
+
end
|
175
188
|
end
|
176
|
-
|
177
189
|
end
|
178
190
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
download(sqlfile, "#{backup_path}/#{filename}")
|
191
|
-
|
192
|
-
begin
|
193
|
-
FileUtils.ln_sf(filename, "#{backup_path}/#{application}_dump.latest.sql.gz")
|
194
|
-
rescue Exception # fallback for file systems that don't support symlinks
|
195
|
-
FileUtils.cp_r("#{backup_path}/#{filename}", "#{backup_path}/#{application}_dump.latest.sql.gz")
|
191
|
+
namespace :config do
|
192
|
+
desc 'Import configuration to active stage'
|
193
|
+
task :import do
|
194
|
+
on roles(:app) do
|
195
|
+
try = 0
|
196
|
+
full_config_path = release_path.join(fetch(:config_path))
|
197
|
+
within release_path.join(fetch(:app_path)) do
|
198
|
+
execute :drush, "config-import -y"
|
199
|
+
rescue
|
200
|
+
try += 1
|
201
|
+
try < 5 ? retry : raise
|
196
202
|
end
|
197
|
-
|
198
|
-
run "rm #{sqlfile}"
|
199
203
|
end
|
204
|
+
end
|
205
|
+
end
|
200
206
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
run_locally "cd #{app_path} && drush sql-dump | gzip -9 > ../#{sqlfile}"
|
207
|
+
namespace :permissions do
|
208
|
+
desc 'Set recommended Drupal permissions'
|
209
|
+
task :recommended do
|
210
|
+
on roles(:app) do
|
211
|
+
within release_path.join(fetch(:app_path)) do
|
212
|
+
execute :chmod, '-R', '555', '.'
|
208
213
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
FileUtils.cp_r(sqlfile, "#{backup_path}/#{application}.local_dump.latest.sql.gz")
|
214
|
+
# Remove execution for files, keep execution on folder.
|
215
|
+
execute 'find', './ -type f -executable -exec chmod -x {} \;'
|
216
|
+
execute 'find', './ -type d -exec chmod +x {} \;'
|
213
217
|
end
|
214
|
-
|
215
|
-
sqlfile
|
216
218
|
end
|
217
219
|
end
|
218
220
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
221
|
+
desc 'Set cleanup permissions to allow deletion of releases'
|
222
|
+
task :cleanup do
|
223
|
+
on roles(:app) do
|
224
|
+
releases = capture(:ls, '-x', releases_path).split
|
225
|
+
valid, invalid = releases.partition { |e| /^\d{14}$/ =~ e }
|
226
|
+
|
227
|
+
if valid.count >= fetch(:keep_releases)
|
228
|
+
directories = (valid - valid.last(fetch(:keep_releases))).map do |release|
|
229
|
+
releases_path.join(release)
|
230
|
+
end
|
231
|
+
if test("[ -d #{current_path} ]")
|
232
|
+
current_release = capture(:readlink, current_path).to_s
|
233
|
+
if directories.include?(current_release)
|
234
|
+
directories.delete(current_release)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
if directories.any?
|
238
|
+
directories.each_slice(100) do |directories_batch|
|
239
|
+
execute :chmod, '-R' ,'ug+w', *directories_batch
|
240
|
+
end
|
241
|
+
end
|
230
242
|
end
|
231
|
-
|
232
|
-
f = File.new(sqlfile, "a+")
|
233
|
-
gz = Zlib::GzipReader.new(File.open(gzfile, "r"))
|
234
|
-
f << gz.read
|
235
|
-
f.close
|
236
|
-
|
237
|
-
run_locally "cd #{app_path} && drush sql-connect < ../#{sqlfile}"
|
238
|
-
|
239
|
-
FileUtils.rm(sqlfile)
|
240
243
|
end
|
244
|
+
end
|
241
245
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
246
|
+
desc 'Initalize shared path permissions'
|
247
|
+
task :writable_shared do
|
248
|
+
on roles(:app) do
|
249
|
+
within shared_path do
|
250
|
+
# "web/sites/default/files" is a shared dir and should be writable.
|
251
|
+
execute :chmod, '-R', '775', "#{fetch(:app_path)}/sites/default/files"
|
248
252
|
|
249
|
-
|
253
|
+
# Remove execution for files, keep execution on folder.
|
254
|
+
execute 'find', "#{fetch(:app_path)}/sites/default/files", '-type f -executable -exec chmod -x {} \;'
|
255
|
+
execute 'find', "#{fetch(:app_path)}/sites/default/files", '-type d -exec chmod +sx {} \;'
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
250
260
|
|
251
|
-
|
252
|
-
|
261
|
+
namespace :files do
|
262
|
+
desc "Download drupal sites files (from remote to local)"
|
263
|
+
task :download do
|
264
|
+
run_locally do
|
265
|
+
on release_roles :app do |server|
|
266
|
+
ask(:answer, "Do you really want to download the files on the server to your local files? Nothings will be deleted but files can be ovewrite. (y/N)");
|
267
|
+
if fetch(:answer) == 'y' then
|
268
|
+
remote_files_dir = "#{shared_path}/#{(fetch(:app_path))}/sites/default/files/"
|
269
|
+
local_files_dir = "#{(fetch(:app_path))}/sites/default/files/"
|
270
|
+
system("rsync --recursive --times --rsh=ssh --human-readable --progress --exclude='.*' --exclude='css' --exclude='js' #{server.user}@#{server.hostname}:#{remote_files_dir} #{local_files_dir}")
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
253
275
|
|
254
|
-
|
276
|
+
desc "Upload drupal sites files (from local to remote)"
|
277
|
+
task :upload do
|
278
|
+
on release_roles :app do |server|
|
279
|
+
ask(:answer, "Do you really want to upload your local files to the server? Nothings will be deleted but files can be ovewrite. (y/N)");
|
280
|
+
if fetch(:answer) == 'y' then
|
281
|
+
remote_files_dir = "#{shared_path}/#{(fetch(:app_path))}/sites/default/files/"
|
282
|
+
local_files_dir = "#{(fetch(:app_path))}/sites/default/files/"
|
283
|
+
system("rsync --recursive --times --rsh=ssh --human-readable --progress --exclude='.*' --exclude='css' --exclude='js' #{local_files_dir} #{server.user}@#{server.hostname}:#{remote_files_dir}")
|
255
284
|
end
|
256
285
|
end
|
257
286
|
end
|
metadata
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capdrupal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Kevin Wenger
|
8
|
+
- Yann Lugrin
|
8
9
|
- Gilles Doge
|
10
|
+
- Toni Fisler
|
11
|
+
- Simon Perdrisat
|
9
12
|
- Robert Wohleb
|
10
13
|
- Kim Pepper
|
11
14
|
autorequire:
|
12
15
|
bindir: bin
|
13
16
|
cert_chain: []
|
14
|
-
date:
|
17
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
15
18
|
dependencies:
|
16
19
|
- !ruby/object:Gem::Dependency
|
17
20
|
name: capistrano
|
@@ -19,51 +22,74 @@ dependencies:
|
|
19
22
|
requirements:
|
20
23
|
- - "~>"
|
21
24
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
23
|
-
- - ">="
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version: 2.13.4
|
25
|
+
version: '3.5'
|
26
26
|
type: :runtime
|
27
27
|
prerelease: false
|
28
28
|
version_requirements: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
33
|
-
- - ">="
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 2.13.4
|
32
|
+
version: '3.5'
|
36
33
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
34
|
+
name: capistrano-composer
|
38
35
|
requirement: !ruby/object:Gem::Requirement
|
39
36
|
requirements:
|
40
37
|
- - "~>"
|
41
38
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
43
|
-
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 1.1.2
|
39
|
+
version: 0.0.6
|
46
40
|
type: :runtime
|
47
41
|
prerelease: false
|
48
42
|
version_requirements: !ruby/object:Gem::Requirement
|
49
43
|
requirements:
|
50
44
|
- - "~>"
|
51
45
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
53
|
-
|
46
|
+
version: 0.0.6
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 10.0.0
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
54
73
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
56
|
-
description:
|
57
|
-
|
58
|
-
email:
|
74
|
+
version: 10.0.0
|
75
|
+
description: " A set of tasks for deploying Drupal 9, Drupal 8 and Drupal 7 projects
|
76
|
+
with Capistrano and the help of Drush.\n"
|
77
|
+
email:
|
78
|
+
- hello@antistatique.net
|
59
79
|
executables: []
|
60
80
|
extensions: []
|
61
|
-
extra_rdoc_files:
|
62
|
-
- README.markdown
|
81
|
+
extra_rdoc_files: []
|
63
82
|
files:
|
64
|
-
-
|
65
|
-
-
|
83
|
+
- ".gitignore"
|
84
|
+
- ".gitkeep"
|
85
|
+
- CHANGELOG.md
|
86
|
+
- CONTRIBUTING.md
|
87
|
+
- Gemfile
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
66
91
|
- capdrupal.gemspec
|
92
|
+
- docs/maintainers.md
|
67
93
|
- lib/capdrupal.rb
|
68
94
|
homepage: http://github.com/antistatique/capdrupal/
|
69
95
|
licenses:
|
@@ -84,9 +110,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
110
|
- !ruby/object:Gem::Version
|
85
111
|
version: '0'
|
86
112
|
requirements: []
|
87
|
-
|
88
|
-
rubygems_version: 2.2.2
|
113
|
+
rubygems_version: 3.1.2
|
89
114
|
signing_key:
|
90
115
|
specification_version: 4
|
91
|
-
summary: A set of tasks for deploying Drupal projects with Capistrano
|
116
|
+
summary: A set of tasks for deploying and managing Drupal projects with Capistrano
|
92
117
|
test_files: []
|
data/README.markdown
DELETED
@@ -1,176 +0,0 @@
|
|
1
|
-
# Capdrupal
|
2
|
-
|
3
|
-
This gem provides a number of tasks which are useful for deploying Drupal projects with [Capistrano](https://github.com/capistrano/capistrano).
|
4
|
-
|
5
|
-
# Capdrupal version
|
6
|
-
|
7
|
-
|
8
|
-
Capdrupal Gem Version | Branch | Capistrano Version | Drupal Version
|
9
|
-
--------------------- | ------ | ------------------ | --------------
|
10
|
-
0.x | d7 | 2 | 7.x
|
11
|
-
2.x | master | 3 | 8.x
|
12
|
-
|
13
|
-
|
14
|
-
## Installation
|
15
|
-
[gems](http://rubygems.org) must be installed on your system first.
|
16
|
-
|
17
|
-
### From RubyGems.org
|
18
|
-
|
19
|
-
$ gem install capdrupal
|
20
|
-
|
21
|
-
### From Github
|
22
|
-
|
23
|
-
$ git clone git://github.com/antistatique/capdrupal.git
|
24
|
-
$ cd capdrupal
|
25
|
-
$ gem build capdrupal.gemspec
|
26
|
-
$ gem install capdrupal-{version}.gem
|
27
|
-
|
28
|
-
### Use Bundler to avoid conflict with Capistrano 3
|
29
|
-
|
30
|
-
This version use capistrano 2. Installation with [bundler](http://bundler.io/) let you use both version and avoid conflict.
|
31
|
-
|
32
|
-
Create a 'Gemfile' on the root of your project
|
33
|
-
|
34
|
-
|
35
|
-
group :development do
|
36
|
-
gem 'capistrano', '~> 2.15.5'
|
37
|
-
gem 'railsless-deploy'
|
38
|
-
gem 'capdrupal'
|
39
|
-
#other development gems...
|
40
|
-
end
|
41
|
-
|
42
|
-
Install the depencies
|
43
|
-
|
44
|
-
$ bundle install
|
45
|
-
|
46
|
-
Use capistrano throuw bundle
|
47
|
-
|
48
|
-
$ bundle exec cap deploy
|
49
|
-
|
50
|
-
|
51
|
-
## Configuration
|
52
|
-
|
53
|
-
It's highly recommended to use Git in your project, but you can also use Subversion or your favorite versionning software. This tutorial his made for multistage deployment, but you can easily use it just for one target.
|
54
|
-
|
55
|
-
First, go to your project directory and launch Capistrano.
|
56
|
-
|
57
|
-
$ cd path/to/your/directory/
|
58
|
-
$ capify .
|
59
|
-
|
60
|
-
Capistrano create two files `capfile` and `config/deploy.rb`. Open `capfile` and set the depencies.
|
61
|
-
|
62
|
-
require 'rubygems'
|
63
|
-
require 'capdrupal'
|
64
|
-
load 'config/deploy'
|
65
|
-
|
66
|
-
Then, go to `config/deploy.rb` to set the parameters of your project. First you have to define the general informations about the user, server and the app himself.
|
67
|
-
|
68
|
-
# USER
|
69
|
-
set :user, "name"
|
70
|
-
set :group, "name"
|
71
|
-
set :runner_group, "name"
|
72
|
-
|
73
|
-
# APP
|
74
|
-
set :application, "appName"
|
75
|
-
|
76
|
-
# The domain and the path to your app directory
|
77
|
-
set :domain, "staging.domain.com"
|
78
|
-
set :deploy_to, "/home/path/to/my/app/"
|
79
|
-
|
80
|
-
The specific Drupal informations and if you have already or not [Drush](https://drupal.org/project/drush) installed on your server (if your not sure, keep it TRUE).
|
81
|
-
|
82
|
-
# DRUPAL
|
83
|
-
set :app_path, "drupal"
|
84
|
-
set :shared_children, ['drupal/sites/default/files']
|
85
|
-
set :shared_files, ['drupal/sites/default/settings.php']
|
86
|
-
set :download_drush, true
|
87
|
-
|
88
|
-
Then, all the informations related to your Git repository
|
89
|
-
|
90
|
-
set :scm, "git"
|
91
|
-
set :repository, "git@github.com:user/repo-name.git"
|
92
|
-
set :branch, "dev"
|
93
|
-
|
94
|
-
Finally, set the other Capistrano related options, the number of realeases you want and the cleanup at the end of the deployment.
|
95
|
-
|
96
|
-
set :use_sudo, false
|
97
|
-
default_run_options[:pty] = true
|
98
|
-
ssh_options[:forward_agent] = true
|
99
|
-
role :app, domain
|
100
|
-
role :db, domain
|
101
|
-
|
102
|
-
set :keep_releases, 5
|
103
|
-
after "deploy:update", "deploy:cleanup"
|
104
|
-
|
105
|
-
Awesome, your configuration file is complete ! You can also use Capdrupal for [multistage](https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension).
|
106
|
-
|
107
|
-
|
108
|
-
## Usage
|
109
|
-
|
110
|
-
So, after configuration come action ! The first time, you have to run this command with the choosing stage.
|
111
|
-
|
112
|
-
$ cap deploy:setup
|
113
|
-
|
114
|
-
In fact, Capistrano create directories and symlink to the targeted server. The `shared` directory contains all shared files of your app who don't need to be change. `Releases` contains the different releases of your app with a number define in `deploy.rb` and finally `current` is the symlink who target the right release.
|
115
|
-
|
116
|
-
myApp
|
117
|
-
├── current -> /home/myApp/releases/20130527070530
|
118
|
-
├── releases
|
119
|
-
│ ├── 20130527065508
|
120
|
-
│ ├── 20130527065907
|
121
|
-
│ └── 20130527070530
|
122
|
-
└── shared
|
123
|
-
|
124
|
-
Now, every time you want to deploy you app !
|
125
|
-
|
126
|
-
$ cap deploy
|
127
|
-
|
128
|
-
And if some troubles occur, juste launch the rollback command to return to the previous release.
|
129
|
-
|
130
|
-
$ cap deploy:rollback
|
131
|
-
|
132
|
-
|
133
|
-
You should then be able to proceed as you would usually, you may want to familiarise yourself with the truncated list of tasks, you can get a full list with:
|
134
|
-
|
135
|
-
$ cap -T
|
136
|
-
|
137
|
-
This show a list of all avaible commands:
|
138
|
-
|
139
|
-
|
140
|
-
cap deploy # Deploys your project.
|
141
|
-
cap deploy:check # Test deployment dependencies.
|
142
|
-
cap deploy:cleanup # Clean up old releases.
|
143
|
-
cap deploy:cold # Deploys and starts a `cold' application.
|
144
|
-
cap deploy:create_symlink # Updates the symlink to the most recently deployed version.
|
145
|
-
cap deploy:pending # Displays the commits since your last deploy.
|
146
|
-
cap deploy:pending:diff # Displays the `diff' since your last deploy.
|
147
|
-
cap deploy:rollback # Rolls back to a previous version and restarts.
|
148
|
-
cap deploy:rollback:code # Rolls back to the previously deployed version.
|
149
|
-
cap deploy:setup # Prepares one or more servers for deployment.
|
150
|
-
cap deploy:symlink # Deprecated.
|
151
|
-
cap deploy:update # Copies your project and updates the symlink.
|
152
|
-
cap deploy:update_code # Copies your project to the remote servers.
|
153
|
-
cap deploy:upload # Copy files to the currently deployed version.
|
154
|
-
cap dev # Set the target stage to `dev'.
|
155
|
-
cap drupal:symlink_shared # Symlinks static directories and static files that need to remain between d...
|
156
|
-
cap drush:backupdb # Backup the database
|
157
|
-
cap drush:cache_clear # Clear the drupal cache
|
158
|
-
cap drush:feature_revert # Revert feature
|
159
|
-
cap drush:get # Gets drush and installs it
|
160
|
-
cap drush:site_offline # Set the site offline
|
161
|
-
cap drush:site_online # Set the site online
|
162
|
-
cap drush:updatedb # Run Drupal database migrations if required
|
163
|
-
cap files:pull # Pull drupal sites files (from remote to local)
|
164
|
-
cap files:push # Push drupal sites files (from local to remote)
|
165
|
-
cap git:push_deploy_tag # Place release tag into Git and push it to origin server.
|
166
|
-
cap invoke # Invoke a single command on the remote servers.
|
167
|
-
cap multistage:prepare # Stub out the staging config files.
|
168
|
-
cap prod # Set the target stage to `prod'.
|
169
|
-
cap shell # Begin an interactive Capistrano session.
|
170
|
-
|
171
|
-
|
172
|
-
## Credits
|
173
|
-
|
174
|
-
Inspired by [capistrano-drupal](https://github.com/previousnext/capistrano-drupal).
|
175
|
-
|
176
|
-
Made by [Antistatique](http://www.antistatique.net) who's always looking for new talented developpers ! Just mail us on [job@antistatique.net](mailto:hello@antistatique.net).
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.9.7
|