rat_deployer 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rat_deployer/cli.rb +6 -79
- data/lib/rat_deployer/config.rb +5 -0
- data/lib/rat_deployer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 262cf16b057028e511cd9d5e4e9396248c0cd725
|
4
|
+
data.tar.gz: c08531236e1d4ec9257344c42e367812239b7f19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbbc4deeef649ba8bf002bfdd14bdcf99633624a301bf074e494ea4c3393a11c2b72e1d3fca01915a8e2e4f8dfedf929cc767576b79af8d8296791a37cd2ecd7
|
7
|
+
data.tar.gz: dec480736bdfc188b5b3e9c66e0f88b8651fc4d5063950d7741a69b3b2a3a01c84b809b1cc77f3e56c516dff1f850a1c8b0f65305a7827db98f056b4273075be
|
data/lib/rat_deployer/cli.rb
CHANGED
@@ -1,88 +1,15 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'fileutils'
|
3
|
-
require 'active_support/core_ext/string/strip'
|
4
3
|
|
5
|
-
require 'rat_deployer/
|
6
|
-
require 'rat_deployer/
|
4
|
+
require 'rat_deployer/commands/compose'
|
5
|
+
require 'rat_deployer/commands/deploy'
|
6
|
+
require 'rat_deployer/commands/docker'
|
7
7
|
|
8
8
|
module RatDeployer
|
9
9
|
# The main Thor subclass
|
10
10
|
class Cli < Thor
|
11
|
-
include
|
12
|
-
|
13
|
-
|
14
|
-
def deploy(*services)
|
15
|
-
RatDeployer::Notifier.notify_deploy_start
|
16
|
-
do_deploy(*services)
|
17
|
-
RatDeployer::Notifier.notify_deploy_end
|
18
|
-
rescue StandardError => e
|
19
|
-
RatDeployer::Notifier.notify <<-STR.strip_heredoc
|
20
|
-
Failed deploy on #{RatDeployer::Config.env}
|
21
|
-
Reason:
|
22
|
-
#{e.message}
|
23
|
-
STR
|
24
|
-
raise e
|
25
|
-
end
|
26
|
-
|
27
|
-
desc 'compose ARGS...', 'runs docker-compose command with default flags'
|
28
|
-
def compose(cmd, *cmd_flags, silent: false)
|
29
|
-
run(
|
30
|
-
[
|
31
|
-
'docker-compose',
|
32
|
-
compose_flags,
|
33
|
-
cmd,
|
34
|
-
cmd_flags
|
35
|
-
].flatten.join(' '),
|
36
|
-
silent: silent
|
37
|
-
)
|
38
|
-
.fetch(:output)
|
39
|
-
end
|
40
|
-
|
41
|
-
desc 'docker ARGS...', 'runs docker command with default flags'
|
42
|
-
def docker(cmd, *cmd_flags)
|
43
|
-
flags = []
|
44
|
-
|
45
|
-
if RatDeployer::Config.remote
|
46
|
-
flags.unshift(RatDeployer::Config.remote_machine_flags)
|
47
|
-
end
|
48
|
-
|
49
|
-
cmd = run "docker #{flags.join(' ')} #{cmd} #{cmd_flags.join(' ')}"
|
50
|
-
cmd.fetch(:output)
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
def do_deploy(*services)
|
56
|
-
if services.any?
|
57
|
-
services_str = services.join(' ')
|
58
|
-
compose("pull #{services_str}")
|
59
|
-
compose("up -d --no-deps --force-recreate #{services_str}")
|
60
|
-
else
|
61
|
-
compose('pull')
|
62
|
-
compose('up -d')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def compose_flags
|
67
|
-
env = RatDeployer::Config.env
|
68
|
-
project_name = RatDeployer::Config.all.fetch('project_name')
|
69
|
-
|
70
|
-
config_files =
|
71
|
-
RatDeployer::Config.for_env['config_files'] || %W[
|
72
|
-
config/default.yml
|
73
|
-
config/#{env}.yml
|
74
|
-
]
|
75
|
-
|
76
|
-
flags = [
|
77
|
-
config_files.map { |cf| "-f #{cf}" },
|
78
|
-
"-p #{project_name}_#{env}"
|
79
|
-
]
|
80
|
-
|
81
|
-
if RatDeployer::Config.remote
|
82
|
-
flags.unshift(RatDeployer::Config.remote_machine_flags)
|
83
|
-
end
|
84
|
-
|
85
|
-
flags
|
86
|
-
end
|
11
|
+
include Commands::Compose::Extension
|
12
|
+
include Commands::Deploy::Extension
|
13
|
+
include Commands::Docker::Extension
|
87
14
|
end
|
88
15
|
end
|
data/lib/rat_deployer/config.rb
CHANGED
data/lib/rat_deployer/version.rb
CHANGED