docker-rails 0.8.0 → 0.9.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: 081568a69c2479bd51fc791e354c457a60b88801
4
- data.tar.gz: 2d93f559d571ffd94e847fb8fa5949bdb18cc3e3
3
+ metadata.gz: 1a5253c80fa206c480db1e56b738ef2fbfe46733
4
+ data.tar.gz: 0c33db371899c5ec86ef344867ec5e5316f1116c
5
5
  SHA512:
6
- metadata.gz: 2920bab9b004243d8873b3e78712348c4ac718f006e0d3df7c8690bbdede4f337b365b6d26bd9a06b47296c83bdb52651fcab941b18721a3d258eb532130bfcd
7
- data.tar.gz: c6dc7fb1bc824563a72a252cb6561045e411164ac32b229e515633c6f9e6a392ea2664d493fe6847b567d4a030ec75e533dbcc515d798b91be759951cf3871a5
6
+ metadata.gz: 5fad7285f5e03e731e3fc382edc7b4ace5da6de9b65de221de1902f7969291509a85b9849fa328df43641f1a493166f9b2641e0137004ca60a09d06f0db6bfbe
7
+ data.tar.gz: 461bc62fac672e235fc63a2de848b11d2f6a2010f9a4549e160338e7df175e3eec318049fc9099531dced3683da074ee3f278e9d54275790b52e812c4d186187
@@ -1 +1 @@
1
- ruby-2.2.2
1
+ ruby-2.3.1
data/README.md CHANGED
@@ -13,7 +13,6 @@ A simplified pattern to execute rails applications within Docker (with a CI buil
13
13
  - Interpolates variables `docker-compose.yml` making CI builds much easier
14
14
  - DB check CLI function provided for docker-compose `command` to check if db is ready
15
15
  - Configurable exit_code for `ci` - determine which container's exit code will be the result of the process (useful for CI tests)
16
- - Declarative ssh key sharing via SSH Agent Forwarding, including making `known_hosts` available to targeted containers.
17
16
 
18
17
  ## Usage
19
18
 
@@ -28,12 +27,11 @@ CI, the reason this is built. Do it all, do it consistently, do it concurrently,
28
27
  `ci` executes:
29
28
 
30
29
  1. `before_command` - run anything on the host prior to building the docker image e.g. `rm -Rf target`
31
- 2. `compose` - create the resolved `docker-compose.yml`
32
- 3. `gemset_volume create` - find or create the shared global gems volume for this ruby version
33
- 4. `ssh_agent forward` - forward any declared keys and copy in `known_hosts`
34
- 5. `build` - `docker-compose build` the configuration
35
- 6. `up` - `docker-compose up` the configuration
36
- 7. `cleanup`
30
+ 1. `compose` - create the resolved `docker-compose.yml`
31
+ 1. `gemset_volume create` - find or create the shared global gems volume for this ruby version
32
+ 1. `build` - `docker-compose build` the configuration
33
+ 1. `up` - `docker-compose up` the configuration
34
+ 1. `cleanup`
37
35
  1. `stop` - stop all containers for this configuration (including one-off sessions)
38
36
  2. `extract` - extract any defined files from any container
39
37
  3. `rm_volumes` - `docker-compose rm -v --force` to cleanup any container volumes (excluding the gems volume)
@@ -87,7 +85,6 @@ Commands:
87
85
  docker-rails ps_all # List all remaining containers regardless of state e.g. docker-rails ps_all
88
86
  docker-rails rm_dangling # Remove danging images e.g. docker-rails rm_dangling
89
87
  docker-rails rm_volumes <target> # Stop all running containers and remove corresponding volumes for the given build/target e.g. docker-rails rm_volumes --build=222 development
90
- docker-rails ssh_agent <command> # SSH Agent Forwarding e.g. docker-rails ssh_agent forward
91
88
  docker-rails stop <target> # Stop all running containers for the given build/target e.g. docker-rails stop --build=222 development
92
89
  docker-rails up <target> # Up the docker-compose configuration for the given build/target. Use -d for detached mode. e.g. docker-rails up -d --build=222 test
93
90
 
@@ -159,16 +156,6 @@ gemset:
159
156
  containers:
160
157
  - web
161
158
 
162
- # ---
163
- # Make the host user's id_rsa key available to the web container e.g. for cloning from github
164
- # If you see "Host key verification failed", make sure the same command runs on the host first
165
- # which will add to the known_hosts file. The known_hosts is copied from the host to the ssh-agent automatically.
166
- ssh-agent:
167
- containers:
168
- - web
169
- keys:
170
- - id_rsa
171
-
172
159
  # ---
173
160
  # Declare a reusable extract set
174
161
  extractions: &extractions
@@ -197,9 +184,11 @@ compose:
197
184
  working_dir: /project/spec/dummy
198
185
  ports:
199
186
  - "3000"
200
-
201
187
  links:
202
188
  - db
189
+ volumes:
190
+ # make keys and known_hosts available
191
+ - ~/.ssh:/root/.ssh
203
192
 
204
193
  db:
205
194
  # https://github.com/docker-library/docs/tree/master/mysql
@@ -18,6 +18,5 @@ require 'docker/rails/app'
18
18
 
19
19
  require 'docker/rails/cli/db_check'
20
20
  require 'docker/rails/cli/gemset_volume'
21
- require 'docker/rails/cli/ssh_agent'
22
21
 
23
22
  require 'docker/rails/cli/main'
@@ -161,7 +161,6 @@ module Docker
161
161
  end
162
162
  end
163
163
  end
164
- rm_ssh_agent
165
164
  puts 'Done.'
166
165
  end
167
166
 
@@ -209,24 +208,6 @@ module Docker
209
208
  container
210
209
  end
211
210
 
212
- def run_ssh_agent
213
- return if @config[:'ssh-agent'].nil?
214
- run_ssh_agent_daemon
215
- ssh_add_keys
216
- ssh_add_known_hosts
217
- end
218
-
219
- def rm_ssh_agent
220
- ssh_agent_name = @config.ssh_agent_name
221
- begin
222
- container = Docker::Container.get(ssh_agent_name)
223
- stop(container)
224
- rm_v(container)
225
- rescue Docker::Error::NotFoundError => e
226
- puts "SSH Agent forwarding container #{ssh_agent_name} does not exist."
227
- end
228
- end
229
-
230
211
  # Create global gems data volume to cache gems for this version of ruby
231
212
  # https://docs.docker.com/userguide/dockervolumes/
232
213
  def create_gemset_volume
@@ -360,41 +341,6 @@ module Docker
360
341
  end
361
342
  end
362
343
 
363
- def ssh_agent_image
364
- 'whilp/ssh-agent:latest'
365
- # 'rosskevin/ssh-agent:latest'
366
- end
367
-
368
- def ssh_base_cmd
369
- ssh_agent_name = @config.ssh_agent_name
370
- "docker run --rm --volumes-from=#{ssh_agent_name} -v ~/.ssh:/ssh #{ssh_agent_image}"
371
- end
372
-
373
- def ssh_add_known_hosts
374
- exec "#{ssh_base_cmd} cp /ssh/known_hosts /root/.ssh/known_hosts"
375
- end
376
-
377
- def ssh_add_keys
378
- ssh_keys = @config[:'ssh-agent'][:keys]
379
- puts "Forwarding SSH key(s): #{ssh_keys.join(',')} into container(s): #{@config[:'ssh-agent'][:containers].join(',')}"
380
- ssh_keys.each do |key_file_name|
381
- local_key_file = "#{ENV['HOME']}/.ssh/#{key_file_name}"
382
- raise "Local key file #{local_key_file} doesn't exist." unless File.exists? local_key_file
383
- exec "#{ssh_base_cmd} ssh-add /ssh/#{key_file_name}"
384
- end
385
- end
386
-
387
- def run_ssh_agent_daemon
388
- ssh_agent_name = @config.ssh_agent_name
389
- begin
390
- Docker::Container.get(ssh_agent_name)
391
- puts "Gem data volume container #{ssh_agent_name} already exists."
392
- rescue Docker::Error::NotFoundError => e
393
- exec "docker run -d --name=#{ssh_agent_name} #{ssh_agent_image}"
394
- puts "SSH Agent forwarding container #{ssh_agent_name} running."
395
- end
396
- end
397
-
398
344
  def rm_v(container)
399
345
  container.remove(v: true, force: true)
400
346
  end
@@ -12,9 +12,6 @@ module Docker
12
12
  desc 'gemset_volume <command>', 'Gemset volume management e.g. docker-rails gemset_volume create'
13
13
  subcommand 'gemset_volume', Docker::Rails::CLI::GemsetVolume
14
14
 
15
- desc 'ssh_agent <command>', 'SSH Agent Forwarding e.g. docker-rails ssh_agent forward'
16
- subcommand 'ssh_agent', Docker::Rails::CLI::SshAgent
17
-
18
15
  desc 'ci <target>', 'Execute the works, everything with cleanup included e.g. docker-rails ci --build=222 test'
19
16
  long_desc <<-D
20
17
 
@@ -30,7 +27,6 @@ module Docker
30
27
  invoke :before, [target], []
31
28
  invoke :compose, [target], []
32
29
  invoke CLI::GemsetVolume, :create, [target], options
33
- invoke CLI::SshAgent, :forward, [target], options
34
30
  begin
35
31
  invoke :build # on CI - always build to ensure dockerfile hasn't been altered - small price to pay for consistent CI.
36
32
  invoke :up
@@ -71,7 +67,6 @@ module Docker
71
67
 
72
68
  invoke :before, [target], base_options
73
69
  invoke CLI::GemsetVolume, :create, [target], base_options
74
- invoke CLI::SshAgent, :forward, [target], base_options
75
70
 
76
71
  if options[:detached]
77
72
  compose_options = '-d'
@@ -166,7 +161,6 @@ module Docker
166
161
 
167
162
  invoke :compose, [target], []
168
163
  invoke CLI::GemsetVolume, :create, [target], []
169
- invoke CLI::SshAgent, :forward, [target], []
170
164
 
171
165
  app.run_service_command(service_name, command)
172
166
  end
@@ -29,10 +29,6 @@ module Docker
29
29
  end
30
30
 
31
31
 
32
- def ssh_agent_name
33
- "#{self[:project_name]}_ssh_agent"
34
- end
35
-
36
32
  def write_docker_compose_file(output_filename = 'docker-compose.yml')
37
33
  write_yaml_file(output_filename, self[:'compose'])
38
34
  end
@@ -64,10 +60,6 @@ module Docker
64
60
  generated_defaults = {compose: {}}
65
61
  compose = generated_defaults[:compose]
66
62
 
67
- # ----
68
- # ssh-agent
69
- generate_ssh_agent(compose, unpruned_config)
70
-
71
63
  # ----
72
64
  # gemset volume
73
65
  generate_gemset(compose, unpruned_config, generated_defaults, filenames)
@@ -117,29 +109,6 @@ module Docker
117
109
  })
118
110
  end
119
111
  end
120
-
121
- def generate_ssh_agent(compose, unpruned_config)
122
- ssh_agent = unpruned_config[:'ssh-agent']
123
- if !ssh_agent.nil?
124
-
125
- raise "Expected to find 'ssh-agent: keys' with at least one entry" if ssh_agent[:keys].nil? || ssh_agent[:keys].length < 1
126
- ssh_agent[:containers].each do |container|
127
- raise "Unknown container #{container}" if unpruned_config[:compose][container.to_sym].nil?
128
- # environment:
129
- # # make ssh keys available via ssh forwarding (see volume entry)
130
- # - SSH_AUTH_SOCK=/ssh-agent/socket
131
- #
132
- # volumes_from:
133
- # # Use configured whilp/ssh-agent long running container for keys
134
- # - <project_name>-ssh-agent
135
- compose[container.to_sym] ||= {}
136
- compose[container.to_sym].deeper_merge! ({
137
- environment: ['SSH_AUTH_SOCK=/root/.ssh/socket'],
138
- volumes_from: [ssh_agent_name]
139
- })
140
- end
141
- end
142
- end
143
112
  end
144
113
  end
145
114
  end
@@ -1,5 +1,5 @@
1
1
  module Docker
2
2
  module Rails
3
- VERSION = '0.8.0'
3
+ VERSION = '0.9.0'
4
4
  end
5
5
  end
@@ -81,10 +81,6 @@ describe Docker::Rails::Config do
81
81
  compose_config
82
82
  }
83
83
 
84
- it 'web should have ssh-agent' do
85
- expect(compose_config[:web][:environment]).to include('SSH_AUTH_SOCK=/root/.ssh/socket')
86
- expect(compose_config[:web][:volumes_from]).to include("#{project_name}_ssh_agent")
87
- end
88
84
  it 'web should have gemset' do
89
85
  expect(compose_config[:web][:environment]).to include('GEM_HOME=/gemset/2.2.2')
90
86
  expect(compose_config[:web][:volumes_from]).to include('gemset-2.2.2')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Ross
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-12 00:00:00.000000000 Z
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -160,7 +160,6 @@ files:
160
160
  - lib/docker/rails/cli/db_check.rb
161
161
  - lib/docker/rails/cli/gemset_volume.rb
162
162
  - lib/docker/rails/cli/main.rb
163
- - lib/docker/rails/cli/ssh_agent.rb
164
163
  - lib/docker/rails/compose_config.rb
165
164
  - lib/docker/rails/config.rb
166
165
  - lib/docker/rails/ext/container.rb
@@ -189,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
188
  version: '0'
190
189
  requirements: []
191
190
  rubyforge_project:
192
- rubygems_version: 2.4.8
191
+ rubygems_version: 2.5.1
193
192
  signing_key:
194
193
  specification_version: 4
195
194
  summary: A simplified pattern to execute rails applications within Docker (with a
@@ -1,17 +0,0 @@
1
- module Docker
2
- module Rails
3
- module CLI
4
- class SshAgent < Thor
5
- desc 'forward', 'Run SSH Agent Forwarding'
6
- def forward(target = nil)
7
- App.configured(target, options).run_ssh_agent
8
- end
9
-
10
- desc 'rm', 'Stop and remove SSH Agent Forwarding'
11
- def rm(target = nil)
12
- App.configured(target, options).rm_ssh_agent
13
- end
14
- end
15
- end
16
- end
17
- end