dctl_rb 0.10.4 → 0.10.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/exe/dctl +28 -23
- data/hi.txt +1 -0
- data/lib/dctl/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 774da376ca2b6a39d5686228cb92b41cfa2036f3a19263ba6938da34909711a9
|
4
|
+
data.tar.gz: 3435a89fdcdeccb0119cd526ee281966bc2e96141342ffb962491188b74ec5bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c42df993cc8c00fdbf34d91bc75a243eb5a41cc11707c56dfe3ca06f6f57d0a85094728b2b56de2e51151dc6c712af6c2a6c6a9fe7ee16e40065d3c9777e58d1
|
7
|
+
data.tar.gz: 86cf724b7ad1b438660142fa6774acbf4689f505cac4f04e48e1c03739f2fd062c24b077bd31683e273b4cf3fdbe32b20ac4a02284d195e3ab2b11755ebed207
|
data/Gemfile.lock
CHANGED
data/exe/dctl
CHANGED
@@ -13,7 +13,7 @@ module Dctl
|
|
13
13
|
SUCCESS_COLOR = :green
|
14
14
|
CMD_COLOR = :dimgray
|
15
15
|
|
16
|
-
class_option :env,
|
16
|
+
class_option :env, type: :string
|
17
17
|
class_option :host, type: :string
|
18
18
|
|
19
19
|
desc "build", "Build images. Pass image name to build a specific one; otherwise builds all"
|
@@ -30,9 +30,9 @@ module Dctl
|
|
30
30
|
exit 1
|
31
31
|
end
|
32
32
|
|
33
|
-
dctl = Dctl::Main.new env:
|
33
|
+
dctl = Dctl::Main.new env: dctl_env
|
34
34
|
images = dctl.expand_images *images
|
35
|
-
env =
|
35
|
+
env = dctl_env
|
36
36
|
|
37
37
|
puts "Generating build script for #{images.join(", ")}"
|
38
38
|
commands = []
|
@@ -62,7 +62,7 @@ module Dctl
|
|
62
62
|
|
63
63
|
desc "push", "Upload locally built images to the remote store"
|
64
64
|
def push(*images)
|
65
|
-
dctl = Dctl::Main.new env:
|
65
|
+
dctl = Dctl::Main.new env: dctl_env
|
66
66
|
images = dctl.expand_images *images
|
67
67
|
push_cmds = []
|
68
68
|
|
@@ -78,7 +78,7 @@ module Dctl
|
|
78
78
|
desc "pull", "Pull the latest remote images to your local machine"
|
79
79
|
option :version, type: :string, desc: "Overrde version. Default is value in compose file"
|
80
80
|
def pull(*images)
|
81
|
-
dctl = Dctl::Main.new env:
|
81
|
+
dctl = Dctl::Main.new env: dctl_env
|
82
82
|
images = dctl.expand_images *images
|
83
83
|
pull_cmds = []
|
84
84
|
|
@@ -95,7 +95,7 @@ module Dctl
|
|
95
95
|
|
96
96
|
desc "up", "Start your dockerized app server"
|
97
97
|
def up
|
98
|
-
dctl = Dctl::Main.new env:
|
98
|
+
dctl = Dctl::Main.new env: dctl_env
|
99
99
|
|
100
100
|
pidfile = "tmp/pids/server.pid"
|
101
101
|
FileUtils.rm pidfile if File.exist? pidfile
|
@@ -106,52 +106,52 @@ module Dctl
|
|
106
106
|
|
107
107
|
desc "down", "Stop one or many containers"
|
108
108
|
def down(*images)
|
109
|
-
dctl = Dctl::Main.new env:
|
109
|
+
dctl = Dctl::Main.new env: dctl_env
|
110
110
|
stream_output "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} down #{images.join(" ")}", exec: true
|
111
111
|
end
|
112
112
|
|
113
113
|
desc "rm", "Remove one or many containers"
|
114
114
|
option :force, type: :boolean, default: false, aliases: %w(f)
|
115
115
|
def rm(*images)
|
116
|
-
dctl = Dctl::Main.new env:
|
116
|
+
dctl = Dctl::Main.new env: dctl_env
|
117
117
|
opts = " --force" if options[:force]
|
118
118
|
stream_output "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} rm#{opts} #{images.join(" ")}", exec: true
|
119
119
|
end
|
120
120
|
|
121
121
|
desc "start", "Start one or many containers"
|
122
122
|
def start(*images)
|
123
|
-
dctl = Dctl::Main.new env:
|
123
|
+
dctl = Dctl::Main.new env: dctl_env
|
124
124
|
stream_output "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} start #{images.join(" ")}", exec: true
|
125
125
|
end
|
126
126
|
|
127
127
|
desc "stop", "Stop one or many containers"
|
128
128
|
def stop(*images)
|
129
|
-
dctl = Dctl::Main.new env:
|
129
|
+
dctl = Dctl::Main.new env: dctl_env
|
130
130
|
stream_output "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} stop #{images.join(" ")}", exec: true
|
131
131
|
end
|
132
132
|
|
133
133
|
desc "restart", "Restart one or many containers"
|
134
134
|
def restart(*images)
|
135
|
-
dctl = Dctl::Main.new env:
|
135
|
+
dctl = Dctl::Main.new env: dctl_env
|
136
136
|
stream_output "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} restart #{images.join(" ")}", exec: true
|
137
137
|
end
|
138
138
|
|
139
139
|
desc "create", "Bring an image up without starting it"
|
140
140
|
def create(*images)
|
141
|
-
dctl = Dctl::Main.new env:
|
141
|
+
dctl = Dctl::Main.new env: dctl_env
|
142
142
|
stream_output "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} up --no-start #{images.join(" ")}", exec: true
|
143
143
|
end
|
144
144
|
|
145
145
|
desc "run [IMAGE] [COMMAND]", "Run a command on the given image"
|
146
146
|
def runcmd(image, *commands)
|
147
|
-
dctl = Dctl::Main.new env:
|
147
|
+
dctl = Dctl::Main.new env: dctl_env
|
148
148
|
stream_output "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} run #{image} #{commands.join(" ")}", exec: true
|
149
149
|
end
|
150
150
|
|
151
151
|
desc "exec [IMAGE] [COMMAND]", "Execute a command on the given _running_ image"
|
152
152
|
map exec: :_exec # avoid overwriting Kernel#exec
|
153
153
|
def _exec(image, *commands)
|
154
|
-
dctl = Dctl::Main.new env:
|
154
|
+
dctl = Dctl::Main.new env: dctl_env
|
155
155
|
stream_output "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} exec #{image} #{commands.join(" ")}", exec: true
|
156
156
|
end
|
157
157
|
|
@@ -168,20 +168,20 @@ module Dctl
|
|
168
168
|
|
169
169
|
desc "ps", "List running containers for this environment"
|
170
170
|
def ps
|
171
|
-
dctl = Dctl::Main.new env:
|
171
|
+
dctl = Dctl::Main.new env: dctl_env
|
172
172
|
stream_output "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} ps", exec: true
|
173
173
|
end
|
174
174
|
|
175
175
|
desc "release IMAGE", "Increase the version number for the given image"
|
176
176
|
def release(image)
|
177
|
-
dctl = Dctl::Main.new env:
|
177
|
+
dctl = Dctl::Main.new env: dctl_env
|
178
178
|
dctl.release(image)
|
179
179
|
end
|
180
180
|
|
181
181
|
desc "initdb", "Setup initial postgres database"
|
182
182
|
def initdb
|
183
|
-
dctl = Dctl::Main.new env:
|
184
|
-
env =
|
183
|
+
dctl = Dctl::Main.new env: dctl_env
|
184
|
+
env = dctl_env
|
185
185
|
local_data_dir = File.expand_path "../tmp/psql-#{env}", __FILE__
|
186
186
|
`#{sudo}rm -r #{local_data_dir}` if File.exists? local_data_dir # todo prompt
|
187
187
|
|
@@ -198,7 +198,7 @@ module Dctl
|
|
198
198
|
|
199
199
|
if options[:keep] != -1
|
200
200
|
keep_last = options[:keep]
|
201
|
-
dctl = Dctl::Main.new env:
|
201
|
+
dctl = Dctl::Main.new env: dctl_env
|
202
202
|
dctl.expand_images.each do |image|
|
203
203
|
current_version = dctl.current_version_for_image(image).to_i
|
204
204
|
keep_after_tag = current_version - keep_last
|
@@ -233,7 +233,7 @@ module Dctl
|
|
233
233
|
|
234
234
|
desc "bash CONTAINER", "Create a new instance of the given image with a bash prompt"
|
235
235
|
def bash(container = "app")
|
236
|
-
dctl = Dctl::Main.new env:
|
236
|
+
dctl = Dctl::Main.new env: dctl_env
|
237
237
|
cmd = "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} run --rm #{container} /bin/bash"
|
238
238
|
|
239
239
|
stream_output cmd, exec: true
|
@@ -241,14 +241,14 @@ module Dctl
|
|
241
241
|
|
242
242
|
desc "connect CONTAINER", "Connect to a running container."
|
243
243
|
def connect(image = "app")
|
244
|
-
dctl = Dctl::Main.new env:
|
244
|
+
dctl = Dctl::Main.new env: dctl_env
|
245
245
|
stream_output "#{sudo}docker-compose #{docker_opts} -f #{dctl.compose_file_path} exec #{image} /bin/bash", exec: true
|
246
246
|
end
|
247
247
|
|
248
248
|
desc "attach CONTAINER", "Connect to a running container."
|
249
249
|
option :env, type: :string, default: "dev"
|
250
250
|
def attach(image = "app")
|
251
|
-
dctl = Dctl::Main.new env:
|
251
|
+
dctl = Dctl::Main.new env: dctl_env
|
252
252
|
tag = dctl.image_tag(image)
|
253
253
|
|
254
254
|
cmd = "#{sudo}docker #{docker_opts} ps --filter ancestor=#{image} -aq | head -n1"
|
@@ -271,7 +271,7 @@ module Dctl
|
|
271
271
|
desc "tag-for [IMAGE]", "Returns the full tag for the given image. Useful in CI."
|
272
272
|
option :version, type: :string, desc: "Override version. Defaults to the value in the compose file"
|
273
273
|
def tag_for(image)
|
274
|
-
dctl = Dctl::Main.new env:
|
274
|
+
dctl = Dctl::Main.new env: dctl_env
|
275
275
|
opts = {}
|
276
276
|
opts[:version] = options[:version] if options[:version]
|
277
277
|
puts dctl.image_tag(image, opts)
|
@@ -294,6 +294,11 @@ module Dctl
|
|
294
294
|
`uname`.chomp == "Darwin" ? "" : "sudo " # use sudo on linux hosts
|
295
295
|
end
|
296
296
|
|
297
|
+
# Support both --env and DCTL_ENV, but prefer --env if both are present
|
298
|
+
def dctl_env
|
299
|
+
options[:env] || ENV["DCTL_ENV"] || "dev"
|
300
|
+
end
|
301
|
+
|
297
302
|
def docker_opts
|
298
303
|
opts = []
|
299
304
|
|
data/hi.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
hi
|
data/lib/dctl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dctl_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Toniazzo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- bin/setup
|
149
149
|
- dctl_rb.gemspec
|
150
150
|
- exe/dctl
|
151
|
+
- hi.txt
|
151
152
|
- lib/dctl.rb
|
152
153
|
- lib/dctl/.version.rb.swp
|
153
154
|
- lib/dctl/main.rb
|