capdrupal 0.10.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +22 -0
- data/.gitkeep +0 -0
- data/CHANGELOG.md +17 -0
- data/CONTRIBUTING.md +44 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +253 -0
- data/Rakefile +4 -0
- data/capdrupal.gemspec +23 -24
- data/docs/maintainers.md +17 -0
- data/lib/capdrupal.rb +227 -210
- metadata +54 -29
- data/README.markdown +0 -184
- 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: c44d744004a0b49a0e7034222558aba3899026837f5b1dfcf6e994f9262e08eb
|
4
|
+
data.tar.gz: 95957676e7e161041ed66fd5f56af9ce7aa071077f289e3a7864273996e5e4d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73243af2f5674c4f7b9b9a4421e3f377222d00630f43586c6f4d9690e9175d645821af8caa9c94d9512fd2a7aa9fc318bf9b00c629046290a4cd1457b6d0d45c
|
7
|
+
data.tar.gz: '08f3121798682e048c27a75cb6f0242ebcd4d4516aeed292ccaa5f1a2612a636c501bd757984d82b18c7073c2af8c726d2712fbdf38003bfbaf61bf579db95a3'
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
20
|
+
|
21
|
+
## Generated gem by gem build capdrupal.gemspec
|
22
|
+
capdrupal-*.gem
|
data/.gitkeep
ADDED
File without changes
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Capdrupal Changelog
|
2
|
+
|
3
|
+
## 3.0.1 (2020-08-07)
|
4
|
+
- Update the command `drupal:cache:clear` to be re-runnable after invoke
|
5
|
+
|
6
|
+
## 3.0.0 (2020-08-07)
|
7
|
+
- Support for Drupal 8 & Drupal 9
|
8
|
+
- Complete code refactoring
|
9
|
+
|
10
|
+
## 0.11.0 (2016-01-21)
|
11
|
+
- Support for Drupal 8 & Drupal 9
|
12
|
+
|
13
|
+
## 0.10.0 (2015-04-24)
|
14
|
+
- Task `deploy` do not clear cache, revert features, updatedb, etc. For this use `deploy:full` task
|
15
|
+
|
16
|
+
## 0.9.6 (2014-06-14)
|
17
|
+
* 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,253 @@
|
|
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
|
+
[![Gem Version](https://badge.fury.io/rb/capdrupal.svg)](https://badge.fury.io/rb/capdrupal)
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/e5db5a7f49d86ce5e418/maintainability)](https://codeclimate.com/github/antistatique/capdrupal/maintainability)
|
7
|
+
|
8
|
+
# Capdrupal version
|
9
|
+
|
10
|
+
Capdrupal Gem Version | Branch | Capistrano Version | Drupal Version
|
11
|
+
--------------------- | ------ | ------------------ | --------------
|
12
|
+
0.11.0 | d7 | 2 | 7.x
|
13
|
+
3.x | main | 3.x | 8.x
|
14
|
+
3.x | main | 3.x | 9.x
|
15
|
+
|
16
|
+
## Prerequisites
|
17
|
+
|
18
|
+
By default, Capdrupal will use **Drush** to run every Drupal commands. Therefore, your Drupal project **must** to require
|
19
|
+
`drush/drush`.
|
20
|
+
|
21
|
+
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).
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem 'capdrupal', '~>3.0'
|
29
|
+
```
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
```shell
|
34
|
+
bundle
|
35
|
+
```
|
36
|
+
|
37
|
+
Or install it yourself if [gems](http://rubygems.org) is installed on your system:
|
38
|
+
|
39
|
+
```shell
|
40
|
+
gem install capdrupal
|
41
|
+
```
|
42
|
+
|
43
|
+
## Configuration
|
44
|
+
|
45
|
+
First, go to your project directory and launch Capistrano.
|
46
|
+
|
47
|
+
```shell
|
48
|
+
cd path/to/your/drupal/project/
|
49
|
+
cap install
|
50
|
+
```
|
51
|
+
|
52
|
+
Capistrano will create the following skeleton
|
53
|
+
|
54
|
+
```
|
55
|
+
.
|
56
|
+
├── Capfile
|
57
|
+
├── config
|
58
|
+
│ └── deploy.rb
|
59
|
+
│ └── deploy
|
60
|
+
│ └── production.rb
|
61
|
+
│ └── staging.rb
|
62
|
+
├── lib
|
63
|
+
│ └── capistrano
|
64
|
+
│ └── tasks
|
65
|
+
|
66
|
+
```
|
67
|
+
|
68
|
+
Create two files `Capfile` and `config/deploy.rb`. Open `Capfile` and set the dependencies.
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# Load DSL and set up stages.
|
72
|
+
require 'capistrano/setup'
|
73
|
+
|
74
|
+
# Include default deployment tasks.
|
75
|
+
require 'capistrano/deploy'
|
76
|
+
|
77
|
+
# Composer is needed to install drush on the server.
|
78
|
+
require 'capistrano/composer'
|
79
|
+
|
80
|
+
# Drupal Tasks.
|
81
|
+
require 'capdrupal'
|
82
|
+
|
83
|
+
# Load custom tasks from `lib/capistrano/tasks` if you have any defined.
|
84
|
+
Dir.glob('config/capistrano/tasks/*.rake').each { |r| import r }
|
85
|
+
```
|
86
|
+
|
87
|
+
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.
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
set :application, 'application-name'
|
91
|
+
set :repo_url, 'git@github.com:company/application.git'
|
92
|
+
|
93
|
+
server 'ssh.example.org', user: 'username', roles: %w{app db web}
|
94
|
+
```
|
95
|
+
|
96
|
+
The specific Drupal information
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
set :install_composer, true
|
100
|
+
set :install_drush, true
|
101
|
+
|
102
|
+
set :app_path, 'web'
|
103
|
+
set :config_path, 'config/sync'
|
104
|
+
|
105
|
+
# Setup the backup before/after failed strategy.
|
106
|
+
set :backup_path, 'backups'
|
107
|
+
set :keep_backups, 5
|
108
|
+
|
109
|
+
# Link file settings.php
|
110
|
+
set :linked_files, fetch(:linked_files, []).push("#{fetch(:app_path)}/sites/default/settings.php", "drush/drush.yml")
|
111
|
+
|
112
|
+
# Link dirs files and private-files
|
113
|
+
set :linked_dirs, fetch(:linked_dirs, []).push("#{fetch(:app_path)}/sites/default/files")
|
114
|
+
```
|
115
|
+
|
116
|
+
Then, all the others information related to your Git repository or debug level
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
# Default value for :scm is :git
|
120
|
+
set :scm, :git
|
121
|
+
|
122
|
+
# Default value for :log_level is :debug
|
123
|
+
set :log_level, :debug
|
124
|
+
```
|
125
|
+
|
126
|
+
Finally, set the deployment to use the proper Drupal 8 strategy
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
namespace :deploy do
|
130
|
+
# Ensure everything is ready to deploy.
|
131
|
+
after "deploy:check:directories", "drupal:db:backup:check"
|
132
|
+
|
133
|
+
# Backup the database before starting a deployment and rollback on fail.
|
134
|
+
# after :updated, "drupal:db:backup"
|
135
|
+
# before :failed, "drupal:db:rollback"
|
136
|
+
# before :cleanup, "drupal:db:backup:cleanup"
|
137
|
+
|
138
|
+
# Set the maintenance Mode on your Drupal online project when deploying.
|
139
|
+
after :updated, "drupal:maintenance:on"
|
140
|
+
|
141
|
+
# Must updatedb before import configurations, E.g. when composer install new
|
142
|
+
# version of Drupal and need updatedb scheme before importing new config.
|
143
|
+
# This is executed without raise on error, because sometimes we need to do drush config-import before updatedb.
|
144
|
+
after :updated, "drupal:updatedb:silence"
|
145
|
+
|
146
|
+
# Remove the cache after the database update
|
147
|
+
after :updated, "drupal:cache:clear"
|
148
|
+
after :updated, "drupal:config:import"
|
149
|
+
|
150
|
+
# Update the database after configurations has been imported.
|
151
|
+
after :updated, "drupal:updatedb"
|
152
|
+
|
153
|
+
# Clear your Drupal 8 cache.
|
154
|
+
after :updated, "drupal:cache:clear"
|
155
|
+
|
156
|
+
# Disable the maintence on the Drupal project.
|
157
|
+
after :updated, "drupal:maintenance:off"
|
158
|
+
|
159
|
+
# Ensure permissions are properly set.
|
160
|
+
after :updated, "drupal:permissions:recommended"
|
161
|
+
after :updated, "drupal:permissions:writable_shared"
|
162
|
+
|
163
|
+
# Fix the release permissions (due to Drupal restrictive permissions)
|
164
|
+
# before deletting old release.
|
165
|
+
before :cleanup, "drupal:permissions:cleanup"
|
166
|
+
end
|
167
|
+
```
|
168
|
+
|
169
|
+
You may now can configure your `staging.rb` and `production.rb` strategy, has you will certainly deploy on different environment
|
170
|
+
|
171
|
+
```shell
|
172
|
+
vi config/deploy/staging.rb
|
173
|
+
```
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
# staging.example.org
|
177
|
+
set :deploy_to, '/var/www/staging.example.org'
|
178
|
+
|
179
|
+
# set a branch for this release
|
180
|
+
set :branch, 'dev'
|
181
|
+
|
182
|
+
# Map composer and drush commands
|
183
|
+
# NOTE: If stage have different deploy_to
|
184
|
+
# you have to copy those line for each <stage_name>.rb
|
185
|
+
# See https://github.com/capistrano/composer/issues/22
|
186
|
+
SSHKit.config.command_map[:composer] = -> { shared_path.join('composer.phar') }
|
187
|
+
SSHKit.config.command_map[:drush] = -> { release_path.join('vendor/bin/drush') }
|
188
|
+
```
|
189
|
+
|
190
|
+
```shell
|
191
|
+
vi config/deploy/production.rb
|
192
|
+
```
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
# www.example.org
|
196
|
+
set :deploy_to, '/var/www/example.org'
|
197
|
+
|
198
|
+
# set a branch for this release
|
199
|
+
set :branch, 'master'
|
200
|
+
|
201
|
+
# Map composer and drush commands
|
202
|
+
# NOTE: If stage have different deploy_to
|
203
|
+
# you have to copy those line for each <stage_name>.rb
|
204
|
+
# See https://github.com/capistrano/composer/issues/22
|
205
|
+
SSHKit.config.command_map[:composer] = -> { shared_path.join('composer.phar') }
|
206
|
+
SSHKit.config.command_map[:drush] = -> { release_path.join('vendor/bin/drush') }
|
207
|
+
```
|
208
|
+
|
209
|
+
Awesome, your configuration is complete !
|
210
|
+
|
211
|
+
## Usage
|
212
|
+
|
213
|
+
So, after configuration come action ! The first time, you have to run this command with the choosing stage.
|
214
|
+
|
215
|
+
```shell
|
216
|
+
cap [staging|production] deploy:setup
|
217
|
+
```
|
218
|
+
|
219
|
+
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.
|
220
|
+
|
221
|
+
```
|
222
|
+
example.org
|
223
|
+
├── current -> /home/example.org/releases/20130527070530
|
224
|
+
├── releases
|
225
|
+
│ ├── 20130527065508
|
226
|
+
│ ├── 20130527065907
|
227
|
+
│ └── 20130527070530
|
228
|
+
└── shared
|
229
|
+
```
|
230
|
+
|
231
|
+
Now, every time you want to deploy your app !
|
232
|
+
|
233
|
+
```
|
234
|
+
cap [staging|production] deploy
|
235
|
+
```
|
236
|
+
|
237
|
+
And if some troubles occur, just launch the rollback command to return to the previous release.
|
238
|
+
|
239
|
+
```
|
240
|
+
cap [staging|production] deploy:rollback
|
241
|
+
```
|
242
|
+
|
243
|
+
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:
|
244
|
+
|
245
|
+
```
|
246
|
+
cap -T
|
247
|
+
```
|
248
|
+
|
249
|
+
## Credits
|
250
|
+
|
251
|
+
Inspired by [capistrano-drupal](https://github.com/previousnext/capistrano-drupal).
|
252
|
+
|
253
|
+
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.1'
|
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,17 @@
|
|
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
|
+
- Commit those 2 changes and create a new tag with the version number
|
13
|
+
- Make a [new release with GitHub](https://github.com/antistatique/capdrupal/releases/new)
|
14
|
+
- Build the gem with `gem build capdrupal.gemspec`
|
15
|
+
- Push the gem to rubygems.org: `gem push capdrupal-X.X.X.gem`
|
16
|
+
- Add the `capdrupal-X.X.X.gem` to the GitHub release
|
17
|
+
|
data/lib/capdrupal.rb
CHANGED
@@ -1,270 +1,287 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# are not sufficient.
|
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
|
22
|
-
|
23
|
-
_cset(:deploy_to) { "/var/www/#{application}" }
|
24
|
-
_cset(:app_path) { "drupal" }
|
25
|
-
_cset :shared_children, false
|
26
|
-
|
27
|
-
_cset :backup_path, "backups"
|
28
|
-
_cset :remote_tmp_dir, "/tmp"
|
29
|
-
|
30
|
-
if download_drush
|
31
|
-
depend :remote, :command, "curl"
|
32
|
-
end
|
33
|
-
|
34
|
-
# This is an optional step that can be defined.
|
35
|
-
#after "deploy", "git:push_deploy_tag"
|
36
|
-
|
37
|
-
after "deploy:finalize_update" do
|
38
|
-
drupal.symlink_shared
|
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, []
|
39
9
|
end
|
10
|
+
end
|
40
11
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
on just that server by specifying the HOSTS environment variable:
|
48
|
-
|
49
|
-
$ cap HOSTS=new.server.com deploy:setup
|
50
|
-
|
51
|
-
It is safe to run this task on servers that have already been set up; it \
|
52
|
-
will not destroy any deployed revisions or data.
|
53
|
-
DESC
|
54
|
-
task :setup, :except => { :no_release => true } do
|
55
|
-
dirs = [deploy_to, releases_path, shared_path].join(' ')
|
56
|
-
run "#{try_sudo} mkdir -p #{releases_path} #{shared_path}"
|
57
|
-
run "#{try_sudo} chown -R #{user}:#{runner_group} #{deploy_to}"
|
58
|
-
if shared_children.size > 0
|
59
|
-
sub_dirs = shared_children.map { |d| File.join(shared_path, d) }
|
60
|
-
run "#{try_sudo} mkdir -p #{sub_dirs.join(' ')}"
|
61
|
-
run "#{try_sudo} chmod 2775 #{sub_dirs.join(' ')}"
|
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'
|
62
18
|
end
|
63
19
|
end
|
20
|
+
end
|
21
|
+
end
|
64
22
|
|
65
|
-
|
66
|
-
Deploy your project and do an updatedb, feature revert, cache clear...
|
67
|
-
DESC
|
68
|
-
task :full do
|
69
|
-
deploy
|
23
|
+
namespace :drupal do
|
70
24
|
|
71
|
-
|
72
|
-
|
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)
|
73
31
|
end
|
74
|
-
|
75
|
-
drupal.site_offline
|
76
|
-
drupal.updatedb
|
77
|
-
drupal.cache_clear
|
78
|
-
drupal.feature_revert
|
79
|
-
drupal.site_online
|
80
|
-
drupal.cache_clear
|
81
32
|
end
|
82
33
|
end
|
83
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}"
|
84
41
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
42
|
+
# Unzip the file for rollback.
|
43
|
+
execute "gunzip #{backup}.gz"
|
44
|
+
|
45
|
+
unless test "[ -f #{backup} ]"
|
46
|
+
warn "backup file #{backup} does not exist."
|
47
|
+
next
|
48
|
+
end
|
49
|
+
|
50
|
+
# Revert from backup.
|
51
|
+
execute :drush, 'sql:drop --yes'
|
52
|
+
execute :drush, "sql:cli < #{backup}"
|
53
|
+
|
54
|
+
# Delete the unziped backup.
|
55
|
+
execute :rm, backup
|
94
56
|
end
|
95
57
|
end
|
58
|
+
end
|
96
59
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
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"
|
104
66
|
end
|
105
67
|
end
|
106
68
|
end
|
107
69
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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)}"
|
75
|
+
end
|
76
|
+
end
|
113
77
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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)
|
119
84
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
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}."
|
124
88
|
|
125
|
-
|
126
|
-
|
127
|
-
run "#{drush_cmd} -r #{latest_release}/#{app_path} updatedb -y"
|
128
|
-
end
|
89
|
+
# If we found less file than the keep number finish the task here
|
90
|
+
next "" unless backups.count > keep_backups.to_i
|
129
91
|
|
130
|
-
|
131
|
-
|
132
|
-
run "#{drush_cmd} -r #{latest_release}/#{app_path} cache-clear all"
|
133
|
-
end
|
92
|
+
# Calculate number of file to delete.
|
93
|
+
to_delete = backups.count - keep_backups.to_i
|
134
94
|
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
138
102
|
end
|
103
|
+
end
|
139
104
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
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
|
112
|
+
end
|
113
|
+
Rake::Task['drupal:cache:clear'].reenable
|
144
114
|
end
|
145
115
|
end
|
146
116
|
|
147
|
-
namespace :
|
148
|
-
desc
|
149
|
-
task :
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
117
|
+
namespace :module do
|
118
|
+
desc 'Enable module(s)'
|
119
|
+
task :enable do
|
120
|
+
on roles(:app) do
|
121
|
+
within release_path.join(fetch(:app_path)) do
|
122
|
+
for mod in fetch(:enable_modules)
|
123
|
+
execute :drush, "en '#{mod}' -y"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
154
127
|
end
|
155
128
|
|
156
|
-
desc
|
157
|
-
task :
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
129
|
+
desc 'Disable module(s)'
|
130
|
+
task :disable do
|
131
|
+
on roles(:app) do
|
132
|
+
within release_path.join(fetch(:app_path)) do
|
133
|
+
for mod in fetch(:disable_modules)
|
134
|
+
execute :drush, "pmu '#{mod}' -y"
|
135
|
+
end
|
136
|
+
end
|
163
137
|
end
|
164
138
|
end
|
165
139
|
end
|
166
140
|
|
167
|
-
namespace :
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
tag = "#{stage}_#{tag}"
|
141
|
+
namespace :maintenance do
|
142
|
+
desc "Set maintenance mode"
|
143
|
+
task :on do
|
144
|
+
on roles(:app) do
|
145
|
+
within release_path.join(fetch(:app_path)) do
|
146
|
+
execute :drush, "state:set system.maintenance_mode 1 -y"
|
147
|
+
execute :drush, 'cr', raise_on_non_zero_exit: false
|
148
|
+
end
|
176
149
|
end
|
177
|
-
puts `git tag #{tag} #{revision} -m "Deployed by #{user} <#{email}>"`
|
178
|
-
puts `git push origin tag #{tag}`
|
179
150
|
end
|
180
151
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
152
|
+
desc "Remove maintenance mode"
|
153
|
+
task :off do
|
154
|
+
on roles(:app) do
|
155
|
+
within release_path.join(fetch(:app_path)) do
|
156
|
+
execute :drush, "state:set system.maintenance_mode 0 -y"
|
157
|
+
execute :drush, 'cr'
|
158
|
+
end
|
159
|
+
end
|
188
160
|
end
|
189
|
-
|
190
161
|
end
|
191
162
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
FileUtils::mkdir_p("#{backup_path}")
|
202
|
-
|
203
|
-
download(sqlfile, "#{backup_path}/#{filename}")
|
163
|
+
desc 'Update database with migrations scripts'
|
164
|
+
task :updatedb do
|
165
|
+
on roles(:app) do
|
166
|
+
within release_path.join(fetch(:app_path)) do
|
167
|
+
execute :drush, 'updatedb -y'
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
204
171
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
172
|
+
namespace :updatedb do
|
173
|
+
desc 'Update database with migrations scripts'
|
174
|
+
task :silence do
|
175
|
+
on roles(:app) do
|
176
|
+
within release_path.join(fetch(:app_path)) do
|
177
|
+
execute :drush, 'updatedb -y', raise_on_non_zero_exit: false
|
209
178
|
end
|
210
|
-
|
211
|
-
run "rm #{sqlfile}"
|
212
179
|
end
|
180
|
+
end
|
181
|
+
end
|
213
182
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
183
|
+
desc 'Apply pending entity schema updates'
|
184
|
+
task :entup do
|
185
|
+
on roles(:app) do
|
186
|
+
within release_path.join(fetch(:app_path)) do
|
187
|
+
execute :drush, 'entup -y'
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
221
191
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
192
|
+
namespace :config do
|
193
|
+
desc 'Import configuration to active stage'
|
194
|
+
task :import do
|
195
|
+
on roles(:app) do
|
196
|
+
try = 0
|
197
|
+
full_config_path = release_path.join(fetch(:config_path))
|
198
|
+
within release_path.join(fetch(:app_path)) do
|
199
|
+
execute :drush, "config-import -y"
|
200
|
+
rescue
|
201
|
+
try += 1
|
202
|
+
try < 5 ? retry : raise
|
226
203
|
end
|
227
|
-
|
228
|
-
sqlfile
|
229
204
|
end
|
230
205
|
end
|
206
|
+
end
|
231
207
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
database.dump.remote
|
208
|
+
namespace :permissions do
|
209
|
+
desc 'Set recommended Drupal permissions'
|
210
|
+
task :recommended do
|
211
|
+
on roles(:app) do
|
212
|
+
within release_path.join(fetch(:app_path)) do
|
213
|
+
execute :chmod, '-R', '555', '.'
|
239
214
|
|
240
|
-
|
241
|
-
|
242
|
-
|
215
|
+
# Remove execution for files, keep execution on folder.
|
216
|
+
execute 'find', './ -type f -executable -exec chmod -x {} \;'
|
217
|
+
execute 'find', './ -type d -exec chmod +x {} \;'
|
243
218
|
end
|
244
|
-
|
245
|
-
f = File.new(sqlfile, "a+")
|
246
|
-
gz = Zlib::GzipReader.new(File.open(gzfile, "r"))
|
247
|
-
f << gz.read
|
248
|
-
f.close
|
249
|
-
|
250
|
-
run_locally "cd #{app_path} && drush sql-connect < ../#{sqlfile}"
|
251
|
-
|
252
|
-
FileUtils.rm(sqlfile)
|
253
219
|
end
|
220
|
+
end
|
254
221
|
|
255
|
-
|
256
|
-
|
257
|
-
|
222
|
+
desc 'Set cleanup permissions to allow deletion of releases'
|
223
|
+
task :cleanup do
|
224
|
+
on roles(:app) do
|
225
|
+
releases = capture(:ls, '-x', releases_path).split
|
226
|
+
valid, invalid = releases.partition { |e| /^\d{14}$/ =~ e }
|
227
|
+
|
228
|
+
if valid.count >= fetch(:keep_releases)
|
229
|
+
directories = (valid - valid.last(fetch(:keep_releases))).map do |release|
|
230
|
+
releases_path.join(release)
|
231
|
+
end
|
232
|
+
if test("[ -d #{current_path} ]")
|
233
|
+
current_release = capture(:readlink, current_path).to_s
|
234
|
+
if directories.include?(current_release)
|
235
|
+
directories.delete(current_release)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
if directories.any?
|
239
|
+
directories.each_slice(100) do |directories_batch|
|
240
|
+
execute :chmod, '-R' ,'ug+w', *directories_batch
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
258
246
|
|
259
|
-
|
260
|
-
|
247
|
+
desc 'Initalize shared path permissions'
|
248
|
+
task :writable_shared do
|
249
|
+
on roles(:app) do
|
250
|
+
within shared_path do
|
251
|
+
# "web/sites/default/files" is a shared dir and should be writable.
|
252
|
+
execute :chmod, '-R', '775', "#{fetch(:app_path)}/sites/default/files"
|
261
253
|
|
262
|
-
|
254
|
+
# Remove execution for files, keep execution on folder.
|
255
|
+
execute 'find', "#{fetch(:app_path)}/sites/default/files", '-type f -executable -exec chmod -x {} \;'
|
256
|
+
execute 'find', "#{fetch(:app_path)}/sites/default/files", '-type d -exec chmod +sx {} \;'
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
263
261
|
|
264
|
-
|
265
|
-
|
262
|
+
namespace :files do
|
263
|
+
desc "Download drupal sites files (from remote to local)"
|
264
|
+
task :download do
|
265
|
+
run_locally do
|
266
|
+
on release_roles :app do |server|
|
267
|
+
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)");
|
268
|
+
if fetch(:answer) == 'y' then
|
269
|
+
remote_files_dir = "#{shared_path}/#{(fetch(:app_path))}/sites/default/files/"
|
270
|
+
local_files_dir = "#{(fetch(:app_path))}/sites/default/files/"
|
271
|
+
system("rsync --recursive --times --rsh=ssh --human-readable --progress --exclude='.*' --exclude='css' --exclude='js' #{server.user}@#{server.hostname}:#{remote_files_dir} #{local_files_dir}")
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
266
276
|
|
267
|
-
|
277
|
+
desc "Upload drupal sites files (from local to remote)"
|
278
|
+
task :upload do
|
279
|
+
on release_roles :app do |server|
|
280
|
+
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)");
|
281
|
+
if fetch(:answer) == 'y' then
|
282
|
+
remote_files_dir = "#{shared_path}/#{(fetch(:app_path))}/sites/default/files/"
|
283
|
+
local_files_dir = "#{(fetch(:app_path))}/sites/default/files/"
|
284
|
+
system("rsync --recursive --times --rsh=ssh --human-readable --progress --exclude='.*' --exclude='css' --exclude='js' #{local_files_dir} #{server.user}@#{server.hostname}:#{remote_files_dir}")
|
268
285
|
end
|
269
286
|
end
|
270
287
|
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.1
|
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: 2021-09-09 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,184 +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
|
-
### With Bundler (highly recommanded)
|
18
|
-
|
19
|
-
This version use capistrano 2. Installation with [bundler](http://bundler.io/) let you use both version and avoid conflict.
|
20
|
-
|
21
|
-
Create a 'Gemfile' on the root of your project
|
22
|
-
|
23
|
-
|
24
|
-
group :development do
|
25
|
-
gem 'capistrano', '~> 2.15.5'
|
26
|
-
gem 'railsless-deploy'
|
27
|
-
gem 'capdrupal'
|
28
|
-
#other development gems...
|
29
|
-
end
|
30
|
-
|
31
|
-
Install the depencies
|
32
|
-
|
33
|
-
$ bundle install
|
34
|
-
|
35
|
-
Use capistrano throw bundle
|
36
|
-
|
37
|
-
$ bundle exec cap deploy
|
38
|
-
|
39
|
-
### From RubyGems.org
|
40
|
-
|
41
|
-
$ gem install capdrupal
|
42
|
-
|
43
|
-
### From Github
|
44
|
-
|
45
|
-
$ git clone git://github.com/antistatique/capdrupal.git
|
46
|
-
$ cd capdrupal
|
47
|
-
$ gem build capdrupal.gemspec
|
48
|
-
$ gem install capdrupal-{version}.gem
|
49
|
-
|
50
|
-
|
51
|
-
## Configuration
|
52
|
-
|
53
|
-
This was tested with Git, 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 your app !
|
125
|
-
|
126
|
-
$ cap deploy
|
127
|
-
|
128
|
-
If you want to deploy your app and also revert features, clear cache
|
129
|
-
|
130
|
-
$ cap deploy:full
|
131
|
-
|
132
|
-
And if some troubles occur, juste launch the rollback command to return to the previous release.
|
133
|
-
|
134
|
-
$ cap deploy:rollback
|
135
|
-
|
136
|
-
|
137
|
-
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:
|
138
|
-
|
139
|
-
$ cap -T
|
140
|
-
|
141
|
-
This show a list of all avaible commands:
|
142
|
-
|
143
|
-
|
144
|
-
cap database:copy:to_local # Copy remote database into your local database
|
145
|
-
cap database:copy:to_remote # Copy local database to the remote database
|
146
|
-
cap deploy # Deploys your project.
|
147
|
-
cap deploy:check # Test deployment dependencies.
|
148
|
-
cap deploy:cleanup # Clean up old releases.
|
149
|
-
cap deploy:cold # Deploys and starts a `cold' application.
|
150
|
-
cap deploy:create_symlink # Updates the symlink to the most recently deployed version.
|
151
|
-
cap deploy:full # Deploy your project and do an updatedb, feature revert, cache clear...
|
152
|
-
cap deploy:pending # Displays the commits since your last deploy.
|
153
|
-
cap deploy:pending:diff # Displays the `diff' since your last deploy.
|
154
|
-
cap deploy:rollback # Rolls back to a previous version and restarts.
|
155
|
-
cap deploy:rollback:code # Rolls back to the previously deployed version.
|
156
|
-
cap deploy:setup # Prepares one or more servers for deployment.
|
157
|
-
cap deploy:symlink # Deprecated API.
|
158
|
-
cap deploy:update # Copies your project and updates the symlink.
|
159
|
-
cap deploy:update_code # Copies your project to the remote servers.
|
160
|
-
cap deploy:upload # Copy files to the currently deployed version.
|
161
|
-
cap dev # Set the target stage to `dev'.
|
162
|
-
cap drupal:backupdb # Backup the database using backup and migrate
|
163
|
-
cap drupal:cache_clear # Clear All the cache
|
164
|
-
cap drupal:drush # Run any drush command
|
165
|
-
cap drupal:feature_revert # Revert feature
|
166
|
-
cap drupal:site_offline # Set the site offline
|
167
|
-
cap drupal:site_online # Set the site online
|
168
|
-
cap drupal:symlink_shared # Symlinks static directories and static files that need to remain between deployments
|
169
|
-
cap drupal:updatedb # Run Drupal database migrations if required
|
170
|
-
cap drush:get # Gets drush and installs it
|
171
|
-
cap files:pull # Pull drupal sites files (from remote to local)
|
172
|
-
cap files:push # Push drupal sites files (from local to remote)
|
173
|
-
cap git:push_deploy_tag # Place release tag into Git and push it to origin server.
|
174
|
-
cap invoke # Invoke a single command on the remote servers.
|
175
|
-
cap multistage:prepare # Stub out the staging config files.
|
176
|
-
cap production # Set the target stage to `production'.
|
177
|
-
cap shell # Begin an interactive Capistrano session.
|
178
|
-
|
179
|
-
|
180
|
-
## Credits
|
181
|
-
|
182
|
-
Inspired by [capistrano-drupal](https://github.com/previousnext/capistrano-drupal).
|
183
|
-
|
184
|
-
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.10.0
|