capistrano-slug 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +137 -0
- data/Rakefile +1 -0
- data/capistrano-slug.gemspec +22 -0
- data/lib/capistrano/slug.rb +2 -0
- data/lib/capistrano/tasks/slug.rake +39 -0
- data/lib/capistrano/tasks/storage.rake +23 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c410eecc15c688b93ca6a7525f3b957a93e5c950
|
4
|
+
data.tar.gz: bed597e554bed48fcd766216dc0d8c102830a124
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7eeb8697ea54e1dc9c56c8bc283e6ee1f5830c0194db3bcfb0cc4013771b5c1fbeac6d7f5b181c473f3f215b98bda795451076f44fe4cd0e84cc9f8e5f7b8373
|
7
|
+
data.tar.gz: f4319ae71b1a56db17d5066fa9d68092844359aa970eeb96e7a561c3ce32cdea9e441d7c6d90d6f5053d1495f51d95c9c4294c2cca043f21a0e0614bef58a5ab
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Robert Coleman
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
# Capistrano-Slug
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/capistrano-slug.svg)](http://badge.fury.io/rb/capistrano-slug)
|
4
|
+
|
5
|
+
Basically after a deploy is completed Capistrano packs up it's directory and sends it off for artifact deployment sometime else.
|
6
|
+
|
7
|
+
The initial use case is taking a point-in-time snapshot of Capistrano deployment, after every deployment, to use on newly bootstrapped servers.
|
8
|
+
When a new server bootstraps I want it to have the current code (and config etc) that was deployed by Capistrano. This is achieved downloading and 'installing' the slug on boot of a new server.
|
9
|
+
|
10
|
+
This enables things like automatic provisioning of new servers but still allows for Capistrano deployments.
|
11
|
+
|
12
|
+
Slug work happens on a single server only - the primary of the configured role (default `:all`).
|
13
|
+
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'capistrano', '~> 3.2.0'
|
21
|
+
gem 'capistrano-slug'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
`$ bundle`
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
`$ gem install capistrano-slug`
|
31
|
+
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
Require the module in your `Capfile`:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'capistrano/slug'
|
39
|
+
```
|
40
|
+
|
41
|
+
`capistrano-slug` comes with 4 tasks:
|
42
|
+
|
43
|
+
* `slug`
|
44
|
+
* `slug:create`
|
45
|
+
* `slug:upload`
|
46
|
+
* `slug:clean`
|
47
|
+
|
48
|
+
|
49
|
+
#### slug
|
50
|
+
|
51
|
+
Create a slug and upload it to your configured storage.
|
52
|
+
|
53
|
+
```shell
|
54
|
+
$ cap production slug
|
55
|
+
INFO Some stuff
|
56
|
+
```
|
57
|
+
|
58
|
+
Can be used during a deploy; if you want to create/upload a slug on every deploy:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
# add to config/deploy.rb
|
62
|
+
|
63
|
+
after 'deploy:finished', :slug
|
64
|
+
```
|
65
|
+
|
66
|
+
|
67
|
+
#### slug:create
|
68
|
+
|
69
|
+
Creates a slug:
|
70
|
+
|
71
|
+
```shell
|
72
|
+
$ cap staging slug:create
|
73
|
+
INFO Created Slug: foo-application-slug.tar.gz
|
74
|
+
```
|
75
|
+
|
76
|
+
|
77
|
+
#### slug:upload
|
78
|
+
|
79
|
+
Uploads a slug to your configured storage:
|
80
|
+
|
81
|
+
```shell
|
82
|
+
$ cap staging slug:upload
|
83
|
+
INFO Uploaded Slug: foo-application-slug.tar.gz
|
84
|
+
```
|
85
|
+
|
86
|
+
#### slug:clean
|
87
|
+
|
88
|
+
Removes a slug from your server (not it's storage):
|
89
|
+
|
90
|
+
```shell
|
91
|
+
$ cap staging slug:clean
|
92
|
+
INFO Cleaned Slug: foo-application-slug.tar.gz
|
93
|
+
```
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
### Configuration
|
98
|
+
|
99
|
+
Configurable options, shown here with defaults:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
set :slug_role, :all
|
103
|
+
set :slug_name, -> { fetch(:application) }
|
104
|
+
set :slug_storage_backend, 's3'
|
105
|
+
set :slug_s3_bucket, nil
|
106
|
+
```
|
107
|
+
|
108
|
+
|
109
|
+
### Storage
|
110
|
+
|
111
|
+
Currently only Amazon S3 is supported. Adding new storage backends shouldn't be a major task, I just haven't had the need -
|
112
|
+
look at `./lib/capistrano/tasks/storage.rake` and send a PR if you're interested!
|
113
|
+
|
114
|
+
#### Amazon S3
|
115
|
+
|
116
|
+
An existing S3 bucket is required.
|
117
|
+
|
118
|
+
Credentials are not set anywhere in Capistrano, it's assumed you're using IAM instance profiles or have ENV vars set for credentials - if this isn't the case create an issue or send a PR!
|
119
|
+
|
120
|
+
The following configuration is required and must be set:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
set :slug_s3_bucket, 'foo-slug-bucket'
|
124
|
+
```
|
125
|
+
|
126
|
+
Object uploads are set to the `:private` ACL and uploaded with server side encryption - they're not configurable I think these are sane options for this use case.
|
127
|
+
|
128
|
+
It currently relies on the `aws` cli being installed on the server: https://aws.amazon.com/cli/
|
129
|
+
|
130
|
+
|
131
|
+
## Contributing
|
132
|
+
|
133
|
+
1. Fork it
|
134
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
135
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
136
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
137
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'capistrano-slug'
|
7
|
+
spec.version = '0.1.0'
|
8
|
+
spec.authors = ['Robert Coleman']
|
9
|
+
spec.email = ['github@robert.net.nz']
|
10
|
+
spec.summary = %q{Capistrano tasks to make deployment artifacts}
|
11
|
+
spec.description = %q{Capistrano tasks to make deployment artifacts}
|
12
|
+
spec.homepage = 'https://github.com/rjocoleman/capistrano-slug'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
namespace :slug do
|
2
|
+
|
3
|
+
desc 'Create Slug'
|
4
|
+
task :create do
|
5
|
+
on primary fetch(:slug_role) do
|
6
|
+
slug_file = "#{fetch(:tmp_dir)}/#{fetch(:application)}/#{fetch(:slug_name)}-slug.tar.gz"
|
7
|
+
info "Slug: Creating #{slug_file}"
|
8
|
+
execute "tar czf #{slug_file} -C #{deploy_path} ."
|
9
|
+
info "Slug: Successfully created #{slug_file}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# pluggable storage backends are in storage.rake
|
14
|
+
desc 'Upload Slug'
|
15
|
+
task :upload do
|
16
|
+
invoke "slug:upload:#{fetch(:slug_storage_backend)}"
|
17
|
+
end
|
18
|
+
|
19
|
+
task :clean do
|
20
|
+
on primary fetch(:slug_role) do
|
21
|
+
slug_file = "#{fetch(:tmp_dir)}/#{fetch(:application)}/#{fetch(:slug_name)}-slug.tar.gz"
|
22
|
+
execute :rm, slug_file
|
23
|
+
info "Slug: Cleaned #{slug_file}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Create & upload a new slug'
|
30
|
+
task :slug => ['slug:create', 'slug:upload', 'slug:clean']
|
31
|
+
|
32
|
+
namespace :load do
|
33
|
+
task :defaults do
|
34
|
+
|
35
|
+
set :slug_name, -> { fetch(:application) }
|
36
|
+
set :slug_role, :web
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
namespace :slug do
|
2
|
+
namespace :upload do
|
3
|
+
|
4
|
+
task :s3 do
|
5
|
+
on primary fetch(:slug_role) do
|
6
|
+
slug_file = "#{fetch(:slug_name)}-slug.tar.gz"
|
7
|
+
slug = "#{fetch(:tmp_dir)}/#{fetch(:application)}/#{slug_file}"
|
8
|
+
execute :aws, "s3 cp #{slug} s3://#{fetch(:slug_s3_bucket)}/#{slug_file} --acl private --sse"
|
9
|
+
info "Slug: Uploaded #{slug_file}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :load do
|
17
|
+
task :defaults do
|
18
|
+
|
19
|
+
set :slug_storage_backend, 's3'
|
20
|
+
set :slug_s3_bucket, nil
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-slug
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Coleman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Capistrano tasks to make deployment artifacts
|
42
|
+
email:
|
43
|
+
- github@robert.net.nz
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- capistrano-slug.gemspec
|
54
|
+
- lib/capistrano/slug.rb
|
55
|
+
- lib/capistrano/tasks/slug.rake
|
56
|
+
- lib/capistrano/tasks/storage.rake
|
57
|
+
homepage: https://github.com/rjocoleman/capistrano-slug
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.2.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Capistrano tasks to make deployment artifacts
|
81
|
+
test_files: []
|