dckerize 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d40a2a22aa0a03a3406e9f6dd3e59500935dbe7
4
- data.tar.gz: 7023801fff0459073316a43f3e2df9e241eeffd4
3
+ metadata.gz: a108c4f9368f767f4ed8c57ba4a734d68af0aadb
4
+ data.tar.gz: 9d6cf596f0b1e07eb3de11de224c452fd723ae7b
5
5
  SHA512:
6
- metadata.gz: 9f6a947f040f081cd67ee37b46cee9cc9036ba02d0b04894ff2a6f3f93114cba8311b1fc55729882bb6670195a9f705a6e6f5b4082791d5c260dcf2f1769de9d
7
- data.tar.gz: 4638884421623e3cf7a04402ef6b2ba58fb07b431ace32e937fe864051716040f0bbd4fcd62c51575906b8d1b2fd75a9c70e4b959048e3fe2b2f3aa7033e88d4
6
+ metadata.gz: b529c3e0010903feab4bee76d987d86aadd4ac859126ea611fb1c6f2b290c6179a576e56d53edeff2fba06616502c71bfa7de9e47bf61f7eeb5686056a6d00cb
7
+ data.tar.gz: b93d97b780b894c8dc0505c8bb91cfebef5b76fe94bee1b24d275bdcde9fb17c6d25dfbbb3b9f0796417a6a2db2140d097f921b3cf498f4660088fde4aa6f7b3
data/README.md CHANGED
@@ -13,9 +13,9 @@ You'll get
13
13
 
14
14
  - An ubuntu trusty image already provisioned with Docker and Docker Compose.
15
15
  - An nginx/passenger container environment for serving your application and all the necessary configurations.
16
- - A separate container running MySQL/postgres for your DB.
16
+ - A separate container running MySQL/postgres/Mongo for your DB.
17
17
  - A separate container for keeping your data using the data-only container pattern.
18
- - Extras (elasticsearch for now)
18
+ - Extras (elasticsearch and redis for now)
19
19
 
20
20
  ## Requirements
21
21
 
@@ -32,7 +32,7 @@ You need to have a Rails application already created.
32
32
 
33
33
  General usage:
34
34
 
35
- $ dckerize up APP_NAME --database=[mysql|postgres] [--extras=elasticsearch]
35
+ $ dckerize up APP_NAME --database=[mysql|postgres|mongo] [--extras=elasticsearch,redis]
36
36
 
37
37
  So for example in the root of your application run:
38
38
 
@@ -46,6 +46,10 @@ Or
46
46
 
47
47
  $ dckerize up APP_NAME --database=postgres --extras=elasticsearch
48
48
 
49
+ Or
50
+
51
+ $ dckerize up APP_NAME --database=mongo --extras=elasticsearch,redis
52
+
49
53
 
50
54
  Where APP_NAME should be the same name of your application and you must specify the database
51
55
  that you want to use.
@@ -61,7 +65,7 @@ should be declared in this file.
61
65
  - A Dockerfile for building your application.
62
66
  - A docker-compose.yml file for starting your entire enviroment inside the VM.
63
67
 
64
- ### DB configuration
68
+ ### Environment Variables Configuration
65
69
 
66
70
  ## MySQL
67
71
  In your config/database.yml add these lines to your configuration:
@@ -77,14 +81,24 @@ In your config/database.yml add these lines to your configuration:
77
81
  password: <%= ENV['POSTGRES_ENV_POSTGRES_PASSWORD'] %>
78
82
  host: postgres
79
83
 
80
- ### Extras configuration
84
+ ## Mongo
85
+
86
+ Host for Mongo
87
+
88
+ ENV['MONGO_PORT_27017_TCP_ADDR']
89
+
90
+
91
+ ## Elasticsearch
92
+
93
+ Host for elasticsearch
94
+
95
+ ENV['ELASTICSEARCH_PORT_9200_TCP_ADDR']
81
96
 
82
- #### Elasticsearch
97
+ ## Redis
83
98
 
84
- If you're using the elasticsearch-rails gem, you just need to specify the environment variables
85
- linked between the containers in your elasticsearch initializer and you'll be ready to go
99
+ Host for redis
86
100
 
87
- ELASTICSEARCH_URL = ENV['ELASTICSEARCH_URL'] || ENV['ELASTICSEARCH_PORT_9200_TCP_ADDR']
101
+ ENV['REDIS_PORT_6379_TCP_ADDR']
88
102
 
89
103
  ### Developing
90
104
 
data/dckerize.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Pablo Acuña"]
10
10
  spec.email = ["pabloacuna88@gmail.com"]
11
11
 
12
- spec.summary = %q{Supercharged Rails environment using Docker and Vagrant.}
12
+ spec.summary = %q{Supercharged Rails development using Docker containers.}
13
13
  spec.homepage = "https://github.com/pacuna/dckerize"
14
14
  spec.license = "MIT"
15
15
 
@@ -8,24 +8,32 @@ module Dckerize
8
8
  def image
9
9
  if name == 'elasticsearch'
10
10
  'elasticsearch'
11
+ elsif name == 'redis'
12
+ 'redis'
11
13
  end
12
14
  end
13
15
 
14
16
  def service_name
15
17
  if name == 'elasticsearch'
16
18
  'elasticsearch'
19
+ elsif name == 'redis'
20
+ 'redis'
17
21
  end
18
22
  end
19
23
 
20
24
  def alias
21
25
  if name == 'elasticsearch'
22
26
  'elasticsearch'
27
+ elsif name == 'redis'
28
+ 'redis'
23
29
  end
24
30
  end
25
31
 
26
32
  def env_variables
27
33
  if name == 'elasticsearch'
28
34
  ['ELASTICSEARCH_PORT_9200_TCP_ADDR', 'ELASTICSEARCH_URL']
35
+ elsif name == 'redis'
36
+ ['REDIS_PORT_6379_TCP_ADDR']
29
37
  end
30
38
  end
31
39
  end
@@ -3,19 +3,24 @@ module Dckerize
3
3
  attr_accessor :name, :db, :extras
4
4
  def initialize(name, db, extras = [])
5
5
  if db == 'mysql'
6
- @db = 'mysql:5.7'
7
- @db_password = 'MYSQL_ROOT_PASSWORD'
8
- @db_password_env = 'MYSQL_ENV_MYSQL_ROOT_PASSWORD'
9
- @db_host_env = 'MYSQL_PORT_3306_TCP_ADDR'
10
- @db_name_for_data_volume = 'mysql'
11
- @db_service_name = 'mysql'
6
+ @db = 'mysql:5.7'
7
+ @db_password = 'MYSQL_ROOT_PASSWORD'
8
+ @db_password_env = 'MYSQL_ENV_MYSQL_ROOT_PASSWORD'
9
+ @db_host_env = 'MYSQL_PORT_3306_TCP_ADDR'
10
+ @data_volume_dir = '/var/lib/mysql'
11
+ @db_service_name = 'mysql'
12
12
  elsif db == 'postgres'
13
- @db = 'postgres'
14
- @db_password = 'POSTGRES_PASSWORD'
15
- @db_password_env = 'POSTGRES_ENV_POSTGRES_PASSWORD'
16
- @db_host_env = 'POSTGRES_PORT_5432_TCP_ADDR'
17
- @db_name_for_data_volume = 'postgresql'
18
- @db_service_name = 'postgres'
13
+ @db = 'postgres'
14
+ @db_password = 'POSTGRES_PASSWORD'
15
+ @db_password_env = 'POSTGRES_ENV_POSTGRES_PASSWORD'
16
+ @db_host_env = 'POSTGRES_PORT_5432_TCP_ADDR'
17
+ @data_volume_dir = '/var/lib/postgresql'
18
+ @db_service_name = 'postgres'
19
+ elsif db == 'mongo'
20
+ @db = 'mongo'
21
+ @db_host_env = 'MONGO_PORT_27017_TCP_ADDR'
22
+ @data_volume_dir = '/data/db'
23
+ @db_service_name = 'mongo'
19
24
  end
20
25
  @name = name
21
26
 
@@ -1,8 +1,9 @@
1
1
  module Dckerize
2
2
  class Runner
3
3
 
4
- VALID_OPTIONS = ['--database=mysql', '--database=postgres', '--extras=elasticsearch']
5
- ERROR_MESSAGE = 'USAGE: dckerize up --database=[mysql|postgres] [--extras=elasticsearch]'
4
+ VALID_DBS = ['mysql', 'postgres', 'mongo']
5
+ VALID_EXTRAS = ['elasticsearch', 'redis']
6
+ ERROR_MESSAGE = 'USAGE: dckerize up APP_NAME --database=[mysql|postgres|mongo] [--extras=elasticsearch|redis]'
6
7
  def initialize(options)
7
8
  @options = options
8
9
  end
@@ -29,9 +30,19 @@ module Dckerize
29
30
  return false if @options[0] != 'up'
30
31
  # db is mandatory
31
32
  return false unless @options.grep(/--database=/).any?
33
+
32
34
  # only valid options allowed
35
+ # for dbs and extras
33
36
  @options[2..-1].each do |option|
34
- return false unless VALID_OPTIONS.include?(option)
37
+ if option.split('=')[0] == '--database'
38
+ return false unless VALID_DBS.include?(option.split('=')[1])
39
+ elsif option.split('=')[0] == '--extras'
40
+ (option.split('=')[1]).split(',').each do |extra|
41
+ return false unless VALID_EXTRAS.include?(extra)
42
+ end
43
+ else
44
+ return false
45
+ end
35
46
  end
36
47
  true
37
48
  end
@@ -1,3 +1,3 @@
1
1
  module Dckerize
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.5"
3
3
  end
@@ -1,16 +1,20 @@
1
1
  data:
2
2
  image: <%= @db %>
3
3
  name: <%= @name %>-data
4
+ <%- if @db_password -%>
4
5
  environment:
5
6
  - <%= @db_password %>=secretpassword
7
+ <%- end -%>
6
8
  volumes:
7
- - /var/lib/<%= @db_name_for_data_volume %>
9
+ - <%= @data_volume_dir %>
8
10
  command: true
9
11
  <%= @db_service_name %>:
10
12
  image: <%= @db %>
11
13
  name: <%= @name %>-db
14
+ <%- if @db_password -%>
12
15
  environment:
13
16
  - <%= @db_password %>=secretpassword
17
+ <%- end -%>
14
18
  volumes_from:
15
19
  - data
16
20
  webapp:
@@ -1,4 +1,6 @@
1
+ <%- if @db_password_env -%>
1
2
  env <%= @db_password_env %>;
3
+ <%- end -%>
2
4
  env <%= @db_host_env %>;
3
5
  <% @extras.each do |extra| -%>
4
6
  <% extra.env_variables.each do |env_variable| -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dckerize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Acuña
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-11 00:00:00.000000000 Z
11
+ date: 2015-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,5 +106,5 @@ rubyforge_project:
106
106
  rubygems_version: 2.4.6
107
107
  signing_key:
108
108
  specification_version: 4
109
- summary: Supercharged Rails environment using Docker and Vagrant.
109
+ summary: Supercharged Rails development using Docker containers.
110
110
  test_files: []