dockrails 1.0.2 → 1.0.3
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 +4 -4
- data/bin/dockrails +23 -11
- data/lib/dockrails/generate.rb +14 -13
- data/lib/dockrails/version.rb +1 -1
- data/spec/generate_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8096b68de7a31963de73702571cdc07950838d6e
|
4
|
+
data.tar.gz: ff8d5475e2de304a1654229c38ea49961acef3d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38232ab9d1ed8fdc66278c64700754117d39a5f71945d2fc8144afd0ab6fdab70fecfbf7fd7fa08d2844606b8d1bf8c33a869bef10832b8ba19c3c57fac463de
|
7
|
+
data.tar.gz: c802e14c7650ec7a4f92b9ce8aa3aa7f75ffc188c0b9e9d7f0f7328cbf2a6e0c0437e62fdd2d3d824e8325932614d1abe91623a5cc72e7dc7d06e1c1aab47b25
|
data/bin/dockrails
CHANGED
@@ -7,6 +7,7 @@ require 'dockrails'
|
|
7
7
|
program :name, 'dockrails'
|
8
8
|
program :version, Dockrails::VERSION
|
9
9
|
program :description, 'CLI to Generate and Run a Rails environment with Docker'
|
10
|
+
program :help_formatter, Commander::HelpFormatter::TerminalCompact
|
10
11
|
|
11
12
|
command :init do |c|
|
12
13
|
c.syntax = 'dockrails init'
|
@@ -17,15 +18,15 @@ command :init do |c|
|
|
17
18
|
|
18
19
|
existing_files = ["Dockerfile", "docker-compose.yml", "docker-sync.yml"].map { |file| File.exist?(file) }
|
19
20
|
if existing_files.include?(true)
|
20
|
-
say "We detected an existing Docker install in this folder"
|
21
|
-
answer = agree "Do you want to continue and override it? (yes|no)"
|
21
|
+
say "<%= color 'We detected an existing Docker install in this folder', YELLOW %>"
|
22
|
+
answer = agree "<%= color 'Do you want to continue and override it? (yes|no)', BOLD %>"
|
22
23
|
exit if !answer
|
23
24
|
end
|
24
25
|
|
25
|
-
rails_app = ask "\
|
26
|
+
rails_app = ask "\n<%= color 'Type the name of your Rails App folder', BOLD %>"
|
26
27
|
if !system("find #{rails_app} > /dev/null")
|
27
|
-
say "\
|
28
|
-
say "If you want to create a new Rails app: rails new my_app -B -d postgresql"
|
28
|
+
say "\n<%= color 'Unable to find your Rails application folder in the current path, please try again', RED %>"
|
29
|
+
say "<%= color 'If you want to create a new Rails app: rails new my_app -B -d postgresql', UNDERLINE %>"
|
29
30
|
exit
|
30
31
|
end
|
31
32
|
|
@@ -33,7 +34,7 @@ command :init do |c|
|
|
33
34
|
|
34
35
|
(generate.check_system_requirements).each do |k,v|
|
35
36
|
if v == false
|
36
|
-
say "
|
37
|
+
say "\n<%= color 'Please install #{k} in order to continue', RED%>"
|
37
38
|
exit
|
38
39
|
end
|
39
40
|
end
|
@@ -45,11 +46,11 @@ command :init do |c|
|
|
45
46
|
generate.create_docker_compose
|
46
47
|
generate.create_docker_sync
|
47
48
|
|
48
|
-
say "\
|
49
|
+
say "\n<%= color 'Successful dockerization!
|
49
50
|
Please take a look at the different files generated:
|
50
51
|
- Dockerfile
|
51
52
|
- docker-compose.yml
|
52
|
-
- docker-sync.yml"
|
53
|
+
- docker-sync.yml', GREEN%>"
|
53
54
|
|
54
55
|
say "\nStart your dockerized Rails Environement: dockrails start"
|
55
56
|
say "Familiarize yourself with the different commands: dockrails --help"
|
@@ -83,7 +84,7 @@ command :run do |c|
|
|
83
84
|
c.example 'description', 'dockrails run [web|job|db|redis] bundle install'
|
84
85
|
c.action do |args, options|
|
85
86
|
if args.size < 2
|
86
|
-
say "\n Please specify a container and command to run, ex: dockrails run app bundle install"
|
87
|
+
say "\n<%= color 'Please specify a container and command to run, ex: dockrails run app bundle install', RED%>"
|
87
88
|
else
|
88
89
|
system("docker-compose run #{args.join(" ")}")
|
89
90
|
end
|
@@ -93,12 +94,23 @@ end
|
|
93
94
|
command :attach do |c|
|
94
95
|
c.syntax = 'dockrails attach [container]'
|
95
96
|
c.summary = 'Attach TTY to a specific container (usefull for ByeBug or Pry)'
|
96
|
-
c.description = '
|
97
|
+
c.description = ''
|
98
|
+
c.example 'description', 'dockrails attach web'
|
97
99
|
c.action do |args, options|
|
98
100
|
if args.size < 1
|
99
|
-
say "\n Please specify a container, ex: dockrails attach
|
101
|
+
say "\n<%= color 'Please specify a container, ex: dockrails attach web', RED%>"
|
100
102
|
else
|
101
103
|
system("docker attach $(docker-compose ps -q #{args[0]})")
|
102
104
|
end
|
103
105
|
end
|
104
106
|
end
|
107
|
+
|
108
|
+
command :update do |c|
|
109
|
+
c.syntax = 'dockrails update'
|
110
|
+
c.summary = 'Update to latest Dockrails version'
|
111
|
+
c.description = ''
|
112
|
+
c.example 'description', 'dockrails update'
|
113
|
+
c.action do |args, options|
|
114
|
+
system("gem update dockrails")
|
115
|
+
end
|
116
|
+
end
|
data/lib/dockrails/generate.rb
CHANGED
@@ -21,23 +21,24 @@ module Dockrails
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def configure
|
24
|
-
@config[:
|
25
|
-
@config[:db] = choose("\
|
26
|
-
@config[:db_name] = ask "\
|
27
|
-
@config[:db_user] = ask "\
|
28
|
-
@config[:db_password] = ask "\
|
29
|
-
@config[:redis] = agree("\
|
30
|
-
@config[:sidekiq] = agree("\
|
31
|
-
|
32
|
-
|
33
|
-
- Ruby version: #{@config[:
|
24
|
+
@config[:ruby] = choose("\n<%= color 'Choose a ruby version?', BOLD%>", "latest", "2.4", "2.3", "2.2")
|
25
|
+
@config[:db] = choose("\n<%= color 'Choose a DB Engine', BOLD%>", :pgsql, :mysql)
|
26
|
+
@config[:db_name] = ask "\n<%= color 'Choose a database name', BOLD%>"
|
27
|
+
@config[:db_user] = ask "\n<%= color 'Choose a database username', BOLD%>"
|
28
|
+
@config[:db_password] = ask "\n<%= color 'Choose a database password', BOLD%>"
|
29
|
+
@config[:redis] = agree("\n<%= color 'Do you need a Redis DB? (yes|no)', BOLD%>")
|
30
|
+
@config[:sidekiq] = agree("\n<%= color 'Do you need a SideKiq Container? (yes|no)', BOLD%>") if @config[:redis]
|
31
|
+
|
32
|
+
say "\nSummary:
|
33
|
+
- Ruby version: #{@config[:ruby]}
|
34
34
|
- DB Engine: #{@config[:db]}
|
35
35
|
- DB Name: #{@config[:db_name]}
|
36
36
|
- DB Username: #{@config[:db_user]}
|
37
37
|
- DB Password: #{@config[:db_password]}
|
38
38
|
- Redis? #{@config[:redis]}
|
39
|
-
- Job Container? #{@config[:sidekiq] ||= false}
|
40
|
-
|
39
|
+
- Job Container? #{@config[:sidekiq] ||= false}"
|
40
|
+
|
41
|
+
user_agree = agree("\n<%= color 'Is this correct? (yes|no)', BOLD%>")
|
41
42
|
|
42
43
|
unless user_agree
|
43
44
|
configure
|
@@ -54,7 +55,7 @@ module Dockrails
|
|
54
55
|
|
55
56
|
def create_dockerfile
|
56
57
|
File.open("Dockerfile", 'w') do |f|
|
57
|
-
f.write("FROM ruby:#{@config[:
|
58
|
+
f.write("FROM ruby:#{@config[:ruby]}
|
58
59
|
RUN apt-get update && apt-get install -y \
|
59
60
|
build-essential \
|
60
61
|
wget \
|
data/lib/dockrails/version.rb
CHANGED
data/spec/generate_spec.rb
CHANGED
@@ -56,7 +56,7 @@ describe Dockrails::Generate do
|
|
56
56
|
@app_path = "rails_app"
|
57
57
|
|
58
58
|
@config_with_redis = {
|
59
|
-
|
59
|
+
ruby: "latest",
|
60
60
|
db: :pgsql,
|
61
61
|
db_name: "rails",
|
62
62
|
db_user: "rails",
|
@@ -66,7 +66,7 @@ describe Dockrails::Generate do
|
|
66
66
|
}
|
67
67
|
|
68
68
|
@config_without_redis = {
|
69
|
-
|
69
|
+
ruby: "latest",
|
70
70
|
db: :pgsql,
|
71
71
|
db_name: "rails",
|
72
72
|
db_user: "rails",
|
@@ -76,7 +76,7 @@ describe Dockrails::Generate do
|
|
76
76
|
}
|
77
77
|
|
78
78
|
@config_with_mysql = {
|
79
|
-
|
79
|
+
ruby: "latest",
|
80
80
|
db: :mysql,
|
81
81
|
db_name: "rails",
|
82
82
|
db_user: "rails",
|