stack_car 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc0c3e1f27e698861c2c9bccffd68f6879ff9da5
4
- data.tar.gz: e666418ddb4ac4a73d01e0eed0ac40db91c6435a
3
+ metadata.gz: 185a0b49e3f2bdac8994507a50f3454d1455df64
4
+ data.tar.gz: 1a924d44567950615378184317b421e9c9ccee51
5
5
  SHA512:
6
- metadata.gz: e16e46c835e97f0807ead8f7b7166f83cf03b4cc3428bd8678c4523edba79c5e8a4907172753c136e682970efb1196e06f961b4910a43f4a6ffccad8652e87a1
7
- data.tar.gz: 6c444905ee7725c0258ac4f8a1aa5199276271363928c3ebf5566bf6e6a21ef6ea8b7f133f758d07b985c94ce406239f9516473422d2462a46d812b65a8d132d
6
+ metadata.gz: c65cd894261123a12ebf2ac3f47a39b57a44aea50f87e1d481e255b755c9edc490ffa32dd4ae9e61e777be0cc3c44e89e2b43ea885ffe236da8f3540577862f1
7
+ data.tar.gz: 24e5e23aceb5cbd161017047ef4ee1d54b01288877d21ad3e8598659bd90b8f5c9f617c005a31e30c346bff01295ca2dbff3037737bfe7e1edfd3d53fb4e8ce6
data/lib/stack_car/cli.rb CHANGED
@@ -25,78 +25,78 @@ module StackCar
25
25
  run("docker-compose pull #{options[:service]}")
26
26
  end
27
27
 
28
- run("docker-compose up #{args.join(' ')} #{options[:service]}")
28
+ run_with_exit("docker-compose up #{args.join(' ')} #{options[:service]}")
29
29
  end
30
30
 
31
31
  method_option :service, default: '', type: :string, aliases: '-s'
32
32
  desc "stop", "stops the specified running service, defaults to all"
33
33
  def stop
34
34
  run("docker-compose stop #{options[:service]}")
35
- run("rm -rf tmp/pids/*")
35
+ run_with_exit("rm -rf tmp/pids/*")
36
36
  end
37
37
  map down: :stop
38
38
 
39
39
  method_option :service, default: 'web', type: :string, aliases: '-s'
40
40
  desc "build", "builds specified service, defaults to web"
41
41
  def build
42
- run("docker-compose build #{options[:service]}")
42
+ run_with_exit("docker-compose build #{options[:service]}")
43
43
  end
44
44
 
45
45
  method_option :service, default: 'web', type: :string, aliases: '-s'
46
46
  desc "push ARGS", "wraps docker-compose push web unless --service is used to specify"
47
47
  def push(*args)
48
- run("docker-compose push #{options[:service]} #{args.join(' ')}")
48
+ run_with_exit("docker-compose push #{options[:service]} #{args.join(' ')}")
49
49
  end
50
50
 
51
51
  method_option :service, default: 'web', type: :string, aliases: '-s'
52
52
  desc "pull ARGS", "wraps docker-compose pull web unless --service is used to specify"
53
53
  def pull(*args)
54
- run("docker-compose pull #{options[:service]} #{args.join(' ')}")
54
+ run_with_exit("docker-compose pull #{options[:service]} #{args.join(' ')}")
55
55
  end
56
56
 
57
57
  method_option :service, default: '', type: :string, aliases: '-s'
58
58
  desc "ps ARGS", "wraps docker-compose pull web unless --service is used to specify"
59
59
  def ps(*args)
60
- run("docker-compose ps #{options[:service]} #{args.join(' ')}")
60
+ run_with_exit("docker-compose ps #{options[:service]} #{args.join(' ')}")
61
61
  end
62
62
  map status: :ps
63
63
 
64
64
  method_option :service, default: 'web', type: :string, aliases: '-s'
65
65
  desc "bundle ARGS", "wraps docker-compose run web unless --service is used to specify"
66
66
  def bundle(*args)
67
- run("docker-compose exec #{options[:service]} bundle")
67
+ run_with_exit("docker-compose exec #{options[:service]} bundle")
68
68
  end
69
69
 
70
70
  method_option :service, default: 'web', type: :string, aliases: '-s'
71
71
  desc "walk ARGS", "wraps docker-compose run web unless --service is used to specify"
72
72
  def walk(*args)
73
- run("docker-compose run #{options[:service]} #{args.join(' ')}")
73
+ run_with_exit("docker-compose run #{options[:service]} #{args.join(' ')}")
74
74
  end
75
75
 
76
76
  method_option :service, default: 'web', type: :string, aliases: '-s'
77
77
  desc "exec ARGS", "wraps docker-compose exec web unless --service is used to specify"
78
78
  def exec(*args)
79
- run("docker-compose exec #{options[:service]} #{args.join(' ')}")
79
+ run_with_exit("docker-compose exec #{options[:service]} #{args.join(' ')}")
80
80
  end
81
81
  map ex: :exec
82
82
 
83
83
  method_option :service, default: 'web', type: :string, aliases: '-s'
84
84
  desc 'sh ARGS', "launch a shell using docker-compose exec, sets tty properly"
85
85
  def sh(*args)
86
- run("docker-compose exec -e COLUMNS=\"\`tput cols\`\" -e LINES=\"\`tput lines\`\" #{options[:service]} bash #{args.join(' ')}")
86
+ run_with_exit("docker-compose exec -e COLUMNS=\"\`tput cols\`\" -e LINES=\"\`tput lines\`\" #{options[:service]} bash #{args.join(' ')}")
87
87
  end
88
88
 
89
89
  method_option :service, default: 'web', type: :string, aliases: '-s'
90
90
  desc "bundle_exec ARGS", "wraps docker-compose exec web bundle exec unless --service is used to specify"
91
91
  def bundle_exec(*args)
92
- run("docker-compose exec #{options[:service]} bundle exec #{args.join(' ')}")
92
+ run_with_exit("docker-compose exec #{options[:service]} bundle exec #{args.join(' ')}")
93
93
  end
94
94
  map be: :bundle_exec
95
95
 
96
96
  method_option :service, default: 'web', type: :string, aliases: '-s'
97
97
  desc "console ARGS", "shortcut to start rails console"
98
98
  def console(*args)
99
- run("docker-compose exec #{options[:service]} bundle exec rails console #{args.join(' ')}")
99
+ run_with_exit("docker-compose exec #{options[:service]} bundle exec rails console #{args.join(' ')}")
100
100
  end
101
101
  map rc: :console
102
102
 
@@ -107,29 +107,29 @@ module StackCar
107
107
  registry = "#{ENV['REGISTRY_HOST']}#{ENV['REGISTRY_URI']}"
108
108
  tag = ENV["TAG"] || 'latest'
109
109
  unless File.exists?("#{ENV['HOME']}/.docker/config.json") && File.readlines("#{ENV['HOME']}/.docker/config.json").grep(/#{ENV['REGISTRY_HOST']}/).size > 0
110
- run("docker login #{ENV['REGISTRY_HOST']}")
110
+ run_with_exit("docker login #{ENV['REGISTRY_HOST']}")
111
111
  end
112
- run("docker tag #{registry}:#{tag} #{registry}:#{environment}-#{timestamp}")
113
- run("docker push #{registry}:#{environment}-#{timestamp}")
114
- run("docker tag #{registry}:#{tag} #{registry}:#{sha}")
115
- run("docker push #{registry}:#{sha}")
116
- run("docker tag #{registry}:#{tag} #{registry}:#{environment}-latest")
117
- run("docker push #{registry}:#{environment}-latest")
118
- run("docker tag #{registry}:#{tag} #{registry}:latest")
119
- run("docker push #{registry}:latest")
112
+ run_with_exit("docker tag #{registry}:#{tag} #{registry}:#{environment}-#{timestamp}")
113
+ run_with_exit("docker push #{registry}:#{environment}-#{timestamp}")
114
+ run_with_exit("docker tag #{registry}:#{tag} #{registry}:#{sha}")
115
+ run_with_exit("docker push #{registry}:#{sha}")
116
+ run_with_exit("docker tag #{registry}:#{tag} #{registry}:#{environment}-latest")
117
+ run_with_exit("docker push #{registry}:#{environment}-latest")
118
+ run_with_exit("docker tag #{registry}:#{tag} #{registry}:latest")
119
+ run_with_exit("docker push #{registry}:latest")
120
120
  end
121
121
 
122
122
  desc "provision ENVIRONMENT", "configure the servers for docker and then deploy an image"
123
123
  def provision(environment)
124
124
  # TODO make dotenv load a specific environment?
125
- run("DEPLOY_ENV=#{environment} dotenv ansible-playbook -i ops/hosts -l #{environment}:localhost ops/provision.yml")
125
+ run_with_exit("DEPLOY_ENV=#{environment} dotenv ansible-playbook -i ops/hosts -l #{environment}:localhost ops/provision.yml")
126
126
  end
127
127
 
128
128
  desc "ssh ENVIRONMENT", "log in to a running instance - requires PRODUCTION_SSH to be set"
129
129
  def ssh(environment)
130
130
  target = ENV["#{environment.upcase}_SSH"]
131
131
  if target
132
- run(target)
132
+ run_with_exit(target)
133
133
  else
134
134
  say "Please set #{environment.upcase}_SSH"
135
135
  end
@@ -137,7 +137,7 @@ module StackCar
137
137
 
138
138
  desc "deploy ENVIRONMENT", "deploy an image from the registry"
139
139
  def deploy(environment)
140
- run("DEPLOY_HOOK=$DEPLOY_HOOK_#{environment.upcase} dotenv ansible-playbook -i ops/hosts -l #{environment}:localhost ops/deploy.yml")
140
+ run_with_exit("DEPLOY_HOOK=$DEPLOY_HOOK_#{environment.upcase} dotenv ansible-playbook -i ops/hosts -l #{environment}:localhost ops/deploy.yml")
141
141
  end
142
142
 
143
143
  method_option :elasticsearch, default: false, type: :boolean, aliases: '-e'
@@ -257,5 +257,12 @@ module StackCar
257
257
  post_apt.join(" && \\\n")
258
258
  end
259
259
 
260
+ def run_with_exit(*args)
261
+ result = run(*args)
262
+ if !result
263
+ exit(1)
264
+ end
265
+ end
266
+
260
267
  end
261
268
  end
@@ -1,3 +1,3 @@
1
1
  module StackCar
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  <% if options[:postgres] -%>
2
+ env DB_ADAPTER;
2
3
  env POSTGRES_DB;
3
4
  env POSTGRES_USER;
4
5
  env POSTGRES_PASSWORD;
@@ -6,6 +7,7 @@ env POSTGRES_HOST;
6
7
  env TEST_DB;
7
8
  <% end -%>
8
9
  <% if options[:mysql] -%>
10
+ env DB_ADAPTER;
9
11
  env MYSQL_DATABASE;
10
12
  env MYSQL_USER;
11
13
  env MYSQL_PASSWORD;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stack_car
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Kaufman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-21 00:00:00.000000000 Z
11
+ date: 2018-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler