dockerize_rails 1.0.4.beta.1 → 1.1.0.beta.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dec7544d02ad55713f66af3f0f00a8d32a4478ba
4
- data.tar.gz: 14d4eb5844cca1fba3fd981acf02d40a7da6509b
3
+ metadata.gz: ea87914734606304a4d7e5e2c3bc82e39f4b9042
4
+ data.tar.gz: e01d48138e3b396a7a59b28269bbc05d7182adcf
5
5
  SHA512:
6
- metadata.gz: f5b67358641d2df848b6d3891413d61854a29354c31be6caa85e153db09402cf47f18ce3ec8a754bb765683d2a70bb320bd4cc0fe19c572c7c0d3155f06a3c03
7
- data.tar.gz: a398ca61528e1c4543078e69665c6bc14a4eef15fb33cc088efd037170849b54768503630b6825e7c3eab21940aef6238f96e3aeaf472b6ce3b7cc8c18eada46
6
+ metadata.gz: 11bbc0991e17ba4fc93a828e30127a526dea76629e5ecec02e9bc24efcd7eec2e62d2db56d4b0ff1703845261863cb4758f94e082fb08b9ca4247ae0f8d324a9
7
+ data.tar.gz: eac738f7c2eded4ee097493a06829d5e5fea3135698323db8d9d8bf8203ae0cfa2fbe1a6d948e9a0a184223443991fd638cbdf6a6917b000ebfae7868a260e7b
data/README.md CHANGED
@@ -31,6 +31,8 @@ $ bundle exec dock dockerize --test-env
31
31
  $ bundle exec dock undockerize
32
32
  $ bundle exec dock undockerize --purge
33
33
  $ bundle exec dock docker_info
34
+ $ bundle exec dock docker_pull
35
+ $ bundle exec dock docker_build
34
36
  ```
35
37
 
36
38
  ## Demo
@@ -15,6 +15,10 @@ module DockerizeRails
15
15
  return undockerize
16
16
  when *(commands[:docker_info])
17
17
  return docker_info
18
+ when *(commands[:docker_pull])
19
+ return docker_pull
20
+ when *(commands[:docker_build])
21
+ return docker_build
18
22
  when *(commands[:help])
19
23
  return help
20
24
  else
@@ -60,5 +64,17 @@ module DockerizeRails
60
64
  puts
61
65
  0
62
66
  end
67
+
68
+ def self.docker_pull
69
+ DRNameSpace.load
70
+ DockerizeRails::DockerHelper.pull
71
+ 0
72
+ end
73
+
74
+ def self.docker_build
75
+ DRNameSpace.load
76
+ DockerizeRails::DockerHelper.build
77
+ return 0
78
+ end
63
79
  end
64
80
  end
@@ -31,10 +31,6 @@ module DockerizeRails
31
31
  :'--test-env' => 'generates configurations to run tests.'.freeze
32
32
  }
33
33
  },
34
- docker_info: {
35
- aliases: %I[docker_info di],
36
- help: 'Shows Docker information'.freeze
37
- },
38
34
  undockerize: {
39
35
  aliases: %I[undockerize ud du u dd],
40
36
  help: 'Removes docker configurations'.freeze,
@@ -42,9 +38,21 @@ module DockerizeRails
42
38
  :'--purge' => "also removes #{Constants::DOCKERIZE_RAILS_CONFIG_FILE_NAME}".freeze
43
39
  }
44
40
  },
41
+ docker_info: {
42
+ aliases: %I[docker_info di],
43
+ help: 'Shows Docker information'.freeze
44
+ },
45
+ docker_pull: {
46
+ aliases: %I[docker_pull pull dp],
47
+ help: 'Pulls Docker images'.freeze
48
+ },
49
+ docker_build: {
50
+ aliases: %I[docker_build build db],
51
+ help: 'Builds Docker images'.freeze
52
+ },
45
53
  help: {
46
54
  aliases: %I[help h],
47
- help: 'prints this message'.freeze
55
+ help: 'Prints this message'.freeze
48
56
  }
49
57
  }.freeze
50
58
  end
@@ -5,5 +5,104 @@ module DockerizeRails
5
5
  def self.version
6
6
  Docker.version
7
7
  end
8
+
9
+ def self.pull
10
+ status = 0
11
+ Docker::Image.create('fromImage' => "ruby:#{DRConfig.ruby_version}")
12
+ puts "Base image 'ruby:#{DRConfig.ruby_version}' ready".green
13
+ status += pull_mysql
14
+ status += pull_postgres
15
+ status
16
+ rescue Docker::Error::NotFoundError => e
17
+ puts
18
+ puts e.to_s.red
19
+ puts
20
+ 1
21
+ end
22
+
23
+ def self.build
24
+ status = 0
25
+ image = Docker::Image.build_from_dir(
26
+ '.',
27
+ dockerfile: "#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::RAILS_DIRECTORY_NAME}/Dockerfile"
28
+ )
29
+ image.tag(repo: "#{DRConfig.application_name}_rails", tag: "#{DRConfig.application_env}")
30
+ puts "Image '#{DRConfig.application_name}_rails:#{DRConfig.application_env}' build success".green
31
+ status += build_postgres
32
+ status += build_mysql
33
+ status
34
+ rescue Docker::Error::NotFoundError => e
35
+ puts
36
+ puts e.to_s.red
37
+ puts
38
+ 1
39
+ end
40
+
41
+ def self.pull_mysql
42
+ if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'mysql'
43
+ Docker::Image.create('fromImage' => "mysql:#{DRConfig.mysql_version}")
44
+ puts "Base image 'mysql:#{DRConfig.mysql_version}' ready".green
45
+ end
46
+ 0
47
+ rescue Docker::Error::NotFoundError => e
48
+ puts
49
+ puts e.to_s.red
50
+ puts
51
+ 1
52
+ end
53
+
54
+ def self.pull_postgres
55
+ if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'postgresql'
56
+ Docker::Image.create('fromImage' => "postgres:#{DRConfig.postgres_version}")
57
+ puts "Base image 'postgres:#{DRConfig.postgres_version}' ready".green
58
+ end
59
+ 0
60
+ rescue Docker::Error::NotFoundError => e
61
+ puts
62
+ puts e.to_s.red
63
+ puts
64
+ 1
65
+ end
66
+
67
+ def self.build_mysql
68
+ if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'mysql'
69
+ image = Docker::Image.build_from_dir(
70
+ '.',
71
+ dockerfile: "#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::MYSQL_DIRECTORY_NAME}/Dockerfile"
72
+ )
73
+ image.tag(repo: "#{DRConfig.application_name}_mysql", tag: "#{DRConfig.application_env}")
74
+ puts "Image '#{DRConfig.application_name}_mysql:#{DRConfig.application_env}' build success".green
75
+ end
76
+ 0
77
+ rescue Docker::Error::NotFoundError => e
78
+ puts
79
+ puts e.to_s.red
80
+ puts
81
+ 1
82
+ end
83
+
84
+ def self.build_postgres
85
+ if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'postgresql'
86
+ image = Docker::Image.build_from_dir(
87
+ '.',
88
+ dockerfile: "#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::PG_DIRECTORY_NAME}/Dockerfile"
89
+ )
90
+ image.tag(repo: "#{DRConfig.application_name}_postgres", tag: "#{DRConfig.application_env}")
91
+ puts "Image '#{DRConfig.application_name}_postgres:#{DRConfig.application_env}' build success".green
92
+ end
93
+ 0
94
+ rescue Docker::Error::NotFoundError => e
95
+ puts
96
+ puts e.to_s.red
97
+ puts
98
+ 1
99
+ end
100
+
101
+ class << self
102
+ private :build_mysql
103
+ private :build_postgres
104
+ private :pull_mysql
105
+ private :pull_postgres
106
+ end
8
107
  end
9
108
  end
@@ -1,3 +1,3 @@
1
1
  module DockerizeRails
2
- VERSION = '1.0.4.beta.1'.freeze
2
+ VERSION = '1.1.0.beta.1'.freeze
3
3
  end
@@ -5,6 +5,7 @@ services:
5
5
  build:
6
6
  context: .
7
7
  dockerfile: ./<%= "#{Constants::CONFIG_DIRECTORY_NAME}/rails/Dockerfile" %>
8
+ image: <%= "#{DRConfig.application_name}_rails:#{application_env}" %>
8
9
  expose:
9
10
  - '<%= application_port %>'
10
11
  ports:
@@ -24,6 +25,7 @@ services:
24
25
  build:
25
26
  context: .
26
27
  dockerfile: ./<%= "#{Constants::CONFIG_DIRECTORY_NAME}/#{databases[application_env]}/Dockerfile" %>
28
+ image: <%= "#{DRConfig.application_name}_#{databases[application_env]}:#{application_env}" %>
27
29
  volumes:
28
30
  - './<%= "#{Constants::CONFIG_DIRECTORY_NAME}/#{databases[application_env]}/#{Constants::DATA_DIRECTORY_NAME}" %>:/var/lib/<%= databases[application_env] %>:rw'
29
31
  ports:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockerize_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4.beta.1
4
+ version: 1.1.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - indrajit
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-02 00:00:00.000000000 Z
11
+ date: 2017-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api