carafe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.md +22 -0
- data/README.md +140 -0
- data/carafe.gemspec +25 -0
- data/lib/capistrano/tasks/buildhost.rake +141 -0
- data/lib/capistrano/tasks/local.rake +16 -0
- data/lib/capistrano/tasks/node.rake +120 -0
- data/lib/carafe/version.rb +3 -0
- data/lib/carafe.rb +75 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a4a7e5d60093d18eadcdf5151550524ba2811152
|
4
|
+
data.tar.gz: 041a8c124e42db6e2526bc1ab6b2b581870f9f40
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7571338becfac1a55944ca258178190c3fd15039a2d59b8762a4f95b11253e3affc1e19c197f4b9d4f21f8e93d8f21f0b821514c46070cbe3f3c23ebb16aabb8
|
7
|
+
data.tar.gz: 5eb5e9fa216d2e7c1344d33881057153f1570dc8d198c1c62db93579bd1333eba0981417bb882e2a036cda8f5b510531af7689aeb23eeed2e75c1d31e7c384ce
|
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Thomas Stratmann
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# Carafe
|
2
|
+
|
3
|
+
This is a tool for deploying Elixir applications, built upon [capistrano](http://capistranorb.com/).
|
4
|
+
|
5
|
+
Carafe requires git for hosting the source repository. It depends on
|
6
|
+
[Edeliver](https://github.com/boldpoker/edeliver) for a few parts that are not handled in
|
7
|
+
Carafe yet. Release building requires [Distillery](https://github.com/bitwalker/distillery).
|
8
|
+
|
9
|
+
Currently, only full releases, not upgrades, are supported, and archives are
|
10
|
+
kept locally.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
### Prerequisites, Ruby side
|
15
|
+
|
16
|
+
You need ruby >= 2.0 installed in your development environment. The recommended way of installing dependencies on the ruby side is via bundler. Create a `Gemfile` at
|
17
|
+
the project root containing:
|
18
|
+
|
19
|
+
```
|
20
|
+
source "https://rubygems.org"
|
21
|
+
|
22
|
+
group :development do
|
23
|
+
gem "carafe"
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
Then run `bundle install --path vendor/bundle`, followed by `bundle exec cap install`. This gives you
|
28
|
+
these additional files:
|
29
|
+
|
30
|
+
```
|
31
|
+
o .bundle/config
|
32
|
+
+ Capfile
|
33
|
+
+ Gemfile
|
34
|
+
+ Gemfile.lock
|
35
|
+
o vendor/bundle
|
36
|
+
+ config/deploy.rb
|
37
|
+
+ config/deploy/staging.rb
|
38
|
+
+ config/deploy/production.rb
|
39
|
+
```
|
40
|
+
|
41
|
+
Files behind `o` should be gitignored, the others checked in. Add the following line to the `Capfile`:
|
42
|
+
|
43
|
+
```
|
44
|
+
require "carafe"
|
45
|
+
```
|
46
|
+
|
47
|
+
### Prerequisites, Elixir side
|
48
|
+
|
49
|
+
Add these deps to your `mix.exs`:
|
50
|
+
|
51
|
+
```
|
52
|
+
defp deps do
|
53
|
+
[
|
54
|
+
{:edeliver, "~> 1.4.2"},
|
55
|
+
{:distillery, "~> 0.9"},
|
56
|
+
{:carafe, "0.2.0"}
|
57
|
+
]
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
and run `mix deps.get`. Add `:edeliver` to your `:extra_applications` AS LAST:
|
62
|
+
|
63
|
+
```
|
64
|
+
def application do
|
65
|
+
[extra_applications: [:logger, :edeliver]]
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
## Configuration
|
70
|
+
|
71
|
+
First, configure your application for [distillery](https://github.com/bitwalker/distillery/).
|
72
|
+
|
73
|
+
The [Capistrano documentation on configuration](http://capistranorb.com/documentation/getting-started/configuration/)
|
74
|
+
gives you all the technical details on configuration in general. Note that Carafe does not use most of the
|
75
|
+
variables listed there. Below you find a short introduction that gets you started.
|
76
|
+
|
77
|
+
General configuration goes into `config/deploy.rb`. Capistrano has the concept of "stages", and stage specific
|
78
|
+
configuration goes into separate files. For the `production` stage this would be `config/deploy/production.rb`.
|
79
|
+
Stage specific configuration has precedence over general one.
|
80
|
+
|
81
|
+
To configure the deployment process, we mostly set variables and declare servers, as in this example snippet:
|
82
|
+
|
83
|
+
```
|
84
|
+
set :application, "my_app"
|
85
|
+
set :repo_url, "https://github.com/...."
|
86
|
+
|
87
|
+
set :repo_path, "dummy1_repo"
|
88
|
+
set :build_path, "build_path"
|
89
|
+
server "buildhost1", user: "user", roles: ["build"]
|
90
|
+
```
|
91
|
+
|
92
|
+
Note we are declaring a host (and how to connect to via ssh) to be a build host by giving it the "build" role.
|
93
|
+
There obviously must be only one buildhost. In `config/deploy/production.rb`, we might write
|
94
|
+
|
95
|
+
```
|
96
|
+
server "main", user: "user", roles: ["app"]
|
97
|
+
```
|
98
|
+
|
99
|
+
to declare a server as a node to deploy our app to.
|
100
|
+
Documentation on the `server`
|
101
|
+
options can be found [here](http://capistranorb.com/documentation/advanced-features/properties/).
|
102
|
+
|
103
|
+
Here are the config variables honored by carafe:
|
104
|
+
|
105
|
+
|Varible|Used for/as...|
|
106
|
+
|---|---|
|
107
|
+
|`:branch`| git branch to build the release from, or :current for current branch|
|
108
|
+
|`:repo_url`| cloning the repo on the build host|
|
109
|
+
|`:repo_path`| path of repository cache on build host|
|
110
|
+
|`:mix_env`| MIX_ENV environment when running `release` mix task from distillery|
|
111
|
+
|`:application`| name of the OTP application|
|
112
|
+
|`:distillery_environment`| name of the distillery environment, defaulting to the value of :mix_env|
|
113
|
+
|`:build_path`| path to build release on build host|
|
114
|
+
|`:app_path`| path on application server where releases are unpacked and operated|
|
115
|
+
|
116
|
+
### Umbrella project deployments
|
117
|
+
|
118
|
+
A demonstration for an umbrella project is in the `dummies/dummy2` test dummy project.
|
119
|
+
|
120
|
+
## Usage
|
121
|
+
|
122
|
+
Currently, only deploying releases is supported. Every deploy scenario is a bit different, so
|
123
|
+
you need to tell how a deploy is to be done. In `deploy.rb`, add the following line:
|
124
|
+
|
125
|
+
```
|
126
|
+
task "deploy" => [
|
127
|
+
"buildhost:generate_release",
|
128
|
+
"buildhost:archive:download",
|
129
|
+
"node:archive:upload_and_unpack",
|
130
|
+
"node:full_restart"
|
131
|
+
]
|
132
|
+
```
|
133
|
+
|
134
|
+
You should now be able to perform a production deploy with the command `bundle exec cap production deploy`.
|
135
|
+
|
136
|
+
## Development & Contributing
|
137
|
+
|
138
|
+
Coming soon.
|
139
|
+
|
140
|
+
|
data/carafe.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'carafe/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "carafe"
|
8
|
+
spec.version = Carafe::VERSION
|
9
|
+
spec.authors = ["Thomas Stratmann"]
|
10
|
+
spec.email = ["thomas.stratmann@9elements.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Deployment for Elixir applications, using capistrano}
|
13
|
+
spec.description = %q{Deployment for Elixir applications, using capistrano}
|
14
|
+
spec.homepage = "https://github.com/schnittchen/carafe"
|
15
|
+
|
16
|
+
spec.files = Dir.glob("{bin,lib}/**/*.rb") +
|
17
|
+
Dir.glob("{bin,lib}/**/*.rake") +
|
18
|
+
%w(README.md LICENSE.md carafe.gemspec)
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
task "buildhost:git:check_reachable" do
|
2
|
+
on Carafe.build_host do |host|
|
3
|
+
Carafe::Buildhost.git.check_repo_is_reachable
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
desc "Creates or updates the repo cache on the build host"
|
8
|
+
task "buildhost:repo:update" => "buildhost:git:check_reachable" do
|
9
|
+
on Carafe.build_host do |host|
|
10
|
+
unless Carafe::Buildhost.git.repo_mirror_exists?
|
11
|
+
Carafe::Buildhost.git.clone_repo
|
12
|
+
else
|
13
|
+
# .clone_repo respects the repo_path, .update_mirror not.
|
14
|
+
within repo_path do
|
15
|
+
Carafe::Buildhost.git.update_mirror
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Deletes the build path on the build host"
|
22
|
+
task "buildhost:clean" do
|
23
|
+
on Carafe.build_host do |host|
|
24
|
+
execute :rm, "-rf", Carafe::Buildhost.build_path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Deletes everything in the build path on the build host, except deps/"
|
29
|
+
task "buildhost:clean:keepdeps" do
|
30
|
+
on Carafe.build_host do |host|
|
31
|
+
execute :mkdir, "-p", Carafe::Buildhost.build_path
|
32
|
+
within Carafe::Buildhost.build_path do
|
33
|
+
execute :find, %w{\( -path './deps/*' -or -path ./deps \) -or -delete}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Checks if the needed source revision is available on the build host"
|
39
|
+
task "buildhost:check_rev_available" => ["local:gather-rev", "buildhost:repo:update"] do
|
40
|
+
on Carafe.build_host do |host|
|
41
|
+
within repo_path do
|
42
|
+
rev = fetch(:rev)
|
43
|
+
execute :git, "cat-file -e #{rev}^{commit}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Prepare the build path on the build host for building a release"
|
49
|
+
task "buildhost:prepare_build_path" => ["buildhost:clean:keepdeps", "buildhost:check_rev_available"] do
|
50
|
+
on Carafe.build_host do |host|
|
51
|
+
rev= fetch(:rev)
|
52
|
+
|
53
|
+
execute :sh, "-c", "git -C #{repo_path} archive #{rev} | tar xfC - #{Carafe::Buildhost.build_path}".shellescape
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Execute `mix deps.get` on the build host"
|
58
|
+
task "buildhost:mix:deps.get" do
|
59
|
+
on Carafe.build_host do |host|
|
60
|
+
within Carafe::Buildhost.build_path do
|
61
|
+
with Carafe::Buildhost.mix_env_with_arg do
|
62
|
+
execute :mix, "local.hex", "--force"
|
63
|
+
execute :mix, "local.rebar", "--force"
|
64
|
+
execute :mix, "deps.get"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Execute `mix compile` on the build host"
|
71
|
+
task "buildhost:mix:compile" do
|
72
|
+
on Carafe.build_host do |host|
|
73
|
+
within Carafe::Buildhost.build_path do
|
74
|
+
with Carafe::Buildhost.mix_env_with_arg do
|
75
|
+
execute :mix, "compile"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Compile entire project at the build path on the build host"
|
82
|
+
task "buildhost:compile" => [
|
83
|
+
"buildhost:mix:deps.get",
|
84
|
+
"buildhost:mix:compile"
|
85
|
+
]
|
86
|
+
|
87
|
+
desc "Execute `mix release` on the build host"
|
88
|
+
task "buildhost:mix:release" do
|
89
|
+
on Carafe.build_host do |host|
|
90
|
+
within Carafe::Buildhost.build_path do
|
91
|
+
with Carafe::Buildhost.mix_env_with_arg do
|
92
|
+
execute :mix, "release", "--env=#{Carafe.distillery_environment}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "Generate release on the build host"
|
99
|
+
task "buildhost:generate_release" => [
|
100
|
+
"buildhost:prepare_build_path",
|
101
|
+
"buildhost:compile",
|
102
|
+
"buildhost:mix:release"
|
103
|
+
]
|
104
|
+
|
105
|
+
task "buildhost:gather-vsn" do
|
106
|
+
on Carafe.build_host do |host|
|
107
|
+
within Carafe::Buildhost.build_path do
|
108
|
+
with Carafe::Buildhost.mix_env_with_arg do
|
109
|
+
# Pull the version out of rel/config.exs
|
110
|
+
arg =
|
111
|
+
%Q{IO.puts Mix.Releases.Config.read!("rel/config.exs").releases[:#{Carafe.distillery_release}].version}.shellescape
|
112
|
+
|
113
|
+
vsn = capture(:mix, "run", "--no-start", "-e", arg).chomp
|
114
|
+
raise ArgumentError if vsn.empty?
|
115
|
+
|
116
|
+
set :vsn, vsn
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
task "buildhost:archive_path" => "buildhost:gather-vsn" do
|
123
|
+
vsn = fetch(:vsn)
|
124
|
+
|
125
|
+
archive_path =
|
126
|
+
Carafe::Buildhost.build_path.join(
|
127
|
+
"_build", Carafe.distillery_environment,
|
128
|
+
"rel", Carafe.distillery_release,
|
129
|
+
"releases", vsn, "#{Carafe.distillery_release}.tar.gz")
|
130
|
+
|
131
|
+
set :buildhost_archive_path, archive_path
|
132
|
+
end
|
133
|
+
|
134
|
+
task "buildhost:archive:download" => ["buildhost:archive_path", "local:archive_path"] do
|
135
|
+
buildhost_archive_path = fetch(:buildhost_archive_path)
|
136
|
+
local_archive_path = fetch(:local_archive_path)
|
137
|
+
|
138
|
+
on Carafe.build_host do |host|
|
139
|
+
download! buildhost_archive_path, local_archive_path
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
task "local:gather-rev" do
|
2
|
+
rev =
|
3
|
+
run_locally do
|
4
|
+
capture :git, "rev-parse", Carafe.rev_param
|
5
|
+
end
|
6
|
+
|
7
|
+
set :rev, rev
|
8
|
+
set :abbrev_rev, rev[0..9]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Determines and saves the local path for an archive
|
12
|
+
task "local:archive_path" do
|
13
|
+
# TODO
|
14
|
+
archive_path = "archive.tar.gz"
|
15
|
+
set :local_archive_path, archive_path
|
16
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
task "node:archive:upload_and_unpack" => "local:archive_path" do
|
2
|
+
local_archive_path = fetch(:local_archive_path)
|
3
|
+
|
4
|
+
Rake::Task["node:archive:upload"].invoke(local_archive_path)
|
5
|
+
Rake::Task["node:archive:unpack"].invoke
|
6
|
+
end
|
7
|
+
|
8
|
+
task "node:archive:upload", [:archive_path] => "local:archive_path" do |t, args|
|
9
|
+
on Carafe::Node.hosts do |host|
|
10
|
+
execute :mkdir, "-p", Carafe::Node.app_path
|
11
|
+
upload! args[:archive_path], Carafe::Node.app_path.join("archive.tar.gz")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
task "node:archive:unpack" do
|
16
|
+
on Carafe::Node.hosts do |host|
|
17
|
+
within Carafe::Node.app_path do
|
18
|
+
execute :tar, "-xzvf", "archive.tar.gz"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
#task "node:archive:unlink" do
|
24
|
+
# on Carafe::Node.hosts do |host|
|
25
|
+
# within Carafe::Node.app_path do
|
26
|
+
# execute :rm, archive_path
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
#end
|
30
|
+
|
31
|
+
|
32
|
+
desc "Pings the node on each server, fails if one is not responding"
|
33
|
+
task "node:ping" do
|
34
|
+
# TODO in case of failure, we should collect all failing nodes
|
35
|
+
# and report eventually.
|
36
|
+
script = Carafe.distillery_release
|
37
|
+
on Carafe::Node.hosts do |host|
|
38
|
+
within Carafe::Node.app_path do
|
39
|
+
execute "bin/#{script}", "ping"
|
40
|
+
info "Host #{host}: pong"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Starts all nodes. Has no effect on servers where a node is already running"
|
46
|
+
task "node:start" do
|
47
|
+
script = Carafe.distillery_release
|
48
|
+
on Carafe::Node.hosts do |host|
|
49
|
+
within Carafe::Node.app_path do
|
50
|
+
execute "bin/#{script}", "start"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Stops all nodes."
|
56
|
+
task "node:stop" do
|
57
|
+
# FIXME we should attempt to stop all nodes before potentially failing
|
58
|
+
script = Carafe.distillery_release
|
59
|
+
on Carafe::Node.hosts do |host|
|
60
|
+
within Carafe::Node.app_path do
|
61
|
+
execute "bin/#{script}", "stop"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
task "node:stop-if-running" do
|
67
|
+
script = Carafe.distillery_release
|
68
|
+
on Carafe::Node.hosts do |host|
|
69
|
+
within Carafe::Node.app_path do
|
70
|
+
if test("bin/#{script}", "ping")
|
71
|
+
execute "bin/#{script}", "stop"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "Restarts the node, making sure a new version (including ERTS) is booted."
|
78
|
+
task "node:full_restart" => ["node:stop-if-running", "node:start"] do
|
79
|
+
script = Carafe.distillery_release
|
80
|
+
app = Carafe::Node.app_name
|
81
|
+
|
82
|
+
# see https://github.com/boldpoker/edeliver/blob/0582a32546edca8e6b047c956e3dd4ef74b09ac1/libexec/erlang#L856
|
83
|
+
on Carafe::Node.hosts do |host|
|
84
|
+
within Carafe::Node.app_path do
|
85
|
+
execute <<-EOS
|
86
|
+
for i in {1..10}; do bin/#{script} ping && break || true; sleep 1; done
|
87
|
+
EOS
|
88
|
+
|
89
|
+
execute "bin/#{script}", <<-EOS
|
90
|
+
rpcterms Elixir.Edeliver run_command '[monitor_startup_progress, \"#{app}\", verbose].' | grep -e 'Started\\|^ok'
|
91
|
+
EOS
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "Attach to a running node, for introspection"
|
97
|
+
task "node:attach" do
|
98
|
+
script = Carafe.distillery_release
|
99
|
+
on Carafe::Node.hosts do |host|
|
100
|
+
|
101
|
+
puts "Attaching to node. When you are done, make sure to detach with Ctrl-D (otherwise node goes down)"
|
102
|
+
|
103
|
+
# This does not respect the configured host's ssh_options,
|
104
|
+
# and depends on the ssh binary of the local host.
|
105
|
+
|
106
|
+
args =
|
107
|
+
[
|
108
|
+
"-l#{host.user}",
|
109
|
+
"-t",
|
110
|
+
("-p#{host.port}" if host.port),
|
111
|
+
host.hostname,
|
112
|
+
"sh -c 'cd #{Carafe::Node.app_path} && bin/#{script} attach'"
|
113
|
+
].compact
|
114
|
+
|
115
|
+
pid = spawn("ssh", *args)
|
116
|
+
Process.waitpid(pid, Process::WUNTRACED)
|
117
|
+
raise "Error, node probably not running" unless $?.success?
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
data/lib/carafe.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require "carafe/version"
|
2
|
+
|
3
|
+
load File.expand_path("../capistrano/tasks/local.rake", __FILE__)
|
4
|
+
load File.expand_path("../capistrano/tasks/buildhost.rake", __FILE__)
|
5
|
+
load File.expand_path("../capistrano/tasks/node.rake", __FILE__)
|
6
|
+
|
7
|
+
module Carafe
|
8
|
+
def self.build_host
|
9
|
+
hosts = roles(:build)
|
10
|
+
|
11
|
+
if hosts.none?
|
12
|
+
raise "No build host available."
|
13
|
+
end
|
14
|
+
|
15
|
+
if hosts.length > 1
|
16
|
+
raise "There can only be one build host."
|
17
|
+
end
|
18
|
+
|
19
|
+
hosts.first
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.rev_param
|
23
|
+
branch = fetch(:branch) { raise "you need to set :branch to a branch name or :current" }
|
24
|
+
|
25
|
+
if branch == :current
|
26
|
+
"@"
|
27
|
+
else
|
28
|
+
branch
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.mix_env
|
33
|
+
fetch(:mix_env) { raise "set :mix_env in stage config!" }.to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.distillery_release
|
37
|
+
fetch(:application) { raise }
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.distillery_environment
|
41
|
+
fetch(:distillery_environment) { mix_env }
|
42
|
+
end
|
43
|
+
|
44
|
+
module Buildhost
|
45
|
+
def self.git
|
46
|
+
Capistrano::SCM::Git.new
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.build_path
|
50
|
+
Pathname(fetch(:build_path) { raise "no build_path configured" })
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.mix_env_with_arg
|
54
|
+
{ mix_env: Carafe.mix_env }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
module Node
|
59
|
+
def self.app_path
|
60
|
+
Pathname(fetch(:app_path) { raise "set :app_path node path where the release is unpacked an run" })
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.app_name
|
64
|
+
fetch(:application) { raise }
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.hosts
|
68
|
+
hosts = roles(:app)
|
69
|
+
if hosts.none?
|
70
|
+
raise "No hosts have been configured with role 'app'"
|
71
|
+
end
|
72
|
+
hosts
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: carafe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Stratmann
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-11 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.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Deployment for Elixir applications, using capistrano
|
42
|
+
email:
|
43
|
+
- thomas.stratmann@9elements.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- LICENSE.md
|
49
|
+
- README.md
|
50
|
+
- carafe.gemspec
|
51
|
+
- lib/capistrano/tasks/buildhost.rake
|
52
|
+
- lib/capistrano/tasks/local.rake
|
53
|
+
- lib/capistrano/tasks/node.rake
|
54
|
+
- lib/carafe.rb
|
55
|
+
- lib/carafe/version.rb
|
56
|
+
homepage: https://github.com/schnittchen/carafe
|
57
|
+
licenses: []
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.5.2
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Deployment for Elixir applications, using capistrano
|
79
|
+
test_files: []
|
80
|
+
has_rdoc:
|