docker_brick 0.0.1
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 +7 -0
- data/.gitignore +22 -0
- data/.project +17 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +24 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/brick +11 -0
- data/docker_brick.gemspec +29 -0
- data/lib/brick/application.rb +35 -0
- data/lib/brick/cli/build.rb +28 -0
- data/lib/brick/cli/core/subcommand_loader.rb +39 -0
- data/lib/brick/cli/help.rb +16 -0
- data/lib/brick/cli/project_new.rb +29 -0
- data/lib/brick/cli/run.rb +113 -0
- data/lib/brick/cli/service_new.rb +44 -0
- data/lib/brick/cli/up.rb +46 -0
- data/lib/brick/cli.rb +230 -0
- data/lib/brick/cli__validator.rb +28 -0
- data/lib/brick/config.rb +9 -0
- data/lib/brick/docker/docker_client.rb +160 -0
- data/lib/brick/generators/new_project_generator/templates/fig.yml +0 -0
- data/lib/brick/generators/new_project_generator.rb +51 -0
- data/lib/brick/generators/new_service_generator.rb +24 -0
- data/lib/brick/generators.rb +10 -0
- data/lib/brick/mixin/aliasing.rb +24 -0
- data/lib/brick/mixin/colors.rb +24 -0
- data/lib/brick/mixin/convert_to_class_name.rb +52 -0
- data/lib/brick/mixin/docker_support.rb +253 -0
- data/lib/brick/mixin/yaml_helper.rb +18 -0
- data/lib/brick/mixin.rb +8 -0
- data/lib/brick/models/project.rb +139 -0
- data/lib/brick/models/service.rb +276 -0
- data/lib/brick/models.rb +13 -0
- data/lib/brick/monkey_patches/cli.rb +24 -0
- data/lib/brick/monkey_patches/connection.rb +15 -0
- data/lib/brick/monkey_patches/docker_container.rb +28 -0
- data/lib/brick/monkey_patches/hash.rb +16 -0
- data/lib/brick/monkey_patches.rb +5 -0
- data/lib/brick/version.rb +4 -0
- data/lib/brick.rb +34 -0
- data/spec/brick_update.sh +7 -0
- data/spec/integration/brick/models/project_spec.rb +70 -0
- data/spec/projects/nc_test/fig.yml +14 -0
- data/spec/projects/nc_test/ncserver/Dockerfile +7 -0
- data/spec/projects/rails/myapp/Dockerfile +7 -0
- data/spec/projects/rails/myapp/Gemfile +2 -0
- data/spec/projects/rails/myapp/fig.yml +13 -0
- data/spec/shell/brick_update.sh +7 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/unit/brick/mixin/docker_support.yml +33 -0
- data/spec/unit/brick/mixin/docker_support_spec.rb +66 -0
- data/spec/unit/brick/models/dockerfile/Dockerfile +7 -0
- data/spec/unit/brick/models/fig_build.yml +3 -0
- data/spec/unit/brick/models/fig_completed.yml +41 -0
- data/spec/unit/brick/models/fig_dependency.yml +19 -0
- data/spec/unit/brick/models/fig_single.yml +6 -0
- data/spec/unit/brick/models/fig_volumes.yml +10 -0
- data/spec/unit/brick/models/fig_volumes_from.yml +19 -0
- data/spec/unit/brick/models/project_spec.rb +70 -0
- data/spec/unit/brick/models/service_spec.rb +80 -0
- metadata +231 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
module Mixlib
|
2
|
+
module CLI
|
3
|
+
def parse_options(argv=ARGV)
|
4
|
+
argv = argv.dup
|
5
|
+
|
6
|
+
#redefine the method from parse! to order!
|
7
|
+
opt_parser.order!(argv)
|
8
|
+
|
9
|
+
|
10
|
+
# Deal with any required values
|
11
|
+
options.each do |opt_key, opt_value|
|
12
|
+
if opt_value[:required] && !config.has_key?(opt_key)
|
13
|
+
reqarg = opt_value[:short] || opt_value[:long]
|
14
|
+
puts "You must supply #{reqarg}!"
|
15
|
+
puts @opt_parser
|
16
|
+
exit 2
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
@cli_arguments = argv
|
21
|
+
argv
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Excon
|
2
|
+
class Connection
|
3
|
+
def error_call(datum)
|
4
|
+
if datum[:error]
|
5
|
+
message = datum[:response][:body] rescue nil
|
6
|
+
|
7
|
+
if !message.nil? and message.length>0
|
8
|
+
raise(datum[:error],message)
|
9
|
+
else
|
10
|
+
raise(datum[:error])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
class Docker::Container
|
4
|
+
|
5
|
+
def self.search_by_name(name_filter, conn, query={"all"=>true})
|
6
|
+
result=[]
|
7
|
+
hashes = Docker::Util.parse_json(conn.get('/containers/json', query)) || []
|
8
|
+
list=hashes.map { |hash| Docker::Container.get(hash["Id"]) }
|
9
|
+
|
10
|
+
list = list.select{|e| e.info["Name"].include? name_filter}
|
11
|
+
|
12
|
+
result=list.sort_by{|e| -Date.parse(e.info["Created"]).to_time.to_i}
|
13
|
+
|
14
|
+
return result
|
15
|
+
end
|
16
|
+
|
17
|
+
def is_running?
|
18
|
+
running= Docker::Container.get(id).info["State"]["Running"]
|
19
|
+
end
|
20
|
+
|
21
|
+
# Check if an image exists.
|
22
|
+
def self.exist?(id, opts = {}, conn = Docker.connection)
|
23
|
+
get(id, opts, conn)
|
24
|
+
true
|
25
|
+
rescue Docker::Error::NotFoundError
|
26
|
+
false
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
class Hash
|
4
|
+
def to_ostruct
|
5
|
+
ostruct = inject({}) {|result, (key, value)|
|
6
|
+
if value.is_a?(Array)
|
7
|
+
value = value.map {|v| v.respond_to?(:to_ostruct) ? v.to_ostruct : v }
|
8
|
+
end
|
9
|
+
|
10
|
+
result[key] = value.respond_to?(:to_ostruct) ? value.to_ostruct : value
|
11
|
+
result
|
12
|
+
}
|
13
|
+
|
14
|
+
OpenStruct.new(ostruct)
|
15
|
+
end
|
16
|
+
end
|
data/lib/brick.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require "brick/version"
|
2
|
+
|
3
|
+
require 'brick/mixin'
|
4
|
+
|
5
|
+
require "brick/cli"
|
6
|
+
|
7
|
+
require "brick/cli/core/subcommand_loader"
|
8
|
+
|
9
|
+
|
10
|
+
require 'brick/application'
|
11
|
+
|
12
|
+
require 'brick/config'
|
13
|
+
|
14
|
+
require 'excon'
|
15
|
+
|
16
|
+
|
17
|
+
require "brick/cli__validator"
|
18
|
+
|
19
|
+
require 'brick/models'
|
20
|
+
|
21
|
+
require "logger"
|
22
|
+
|
23
|
+
require 'brick/monkey_patches'
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe Brick::Models::Project do
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
`docker stop $(docker ps -aq)`
|
8
|
+
`docker rm $(docker ps -aq)`
|
9
|
+
@config_file = File.join(File.dirname(__FILE__),'fig_single.yml' )
|
10
|
+
end
|
11
|
+
|
12
|
+
subject(:fig_single) { described_class.new("bdt",{:config_file=>@config_file}) }
|
13
|
+
|
14
|
+
describe '#initialize' do
|
15
|
+
|
16
|
+
context "when parsing fig_completed.yml" do
|
17
|
+
it "parse redis service" do
|
18
|
+
#service nginx
|
19
|
+
redis = OpenStruct.new
|
20
|
+
|
21
|
+
redis.images = "redis:latest"
|
22
|
+
|
23
|
+
#subject.services.each{|service|puts "links=#{service.service_config_hash["links"]}"; puts service.service_config_hash}
|
24
|
+
|
25
|
+
expect(fig_single.services["redis"].name).to eq 'bdt_redis_1'
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#create a single service from image" do
|
33
|
+
context "no link support" do
|
34
|
+
|
35
|
+
context "the redis container doesn't exist" do
|
36
|
+
it "create redis service" do
|
37
|
+
instance=fig_single.run_services 'redis'
|
38
|
+
|
39
|
+
puts instance
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "the redis container already exist" do
|
44
|
+
it "create web service" do
|
45
|
+
instance=fig_single.run_services 'redis'
|
46
|
+
|
47
|
+
puts instance
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
subject(:fig_dependency) { described_class.new("bdt",{:config_file=>File.join(File.dirname(__FILE__),'fig_dependency.yml' )}) }
|
54
|
+
|
55
|
+
describe "#create a service which has dependency" do
|
56
|
+
context "no link support" do
|
57
|
+
|
58
|
+
context "enable dependency" do
|
59
|
+
it "create web service" do
|
60
|
+
instance=fig_dependency.run_services 'web', true
|
61
|
+
|
62
|
+
fig_dependency.services.each_value{|service| expect(service.running?).to eq(true)}
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
|
5
|
+
require 'brick'
|
6
|
+
|
7
|
+
require 'ostruct'
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
Docker.logger=Logger.new(STDOUT)
|
12
|
+
|
13
|
+
|
14
|
+
RSpec.shared_context "local paths" do
|
15
|
+
def project_dir
|
16
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
test_volume:
|
3
|
+
image: "rastasheep/ubuntu-sshd:14.04"
|
4
|
+
environment:
|
5
|
+
- ABC=development
|
6
|
+
- CYCY=TEST
|
7
|
+
volumes:
|
8
|
+
- /root/hello_docker
|
9
|
+
- /root/test.rb:/test.rb:ro
|
10
|
+
- /nc_server:/test
|
11
|
+
data_container:
|
12
|
+
image: ubuntu:latest
|
13
|
+
env_array:
|
14
|
+
environment:
|
15
|
+
- ABC=development
|
16
|
+
- CYCY=TEST
|
17
|
+
env_hash:
|
18
|
+
environment:
|
19
|
+
ABC: test
|
20
|
+
CDE: cycy
|
21
|
+
command_test:
|
22
|
+
image: "rastasheep/ubuntu-sshd:14.04"
|
23
|
+
command: /bin/bash -c 'while true; do env; sleep 1; done'
|
24
|
+
port_test:
|
25
|
+
ports:
|
26
|
+
- "5432"
|
27
|
+
- "3001:22"
|
28
|
+
volume_test:
|
29
|
+
volumes:
|
30
|
+
- /root/hello_docker
|
31
|
+
- /root/test.rb:/test.rb:ro
|
32
|
+
- /nc_server:/test
|
33
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include Brick::Mixin::YamlHelper
|
3
|
+
include Brick::Mixin::DockerSupport
|
4
|
+
|
5
|
+
describe Brick::Mixin::DockerSupport do
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
@config_hash = load_yaml_file File.join(File.dirname(__FILE__),'docker_support.yml' )
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#common_config' do
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
it 'environment variable array tranformation' do
|
16
|
+
expect((transform_docker_hash @config_hash['env_array'])["Env"]).to eq ["ABC=development","CYCY=TEST"]
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'environment variable hash tranformation' do
|
20
|
+
expect((transform_docker_hash @config_hash['env_hash'])["Env"]).to eq ["ABC=test","CDE=cycy"]
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'command tranformation' do
|
24
|
+
expect((transform_docker_hash @config_hash['command_test'])["Cmd"]).to eq ["/bin/bash","-c","while true; do env; sleep 1; done"]
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
describe '#create_config' do
|
31
|
+
#create_config_hash = create_config @config_hash
|
32
|
+
it 'port configruation for creating container' do
|
33
|
+
expect((create_config @config_hash['port_test'])["ExposedPorts"]).to eq({"5432/tcp"=>{}, "22/tcp"=>{}})
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'port attribute should be removed creating container' do
|
37
|
+
expect((create_config @config_hash['port_test'])["Ports"]).to eq nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'volume configruation for creating container' do
|
41
|
+
expect((create_config @config_hash['volume_test'])["Volumes"]).to eq({"/root/hello_docker"=>{}, "/test.rb"=>{}, "/test"=>{}})
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#start_config' do
|
48
|
+
#create_config_hash = start_config @config_hash
|
49
|
+
it 'port configruation for starting container' do
|
50
|
+
expect((start_config @config_hash['port_test'])["PortBindings"]).to eq({"5432/tcp"=>[{ "HostPort"=> "5432" }], "22/tcp"=>[{ "HostPort"=> "3001" }]})
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'port attribute should be removed starting container' do
|
54
|
+
expect((start_config @config_hash['port_test'])["Ports"]).to eq nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'volume configruation for starting container' do
|
58
|
+
expect((start_config @config_hash['volume_test'])["Binds"]).to eq(["/root/hello_docker:/root/hello_docker:rw","/root/test.rb:/test.rb:ro","/nc_server:/test:rw"])
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'volume attribute should be removed starting container' do
|
62
|
+
expect((start_config @config_hash['volume_test'])["Volumes"]).to eq nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
nginx:
|
3
|
+
image: "nginx:latest"
|
4
|
+
links:
|
5
|
+
- web
|
6
|
+
- registry
|
7
|
+
ports:
|
8
|
+
- "9080:80"
|
9
|
+
- "9443:443"
|
10
|
+
volumes:
|
11
|
+
- "./nginx/nginx.conf:/etc/nginx/conf.d/docker-registry.conf:ro"
|
12
|
+
- "./nginx/docker-registry.key:/etc/nginx/docker-registry.key:ro"
|
13
|
+
- "./nginx/docker-registry.cert:/etc/nginx/docker-registry.cert:ro"
|
14
|
+
- "./nginx/docker-registry.conf:/etc/nginx/docker-registry.conf:ro"
|
15
|
+
- "./nginx/docker-registry.htpasswd:/etc/nginx/docker-registry.htpasswd:ro"
|
16
|
+
registry:
|
17
|
+
environment:
|
18
|
+
CACHE_REDIS_HOST: redis
|
19
|
+
CACHE_REDIS_PORT: 6379
|
20
|
+
SEARCH_BACKEND: sqlalchemy
|
21
|
+
SETTINGS_FLAVOR: local
|
22
|
+
SQLALCHEMY_INDEX_DATABASE: "sqlite:////var/docker-registry-storage/docker-registry.db"
|
23
|
+
STORAGE_PATH: /var/docker-registry-storage
|
24
|
+
image: "registry:latest"
|
25
|
+
links:
|
26
|
+
- redis
|
27
|
+
ports:
|
28
|
+
- "5000:5000"
|
29
|
+
volumes:
|
30
|
+
- "/var/docker-registry-storage:/var/docker-registry-storage"
|
31
|
+
web:
|
32
|
+
build: "."
|
33
|
+
environment:
|
34
|
+
DOCKER_HUB_USER: USERNAME
|
35
|
+
DOCKER_HUB_PASSWORD: PASSWORD
|
36
|
+
links:
|
37
|
+
- redis
|
38
|
+
- registry
|
39
|
+
redis:
|
40
|
+
image: "redis:latest"
|
41
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
db:
|
3
|
+
image: rastasheep/ubuntu-sshd:14.04
|
4
|
+
ports:
|
5
|
+
- "5432"
|
6
|
+
- "3001:22"
|
7
|
+
tty: true
|
8
|
+
Command: /usr/sbin/sshd -D
|
9
|
+
web:
|
10
|
+
image: ubuntu:latest
|
11
|
+
command: /bin/bash -c 'while true; do env; sleep 1; done'
|
12
|
+
ports:
|
13
|
+
- "3000:22"
|
14
|
+
tty: true
|
15
|
+
links:
|
16
|
+
- db
|
17
|
+
environment:
|
18
|
+
ABC: test
|
19
|
+
CDE: cycy
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
data_container:
|
3
|
+
image: ubuntu:latest
|
4
|
+
volumes:
|
5
|
+
- /hello_docker
|
6
|
+
- /tmp/test.rb:/test.rb:ro
|
7
|
+
- /tmp:/test
|
8
|
+
command: /bin/bash -c 'while true; do env; sleep 1; done'
|
9
|
+
app_container:
|
10
|
+
image: "rastasheep/ubuntu-sshd:14.04"
|
11
|
+
ports:
|
12
|
+
- "3005:22"
|
13
|
+
volumes_from:
|
14
|
+
- data_container
|
15
|
+
interactive_container:
|
16
|
+
image: ubuntu:latest
|
17
|
+
command: /bin/bash
|
18
|
+
tty: true
|
19
|
+
open_stdin: true
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe Brick::Models::Project do
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
`docker stop $(docker ps -aq)`
|
8
|
+
`docker rm $(docker ps -aq)`
|
9
|
+
@config_file = File.join(File.dirname(__FILE__),'fig_single.yml' )
|
10
|
+
end
|
11
|
+
|
12
|
+
subject(:fig_single) { described_class.new("bdt",{:config_file=>@config_file}) }
|
13
|
+
|
14
|
+
describe '#initialize' do
|
15
|
+
|
16
|
+
context "when parsing fig_completed.yml" do
|
17
|
+
it "parse redis service" do
|
18
|
+
#service nginx
|
19
|
+
redis = OpenStruct.new
|
20
|
+
|
21
|
+
redis.images = "redis:latest"
|
22
|
+
|
23
|
+
#subject.services.each{|service|puts "links=#{service.service_config_hash["links"]}"; puts service.service_config_hash}
|
24
|
+
|
25
|
+
expect(fig_single.services["redis"].name).to eq 'bdt_redis_1'
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#create a single service from image" do
|
33
|
+
context "no link support" do
|
34
|
+
|
35
|
+
context "the redis container doesn't exist" do
|
36
|
+
it "create redis service" do
|
37
|
+
instance=fig_single.run_services 'redis'
|
38
|
+
|
39
|
+
puts instance
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "the redis container already exist" do
|
44
|
+
it "create web service" do
|
45
|
+
instance=fig_single.run_services 'redis'
|
46
|
+
|
47
|
+
puts instance
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
subject(:fig_dependency) { described_class.new("bdt",{:config_file=>File.join(File.dirname(__FILE__),'fig_dependency.yml' )}) }
|
54
|
+
|
55
|
+
describe "#create a service which has dependency" do
|
56
|
+
context "no link support" do
|
57
|
+
|
58
|
+
context "enable dependency" do
|
59
|
+
it "create web service" do
|
60
|
+
instance=fig_dependency.run_services 'web', true
|
61
|
+
|
62
|
+
fig_dependency.services.each_value{|service| expect(service.running?).to eq(true)}
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include Brick::Mixin::YamlHelper
|
3
|
+
|
4
|
+
describe Brick::Models::Service do
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
`docker stop $(docker ps -aq)`
|
8
|
+
`docker rm $(docker ps -aq)`
|
9
|
+
@client = Brick::Docker::DockerClient::default
|
10
|
+
`mkdir -p /hello_docker`
|
11
|
+
`echo hello > /tmp/test.rb`
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'test data volumes' do
|
15
|
+
|
16
|
+
config_hash = load_yaml_file File.join(File.dirname(__FILE__),'fig_volumes.yml' )
|
17
|
+
|
18
|
+
subject(:fig_volumes) { described_class.new("test_volume", config_hash["test_volume"],@client ) }
|
19
|
+
|
20
|
+
it 'if it has volumes config' do
|
21
|
+
fig_volumes.run
|
22
|
+
|
23
|
+
expect(fig_volumes.container_info["Volumes"]).to eq({"/root/hello_docker"=>"/root/hello_docker", "/test"=>"/nc_server", "/test.rb"=>"/root/test.rb"})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'test data volumes' do
|
28
|
+
config_hash = load_yaml_file File.join(File.dirname(__FILE__),'fig_volumes_from.yml' )
|
29
|
+
|
30
|
+
subject(:data_container) { described_class.new("data_container", config_hash["data_container"],@client ) }
|
31
|
+
|
32
|
+
subject(:app_container) { described_class.new("app_container", config_hash["app_container"],@client ) }
|
33
|
+
|
34
|
+
it 'app_container volumes from data_container' do
|
35
|
+
app_container.update_volumes_from({"data_container" => data_container})
|
36
|
+
app_container.run
|
37
|
+
|
38
|
+
expect(app_container.running?).to eq true
|
39
|
+
expect(data_container.running?).to eq true
|
40
|
+
|
41
|
+
expect(app_container.container_info["Volumes"]).to eq({"/hello_docker"=> "/hello_docker",
|
42
|
+
"/test"=> "/tmp",
|
43
|
+
"/test.rb"=> "/tmp/test.rb"
|
44
|
+
})
|
45
|
+
|
46
|
+
expect(app_container.container_info["HostConfig"]["VolumesFrom"]).to eq(["data_container:rw"])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
describe 'test interactive container' do
|
52
|
+
config_hash = load_yaml_file File.join(File.dirname(__FILE__),'fig_volumes_from.yml' )
|
53
|
+
config_hash.merge!({"tty"=>true, "open_stdin"=>true})
|
54
|
+
|
55
|
+
subject(:interactive_container) { described_class.new("interactive_container", config_hash["interactive_container"],@client ) }
|
56
|
+
it 'interactive container' do
|
57
|
+
local_logger=Docker.logger
|
58
|
+
Docker.logger=nil
|
59
|
+
interactive_container.run
|
60
|
+
|
61
|
+
#interactive_container.attach
|
62
|
+
Docker.logger=local_logger
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '.build' do
|
67
|
+
config_hash = load_yaml_file File.join(File.dirname(__FILE__),'fig_build.yml' )
|
68
|
+
|
69
|
+
subject(:build_image) { described_class.new("build_image", config_hash["build_image"],@client ) }
|
70
|
+
|
71
|
+
context "build image from relative path" do
|
72
|
+
|
73
|
+
it "build image from docker file" do
|
74
|
+
build_image.build "test_build_image",true, File.dirname(__FILE__)
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|