rumination 0.10.9 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rumination/deploy/base.rb +35 -21
- data/lib/rumination/deploy/class_methods.rb +11 -1
- data/lib/rumination/deploy.rb +1 -0
- data/lib/rumination/tasks/deploy/bootstrap.rake +13 -5
- data/lib/rumination/tasks/deploy/inside.rake +48 -0
- data/lib/rumination/version.rb +1 -1
- data/rumination.gemspec +1 -0
- metadata +17 -3
- data/lib/rumination/tasks/deploy/finish.rake +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66594db74940cc8e881895374f4db6fcb127f88b
|
4
|
+
data.tar.gz: af8b9b0f57b35eb6c07e8a38d132c61c4f7d8c1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a96cfe47c6ed05f07e496a4c627f16c985833be199d725d8ef9d0cc082cc2bacbfeabeec57d889c3c3b684580ee8d48212297a97838efcf961372293bbf9f69
|
7
|
+
data.tar.gz: 99eb7b026868a0fdbf2f6f1d58f28e49e6e84e31c19406f9be94148493ab57405141fc108c25641f08c8eb595dc628e25bf5377df1be1cfa25dead9b0a19dc7a
|
@@ -15,26 +15,30 @@ module Rumination
|
|
15
15
|
load_target_config
|
16
16
|
end
|
17
17
|
|
18
|
-
def bootstrap
|
19
|
-
call do
|
20
|
-
raise BootstrappedAlready if bootstrapped?
|
21
|
-
copy_dump_if_requested
|
22
|
-
app_container.run("rake deploy:bootstrap:inside[#{target}]")
|
23
|
-
raise BootstrapError unless $? == 0
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
18
|
def call
|
28
19
|
setup_outside_env
|
29
20
|
DockerCompose.build.down("--remove-orphans").up
|
30
21
|
app_container.run("bundle install") if cached_gems?
|
31
|
-
yield if block_given?
|
32
|
-
app_container.run("rake deploy:unload[#{target}]")
|
22
|
+
yield self if block_given?
|
23
|
+
app_container.run("rake deploy:inside:unload[#{target}]")
|
33
24
|
raise DeployError unless $? == 0
|
34
|
-
app_container.run("rake deploy:finish[#{target}]")
|
25
|
+
app_container.run("rake deploy:inside:finish[#{target}]")
|
35
26
|
raise DeployError unless $? == 0
|
36
27
|
end
|
37
28
|
|
29
|
+
def bootstrap
|
30
|
+
raise BootstrappedAlready if bootstrapped?
|
31
|
+
copy_dump_if_requested
|
32
|
+
app_container.run("rake deploy:inside:bootstrap[#{target}]")
|
33
|
+
raise BootstrapError unless $? == 0
|
34
|
+
end
|
35
|
+
|
36
|
+
def bootstrap_undo
|
37
|
+
raise NotBootstrappedYet unless bootstrapped?
|
38
|
+
app_container.run("rake deploy:inside:bootstrap:undo[#{target}]")
|
39
|
+
raise BootstrapError unless $? == 0
|
40
|
+
end
|
41
|
+
|
38
42
|
def load_target_config
|
39
43
|
load target_config_path
|
40
44
|
rescue LoadError => e
|
@@ -58,13 +62,24 @@ module Rumination
|
|
58
62
|
|
59
63
|
def write_env_file
|
60
64
|
File.open(env_file_path, "w") do |io|
|
61
|
-
|
62
|
-
puts
|
63
|
-
io.puts %Q[export #{var}="#{generate_password}"]
|
65
|
+
persistent_env.merge(generated_passwords).each do |var, val|
|
66
|
+
io.puts %Q[export #{var}="#{val}"]
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|
67
70
|
|
71
|
+
def rm_env_file
|
72
|
+
File.rm(env_file_path)
|
73
|
+
end
|
74
|
+
|
75
|
+
def persistent_env
|
76
|
+
config.persistent_env || {}
|
77
|
+
end
|
78
|
+
|
79
|
+
def generated_passwords
|
80
|
+
password_vars.map{|var| [var, generate_password]}.to_h
|
81
|
+
end
|
82
|
+
|
68
83
|
def generate_password
|
69
84
|
Generate.password
|
70
85
|
end
|
@@ -72,12 +87,11 @@ module Rumination
|
|
72
87
|
private
|
73
88
|
|
74
89
|
def copy_dump_if_requested
|
75
|
-
|
76
|
-
return unless
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
)
|
90
|
+
source = config.copy_dumpfile
|
91
|
+
return unless source.present?
|
92
|
+
return unless File.exists?(source)
|
93
|
+
target = Rumination.config.pg.dumpfile_path
|
94
|
+
app_container.cp_to_container source, target
|
81
95
|
end
|
82
96
|
|
83
97
|
def load_application_config_if_exists
|
@@ -4,7 +4,13 @@ module Rumination
|
|
4
4
|
module Deploy
|
5
5
|
module ClassMethods
|
6
6
|
def bootstrap target:
|
7
|
-
deploy_class.new(target).
|
7
|
+
deploy_class.new(target).call do |deploy|
|
8
|
+
deploy.bootstrap
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def bootstrap target:
|
13
|
+
deploy_class.new(target).bootstrap_undo
|
8
14
|
end
|
9
15
|
|
10
16
|
def app target:
|
@@ -19,6 +25,10 @@ module Rumination
|
|
19
25
|
deploy_class.new(target).write_env_file
|
20
26
|
end
|
21
27
|
|
28
|
+
def rm_env_file target:
|
29
|
+
deploy_class.new(target).rm_env_file
|
30
|
+
end
|
31
|
+
|
22
32
|
def deploy_class
|
23
33
|
config.deploy_class || Base
|
24
34
|
end
|
data/lib/rumination/deploy.rb
CHANGED
@@ -9,6 +9,7 @@ module Rumination
|
|
9
9
|
UnknownTarget = Class.new(DeployError)
|
10
10
|
BootstrapError = Class.new(DeployError)
|
11
11
|
BootstrappedAlready = Class.new(BootstrapError)
|
12
|
+
NotBootstrappedYet = Class.new(BootstrapError)
|
12
13
|
DatabaseInitError = Class.new(BootstrapError)
|
13
14
|
end
|
14
15
|
end
|
@@ -10,12 +10,20 @@ namespace :deploy do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
namespace :bootstrap do
|
13
|
-
|
14
|
-
task :inside, [:target] => %w[write_env_file db:setup:maybe_load_dump]
|
15
|
-
|
16
|
-
task :write_env_file, [:target] do |t, args|
|
13
|
+
task :undo, [:target] => %w[confirm_undo] do |t, args|
|
17
14
|
require "rumination/deploy"
|
18
|
-
|
15
|
+
args.with_defaults target: :development
|
16
|
+
begin
|
17
|
+
Rumination::Deploy.bootstrap_undo(target: args.target)
|
18
|
+
rescue Rumination::Deploy::NotBootstrappedYet
|
19
|
+
abort "'#{args.target}' has not been bootstrapped yet"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
task :confirm_undo, [:target] do |t, args|
|
24
|
+
require "highline/import"
|
25
|
+
question = "Do you really want to undo the bootstrap (database will be dropped)?"
|
26
|
+
abort("Bootstrap undo canceled, you didn't mean it") unless agree(question)
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
namespace :deploy do
|
2
|
+
namespace :inside do
|
3
|
+
# these are invoked inside the containers
|
4
|
+
task :bootstrap, [:target] => %w[write_env_file db:setup:maybe_load_dump]
|
5
|
+
|
6
|
+
namespace :bootstrap do
|
7
|
+
task :undo, [:target] => %w[db:drop remove_env_file]
|
8
|
+
|
9
|
+
task :remove_env_file, [:target] do |t, args|
|
10
|
+
Rumination::Deploy.rm_env_file(target: args.target)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
task :write_env_file, [:target] do |t, args|
|
15
|
+
require "rumination/deploy"
|
16
|
+
Rumination::Deploy.write_env_file(target: args.target)
|
17
|
+
end
|
18
|
+
|
19
|
+
task :unload, [:target] do |t, args|
|
20
|
+
vhost = ENV["VIRTUAL_HOST"]
|
21
|
+
if vhost.present?
|
22
|
+
sh "rm -f /etc/nginx/vhost.d/#{vhost}*"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
task :finish, [:target] => %w[static_files vhost_conf]
|
27
|
+
|
28
|
+
task :static_files, [:target] do |t, args|
|
29
|
+
vhost = ENV["VIRTUAL_HOST"]
|
30
|
+
if vhost
|
31
|
+
sh "rsync -av public/ /var/www/#{vhost}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
task :vhost_conf, [:target] do |t, args|
|
36
|
+
def erb_config basename, vhost
|
37
|
+
template = "config/nginx/vhost.d/#{basename}.erb"
|
38
|
+
if vhost && File.exists?(template)
|
39
|
+
new_name = basename.sub("app", vhost)
|
40
|
+
sh "erb #{template} > /etc/nginx/vhost.d/#{new_name}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
vhost = ENV["VIRTUAL_HOST"]
|
44
|
+
erb_config "app", vhost
|
45
|
+
erb_config "app_location", vhost
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/rumination/version.rb
CHANGED
data/rumination.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rumination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Baguinski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: highline
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: development utilities
|
112
126
|
email:
|
113
127
|
- abaguinski@depraktijkindex.nl
|
@@ -145,7 +159,7 @@ files:
|
|
145
159
|
- lib/rumination/tasks/deploy.rake
|
146
160
|
- lib/rumination/tasks/deploy/bootstrap.rake
|
147
161
|
- lib/rumination/tasks/deploy/env.rake
|
148
|
-
- lib/rumination/tasks/deploy/
|
162
|
+
- lib/rumination/tasks/deploy/inside.rake
|
149
163
|
- lib/rumination/version.rb
|
150
164
|
- rumination.gemspec
|
151
165
|
homepage: https://github.com/artm/rumination
|
@@ -1,30 +0,0 @@
|
|
1
|
-
namespace :deploy do
|
2
|
-
task :unload, [:target] do |t, args|
|
3
|
-
vhost = ENV["VIRTUAL_HOST"]
|
4
|
-
if vhost.present?
|
5
|
-
sh "rm -f /etc/nginx/vhost.d/#{vhost}*"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
task :finish, [:target] => %w[static_files vhost_conf]
|
10
|
-
|
11
|
-
task :static_files, [:target] do |t, args|
|
12
|
-
vhost = ENV["VIRTUAL_HOST"]
|
13
|
-
if vhost
|
14
|
-
sh "rsync -av public/ /var/www/#{vhost}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
task :vhost_conf, [:target] do |t, args|
|
19
|
-
def erb_config basename, vhost
|
20
|
-
template = "config/nginx/vhost.d/#{basename}.erb"
|
21
|
-
if vhost && File.exists?(template)
|
22
|
-
new_name = basename.sub("app", vhost)
|
23
|
-
sh "erb #{template} > /etc/nginx/vhost.d/#{new_name}"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
vhost = ENV["VIRTUAL_HOST"]
|
27
|
-
erb_config "app", vhost
|
28
|
-
erb_config "app_location", vhost
|
29
|
-
end
|
30
|
-
end
|