docker_rails_proxy 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/docker_rails_proxy/commands/compose/down.rb +1 -1
- data/lib/docker_rails_proxy/commands/compose/proxy.rb +1 -1
- data/lib/docker_rails_proxy/commands/compose/up.rb +3 -3
- data/lib/docker_rails_proxy/commands/kubectl/set_kubeconfig.rb +2 -1
- data/lib/docker_rails_proxy/concerns/rsync.rb +2 -2
- data/lib/docker_rails_proxy/version.rb +1 -1
- data/lib/docker_rails_proxy.rb +26 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43babff9d7eadd9268d58e475813c95334b07637
|
4
|
+
data.tar.gz: 1216cbfd498b85552cbcaf4c46f2149c17beb2a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0af44e98d35bc23b4063edf5fcb79ab9191e7efd4d53300718c9a838b6f5ef243a7779cb6f46f24d1509e1afed84a979a04494fa9e2f2303ab8471dbcdc63ca
|
7
|
+
data.tar.gz: c0e3788f76daa3c87bc406b81fdc6326a8b48c5df8b1c796412e45af288db680f81f3fcf527898e410946e27c1156752a8b579cce6898880baa9d21dd7d43f38
|
@@ -34,9 +34,9 @@ module DockerRailsProxy
|
|
34
34
|
after_initialize :parse_options!, :set_defaults
|
35
35
|
|
36
36
|
before_process do
|
37
|
-
self.from_scratch = if
|
37
|
+
self.from_scratch = if docker_compose?
|
38
38
|
%x(docker-compose ps | grep -c #{APP_NAME}).to_i.zero?
|
39
|
-
elsif
|
39
|
+
elsif kubernetes?
|
40
40
|
%x(kubectl get deploy -l 'app=#{APP_NAME}' -o name).empty?
|
41
41
|
end
|
42
42
|
end
|
@@ -44,7 +44,7 @@ module DockerRailsProxy
|
|
44
44
|
after_process { fswatch_start }
|
45
45
|
|
46
46
|
def process
|
47
|
-
system 'docker-compose up -d' if
|
47
|
+
system 'docker-compose up -d' if docker_compose?
|
48
48
|
sync_app_and_gems_folders
|
49
49
|
|
50
50
|
set_app_container_id if app_container_id.empty?
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require 'optparse'
|
2
3
|
require 'yaml'
|
3
4
|
|
@@ -26,7 +27,7 @@ module DockerRailsProxy
|
|
26
27
|
end
|
27
28
|
|
28
29
|
before_process do
|
29
|
-
|
30
|
+
FileUtils.mkdir_p 'tmp/.kube'
|
30
31
|
|
31
32
|
absolute_dir = File.dirname(options[:path])
|
32
33
|
|
@@ -31,14 +31,14 @@ module DockerRailsProxy
|
|
31
31
|
|
32
32
|
def _rsync_host
|
33
33
|
@_rsync_host ||= begin
|
34
|
-
ip = ENV
|
34
|
+
ip = ENV.fetch('DOCKER_HOST') { '127.0.0.1' }.to_s.sub('tcp://', '').sub(/:\d+$/, '')
|
35
35
|
port = '10873'
|
36
36
|
|
37
37
|
loop do
|
38
38
|
break if (port = %x(kubectl get svc "#{APP_NAME}" -o jsonpath='{.spec.ports[?(@.name=="rsync")].nodePort}' 2> /dev/null).strip).present?
|
39
39
|
sleep 5
|
40
40
|
logger.info 'Waiting for rsync port ...'
|
41
|
-
end if Docker.
|
41
|
+
end if Docker.kubernetes_running
|
42
42
|
|
43
43
|
"rsync://#{ip}:#{port}"
|
44
44
|
end
|
data/lib/docker_rails_proxy.rb
CHANGED
@@ -126,13 +126,19 @@ module DockerRailsProxy
|
|
126
126
|
|
127
127
|
class Docker < Base
|
128
128
|
class << self
|
129
|
-
attr_accessor :vm_provisioner
|
129
|
+
attr_accessor :vm_provisioner, :kubernetes_running
|
130
130
|
end
|
131
131
|
|
132
132
|
attr_accessor :app_container_id
|
133
133
|
|
134
134
|
before_initialize do
|
135
|
-
|
135
|
+
unless system 'type docker &> /dev/null'
|
136
|
+
'Please install docker before continuing.'
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
before_initialize do
|
141
|
+
unless system 'docker ps &> /dev/null'
|
136
142
|
%(
|
137
143
|
Couldn't connect to Docker daemon you might need to run:
|
138
144
|
docker-machine start default
|
@@ -142,25 +148,35 @@ module DockerRailsProxy
|
|
142
148
|
end
|
143
149
|
|
144
150
|
before_initialize do
|
145
|
-
|
151
|
+
if ENV['DOCKER_CERT_PATH'].present?
|
152
|
+
Docker.vm_provisioner = ENV['DOCKER_CERT_PATH'].include?('.minikube') ? :minikube : :docker_machine
|
153
|
+
end
|
154
|
+
|
155
|
+
Docker.vm_provisioner ||= :docker_for_mac
|
156
|
+
end
|
157
|
+
|
158
|
+
before_initialize do
|
159
|
+
if system 'docker images | grep -c kube-apiserver &> /dev/null'
|
160
|
+
Docker.kubernetes_running = true
|
161
|
+
end
|
146
162
|
end
|
147
163
|
|
148
164
|
before_initialize do
|
149
165
|
unless system 'type kubectl &> /dev/null'
|
150
166
|
'kubectl is required, `brew install kubectl`'
|
151
|
-
end if Docker.
|
167
|
+
end if Docker.kubernetes_running
|
152
168
|
end
|
153
169
|
|
154
170
|
after_initialize :set_app_container_id
|
155
171
|
|
156
172
|
private
|
157
173
|
|
158
|
-
def
|
159
|
-
Docker.
|
174
|
+
def docker_compose?
|
175
|
+
!!Docker.kubernetes_running == false
|
160
176
|
end
|
161
177
|
|
162
|
-
def
|
163
|
-
Docker.
|
178
|
+
def kubernetes?
|
179
|
+
Docker.kubernetes_running
|
164
180
|
end
|
165
181
|
|
166
182
|
def set_app_container_id
|
@@ -168,9 +184,9 @@ module DockerRailsProxy
|
|
168
184
|
end
|
169
185
|
|
170
186
|
def get_docker_container_id(app, container: nil)
|
171
|
-
if
|
187
|
+
if docker_compose?
|
172
188
|
%x(docker ps -q --filter "name=^/#{[app, container].compact.join('_')}$").strip
|
173
|
-
elsif
|
189
|
+
elsif kubernetes?
|
174
190
|
pod_name = %x(kubectl get pod -l "app=#{app}" 2> /dev/null | grep Running | awk '{print $1}').strip
|
175
191
|
return '' if pod_name.empty?
|
176
192
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker_rails_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jairo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Configures docker-compose and provides rails command helpers
|
15
15
|
email:
|