roro 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +1 -1
  3. data/lib/roro.rb +1 -0
  4. data/lib/roro/cli.rb +69 -3
  5. data/lib/roro/cli/cli.rb +99 -0
  6. data/lib/roro/cli/configuration.rb +1 -0
  7. data/lib/roro/cli/expose.rb +8 -7
  8. data/lib/roro/cli/generate/config.rb +5 -5
  9. data/lib/roro/cli/generate/generate_keys.rb +9 -25
  10. data/lib/roro/cli/greenfield.rb +10 -21
  11. data/lib/roro/cli/obfuscate.rb +10 -10
  12. data/lib/roro/cli/rollon.rb +1 -1
  13. data/lib/roro/cli/rollon/stories.rb +3 -3
  14. data/lib/roro/cli/{templates/ruby_gem/docker/env_files/.keep → rollon/stories/database.rb} +0 -0
  15. data/lib/roro/cli/rollon/stories/rails.rb +1 -0
  16. data/lib/roro/cli/rollon/{database → stories/rails/database}/database.rb +0 -0
  17. data/lib/roro/cli/rollon/{database → stories/rails/database}/with_mysql.rb +0 -0
  18. data/lib/roro/cli/rollon/{database → stories/rails/database}/with_postgres.rb +0 -0
  19. data/lib/roro/cli/rollon/stories/ruby_gem.rb +77 -0
  20. data/lib/roro/cli/rollon/stories/ruby_gem/with_ci_cd.rb +60 -0
  21. data/lib/roro/cli/rollon/stories/stories.rb +7 -0
  22. data/lib/roro/cli/ruby_gem.rb +60 -47
  23. data/lib/roro/cli/templates/base/Dockerfile.tt +53 -15
  24. data/lib/roro/cli/templates/greenfield/Dockerfile.tt +1 -1
  25. data/lib/roro/cli/templates/ruby_gem/{config.yml → .circleci/config.yml} +0 -0
  26. data/lib/roro/cli/templates/ruby_gem/docker-compose.yml +3 -3
  27. data/lib/roro/cli/templates/ruby_gem/roro/containers/gem/Dockerfile.tt +9 -0
  28. data/lib/roro/cli/templates/ruby_gem/{docker/keys → roro/env_files}/.keep +0 -0
  29. data/{tmp/.gitkeep → lib/roro/cli/templates/ruby_gem/roro/keys/.keep} +0 -0
  30. data/lib/roro/version.rb +1 -1
  31. data/roro.gemspec +2 -2
  32. data/vendor/cache/gem-release-2.1.1.gem +0 -0
  33. metadata +34 -19
  34. data/lib/roro/cli/templates/quickstart/Dockerfile.tt +0 -20
  35. data/lib/roro/cli/templates/quickstart/database.yml +0 -85
  36. data/lib/roro/cli/templates/quickstart/docker-compose.yml +0 -17
  37. data/lib/roro/cli/templates/quickstart/entrypoint.sh +0 -8
  38. data/lib/roro/cli/templates/ruby_gem/.gitignore +0 -8
  39. data/lib/roro/cli/templates/ruby_gem/docker/containers/app/Dockerfile.tt +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ec8ef8f72b6fd4ff28b8d74e1a6b85a7dc17d62af0b4e8c9f78948c51533dd4
4
- data.tar.gz: 8583287621045a0cf864d82728480ce4a80fd814bbe99112948f13327c10ce0d
3
+ metadata.gz: 5d2920a993245b49f9ac51cf665584007cd9cf1b93e5910a18201b914d62e9b1
4
+ data.tar.gz: 44fe546dafd609adb0162cc2296f8562afa7f5cd6cb23bb7b607f1aaf2b08bc6
5
5
  SHA512:
6
- metadata.gz: 444be7de23db2d83ac72cc0520386c05b4b029667469d96d17cafc39c27fae94bf26168fae05b13fc8c8d64b1160b7f1201d62b1acabede65e667d312e2f6e09
7
- data.tar.gz: 9f05dcdf81371ef94275b5b262380d5ad360edcc745e61fe7b8ec99d913b7c4d69374ddeb0770362dd5133fe35abfab813f9817688cd730d3659e813bd5cf4c3
6
+ metadata.gz: be706b2f7677d2e0b1967b645190197be96ed89cdab015bba2de649dd300d395b17acc395feb4687d2a3d7c9805d51c788fa10af3d1163d37d51ef67753d272a
7
+ data.tar.gz: 052aca113a452bf5cf9ee7c01f18e0d4c33e46cdfea5a2d97e768c0652c22d952e4d905770a985d150279c9c8efb7fa7b8a6fed2b2b165bcfa11c194a458468b
data/Guardfile CHANGED
@@ -11,7 +11,7 @@ guard :minitest, options do
11
11
 
12
12
  watch(%r{^test/(.*)\/?test_(.*)\.rb$})
13
13
  watch(%r{^test/(.*)\/?(.*)_test\.rb$})
14
- watch(%r{^lib/roro/cli/(.+)\.rb$}) { |m| "test/cli/#{m[1]}_test.rb" }
14
+ watch(%r{^lib/roro/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
15
15
  watch(%r{^test/thor_helper\.rb$}) { 'test' }
16
16
  watch(%r{^test/fixtures/files/(.*/)?([^/]+)\.yml$}) { 'test' }
17
17
  end
@@ -1,3 +1,4 @@
1
+ require 'byebug'
1
2
  require "roro/version"
2
3
  require "thor"
3
4
  require "roro/cli"
@@ -1,15 +1,13 @@
1
- require 'thor'
2
1
  require 'roro/cli/base/base'
3
- require 'roro/cli/rollon'
4
2
  require 'roro/cli/greenfield'
5
3
  require 'roro/cli/obfuscate'
6
4
  require 'roro/cli/expose'
7
- require 'roro/cli/ruby_gem'
8
5
  require 'roro/cli/generate/config/rails'
9
6
  require 'roro/cli/generate/config'
10
7
  require 'roro/cli/generate/generate_keys'
11
8
  require 'roro/cli/configuration'
12
9
 
10
+ require 'roro/cli/rollon'
13
11
  module Roro
14
12
 
15
13
  class CLI < Thor
@@ -19,5 +17,73 @@ module Roro
19
17
  def self.source_root
20
18
  File.dirname(__FILE__) + '/cli/templates'
21
19
  end
20
+
21
+
22
+ desc "rollon::rails", "Generates files for and makes changes to your app
23
+ so it can run using Docker containers."
24
+ method_option :interactive, desc: "Set up your environment variables as
25
+ you go."
26
+ map "rollon::rails" => "rollon_rails"
27
+
28
+ def rollon_rails
29
+ rollon
30
+ end
31
+
32
+
33
+ desc "greenfield::rails", "Greenfield a new, dockerized rails app with
34
+ either MySQL or PostgreSQL in a separate container."
35
+
36
+ method_option :env_vars, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "key1:value1 key2:value2"
37
+ method_option :interactive, desc: "Set up your environment variables as you go."
38
+ method_option :force, desc: "force over-write of existing files"
39
+
40
+ map "greenfield::rails" => "greenfield_rails"
41
+
42
+ def greenfield_rails(*args)
43
+ greenfield(*args)
44
+ end
45
+ desc "generate::exposed", "Generate private .env files from
46
+ encrypted .env.enc files inside the roro directory."
47
+ map "generate::exposed" => "generate_exposed"
48
+
49
+ def generate_exposed(*args)
50
+ expose(*args)
51
+ end
52
+
53
+ desc "generate::key", "Generate a key inside roro/keys. Takes the name of
54
+ an environment as an argument to private .env files from
55
+ encrypted .env.enc files inside the roro directory.
56
+ Expose encrypted files"
57
+
58
+ map "generate::key" => "generate_key"
59
+ method_option :environment, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "development, staging"
60
+
61
+ def generate_key(*args)
62
+ generate_key_or_keys(*args)
63
+ end
64
+
65
+ desc "generate::keys", "Generate keys for each environment inside roro/keys.
66
+ If you have .env files like 'roro/containers/app/[staging_env].env' and
67
+ 'roro/[circle_ci_env].env' it will generate '/roro/keys/[staging_env].key'
68
+ and '/roro/keys/[circle_ci_env].key'."
69
+ map "generate::keys" => "generate_keys"
70
+
71
+ def generate_keys(*args)
72
+ generate_key(*args)
73
+ end
74
+
75
+ desc "generate::config", "Generate a config file at .roro_config.yml"
76
+ map "generate::config" => "generate_config"
77
+
78
+ def generate_config
79
+ create_file ".roro_config.yml", @config.app.to_yaml
80
+ end
81
+
82
+ desc "generate::obfuscated", "obfuscates any files matching the pattern ./roro/**/*.env"
83
+ map "generate::obfuscated" => "generate_obfuscated"
84
+
85
+ def generate_obfuscated(*args)
86
+ obfuscate(*args)
87
+ end
22
88
  end
23
89
  end
@@ -0,0 +1,99 @@
1
+ require 'thor'
2
+ require 'roro/cli/base/base'
3
+ require 'roro/cli/rollon/stories'
4
+ require 'roro/cli/rollon'
5
+ require 'roro/cli/greenfield'
6
+ require 'roro/cli/obfuscate'
7
+ require 'roro/cli/expose'
8
+ require 'roro/cli/ruby_gem'
9
+ require 'roro/cli/generate/config/rails'
10
+ require 'roro/cli/generate/config'
11
+ require 'roro/cli/generate/generate_keys'
12
+ require 'roro/cli/configuration'
13
+
14
+ module Roro
15
+
16
+ class CLI < Thor
17
+
18
+ include Thor::Actions
19
+
20
+ def self.source_root
21
+ File.dirname(__FILE__) + '/cli/templates'
22
+ end
23
+
24
+ desc "rollon::ruby_gem", "Generate files for containerized gem testing, CircleCI, and releasing to RubyGems."
25
+ method_option :rubies, type: :array, banner: "2.5.3 2.4.2"
26
+ map "rollon::ruby_gem" => "rollon_ruby_gem"
27
+
28
+ def rollon_ruby_gem(*args)
29
+ ruby_gem(*args)
30
+ end
31
+
32
+ desc "rollon::rails", "Generates files for and makes changes to your app
33
+ so it can run using Docker containers."
34
+ method_option :interactive, desc: "Set up your environment variables as
35
+ you go."
36
+ map "rollon::rails" => "rollon_rails"
37
+
38
+ def rollon_rails
39
+ rollon
40
+ end
41
+
42
+
43
+ desc "greenfield::rails", "Greenfield a new, dockerized rails app with
44
+ either MySQL or PostgreSQL in a separate container."
45
+
46
+ method_option :env_vars, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "key1:value1 key2:value2"
47
+ method_option :interactive, desc: "Set up your environment variables as you go."
48
+ method_option :force, desc: "force over-write of existing files"
49
+
50
+ map "greenfield::rails" => "greenfield_rails"
51
+
52
+ def greenfield_rails(*args)
53
+ greenfield(*args)
54
+ end
55
+ desc "generate::exposed", "Generate private .env files from
56
+ encrypted .env.enc files inside the roro directory."
57
+ map "generate::exposed" => "generate_exposed"
58
+
59
+ def generate_exposed(*args)
60
+ expose(*args)
61
+ end
62
+
63
+ desc "generate::key", "Generate a key inside roro/keys. Takes the name of
64
+ an environment as an argument to private .env files from
65
+ encrypted .env.enc files inside the roro directory.
66
+ Expose encrypted files"
67
+
68
+ map "generate::key" => "generate_key"
69
+ method_option :environment, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "development, staging"
70
+
71
+ def generate_key(*args)
72
+ generate_key_or_keys(*args)
73
+ end
74
+
75
+ desc "generate::keys", "Generate keys for each environment inside roro/keys.
76
+ If you have .env files like 'roro/containers/app/[staging_env].env' and
77
+ 'roro/[circle_ci_env].env' it will generate '/roro/keys/[staging_env].key'
78
+ and '/roro/keys/[circle_ci_env].key'."
79
+ map "generate::keys" => "generate_keys"
80
+
81
+ def generate_keys(*args)
82
+ generate_key(*args)
83
+ end
84
+
85
+ desc "generate::config", "Generate a config file at .roro_config.yml"
86
+ map "generate::config" => "generate_config"
87
+
88
+ def generate_config
89
+ create_file ".roro_config.yml", @config.app.to_yaml
90
+ end
91
+
92
+ desc "generate::obfuscated", "obfuscates any files matching the pattern ./roro/**/*.env"
93
+ map "generate::obfuscated" => "generate_obfuscated"
94
+
95
+ def generate_obfuscated(*args)
96
+ obfuscate(*args)
97
+ end
98
+ end
99
+ end
@@ -1,3 +1,4 @@
1
+ require 'yaml'
1
2
  module Roro
2
3
  class Configuration < Thor
3
4
 
@@ -1,13 +1,14 @@
1
1
  module Roro
2
2
  class CLI < Thor
3
+
4
+ no_commands do
3
5
 
4
- desc "expose", "Expose encrypted files"
5
-
6
- def expose(*args)
7
- environments = args.first ? [args.first] : gather_environments
8
- environments.each do |environment|
9
- HandsomeFencer::Crypto.expose(environment, 'roro')
6
+ def expose(*args)
7
+ environments = args.first ? [args.first] : gather_environments
8
+ environments.each do |environment|
9
+ HandsomeFencer::Crypto.expose(environment, 'roro')
10
+ end
10
11
  end
11
12
  end
12
13
  end
13
- end
14
+ end
@@ -2,12 +2,12 @@ module Roro
2
2
  class CLI < Thor
3
3
  include Thor::Actions
4
4
 
5
- desc "generate::config::roro", "Generates a config file at .roro_config.yml"
6
- map "generate::config::roro" => "generate_roro_config"
5
+ # desc "generate::config::roro", "Generate a config file at .roro_config.yml"
6
+ # map "generate::config::roro" => "generate_roro_config"
7
7
 
8
8
 
9
- def generate_roro_config
10
- create_file ".roro_config.yml", @config.app.to_yaml
11
- end
9
+ # def generate_roro_config
10
+ # create_file ".roro_config.yml", @config.app.to_yaml
11
+ # end
12
12
  end
13
13
  end
@@ -1,33 +1,17 @@
1
- require 'openssl'
2
- require 'base64'
3
- require 'handsome_fencer/crypto'
4
-
5
1
  module Roro
6
2
 
7
3
  class CLI < Thor
4
+
5
+ no_commands do
8
6
 
9
- include Thor::Actions
10
- include HandsomeFencer::Crypto
11
-
12
- desc "generate_keys", "Generates keys for all environments. If you have .env files like './**/production.env' and './**/staging.env' this command assumes you need keys for the production and staging environments, and will generate them for you."
13
-
14
- def generate_keys
15
- generate_key
16
- end
17
-
18
- desc "generate_key", "Generate a key for each environment"
19
- method_option :environment, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "development, staging"
20
-
21
- def generate_key(*args)
22
- environments = args.first ? [args.first] : gather_environments
23
- environments.each do |environment|
24
-
25
- confirm_files_decrypted?(environment)
26
- create_file "roro/keys/#{environment}.key", encoded_key
7
+ def generate_key_or_keys(*args)
8
+ environments = args.first ? [args.first] : gather_environments
9
+ environments.each do |environment|
10
+
11
+ confirm_files_decrypted?(environment)
12
+ create_file "roro/keys/#{environment}.key", encoded_key
13
+ end
27
14
  end
28
- end
29
-
30
- no_commands do
31
15
 
32
16
  def encoded_key
33
17
  @cipher = OpenSSL::Cipher.new 'AES-128-CBC'
@@ -1,28 +1,17 @@
1
- require 'os'
2
-
3
1
  module Roro
4
2
 
5
3
  class CLI < Thor
6
-
7
- include Thor::Actions
8
-
9
- desc "greenfield", "Greenfield a brand new rails app using Docker's instructions"
10
-
11
- method_option :env_vars, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "key1:value1 key2:value2"
12
- method_option :interactive, desc: "Set up your environment variables as you go."
13
- method_option :force, desc: "force over-write of existing files"
14
-
15
-
16
- def greenfield
17
- confirm_directory_empty
18
- confirm_dependencies
19
- remove_roro_artifacts
20
- configure_for_greenfielding
21
- copy_greenfield_files
22
- run_greenfield_commands
23
- end
24
-
4
+
25
5
  no_commands do
6
+
7
+ def greenfield
8
+ confirm_directory_empty
9
+ confirm_dependencies
10
+ remove_roro_artifacts
11
+ configure_for_greenfielding
12
+ copy_greenfield_files
13
+ run_greenfield_commands
14
+ end
26
15
 
27
16
  def configure_for_greenfielding
28
17
  @config ||= Roro::Configuration.new(options)
@@ -3,16 +3,16 @@ require 'handsome_fencer/crypto'
3
3
  module Roro
4
4
 
5
5
  class CLI < Thor
6
-
7
- include Thor::Actions
8
- include HandsomeFencer::Crypto
9
-
10
- desc "obfuscate", "obfuscates any files matching the pattern ./roro/**/*.env"
11
-
12
- def obfuscate(*args)
13
- environments = args.first ? [args.first] : gather_environments
14
- environments.each do |environment|
15
- HandsomeFencer::Crypto.obfuscate(environment, 'roro')
6
+
7
+ no_commands do
8
+ include Thor::Actions
9
+ include HandsomeFencer::Crypto
10
+
11
+ def obfuscate(*args)
12
+ environments = args.first ? [args.first] : gather_environments
13
+ environments.each do |environment|
14
+ HandsomeFencer::Crypto.obfuscate(environment, 'roro')
15
+ end
16
16
  end
17
17
  end
18
18
  end
@@ -1,4 +1,4 @@
1
- require_relative 'rollon/stories'
1
+ require 'roro/cli/rollon/stories'
2
2
 
3
3
  module Roro
4
4
 
@@ -1,3 +1,3 @@
1
- require_relative 'database/with_postgres.rb'
2
- require_relative 'database/with_mysql.rb'
3
- require_relative 'database/database.rb'
1
+ require 'roro/cli/rollon/stories/ruby_gem'
2
+ require 'roro/cli/rollon/stories/rails'
3
+ require 'roro/cli/rollon/stories/database'
@@ -0,0 +1 @@
1
+ # require 'roro/cli/rollon/stories/ruby_gem/with_ci_cd.rb'
@@ -0,0 +1,77 @@
1
+ require 'roro/cli/rollon/stories/ruby_gem/with_ci_cd.rb'
2
+ # class RubyGem
3
+ # attr_reader :getsome
4
+
5
+ # def initialize
6
+ # @getsome = 'getsome'
7
+ # end
8
+ # end
9
+
10
+ # include Stories::RubyGem
11
+ # module Rollon
12
+ # module Story
13
+
14
+ # end
15
+ # end
16
+ # class Rollon::Story::RubyGem < Roro::CLI
17
+ # attr_reader :getsome
18
+ # def initialize
19
+ # @getsome = 'getsome'
20
+ # end
21
+ # end
22
+
23
+ # # module Roro
24
+
25
+ # # class CLI < Thor
26
+
27
+
28
+ # # no_commands do
29
+
30
+ # # def ruby_gem(*args)
31
+
32
+
33
+ # # end
34
+ # # def copy_ruby_gem_files
35
+ # # copy_file 'ruby_gem/config.yml', '.circleci/config.yml'
36
+ # # end
37
+ # # end
38
+
39
+ # # def ruby_gem
40
+ # # rubies = options["rubies"] || ["2.5.3", "2.6.0"]
41
+ # # copy_file 'ruby_gem/docker-compose.yml', 'docker-compose.yml'
42
+ # # copy_file 'ruby_gem/config.yml', '.circleci/config.yml'
43
+ # # copy_file 'ruby_gem/setup-gem-credentials.sh', '.circleci/setup-gem-credentials.sh'
44
+ # # directory 'ruby_gem/docker', 'docker', { ruby_version: "2.5"}
45
+
46
+ # # rubies.each do |ruby|
47
+ # # rubydash = ruby.gsub('.', '-')
48
+ # # rubyunderscore = ruby.gsub('.', '_')
49
+ # # doc_loc = "docker/containers/#{rubyunderscore}/Dockerfile"
50
+ # # content = <<-EOM
51
+
52
+ # # app-#{rubydash}:
53
+ # # build:
54
+ # # context: .
55
+ # # dockerfile: #{doc_loc}
56
+ # # command: rake test
57
+ # # EOM
58
+ # # append_to_file 'docker-compose.yml', content
59
+ # # template 'ruby_gem/docker/containers/app/Dockerfile.tt', doc_loc, {ruby_version: ruby}
60
+ # # # append_to_file 'docker-compose.yml', "\n app-#{ruby}:\n build:\n\s\s\s\s\s\scontext:"
61
+ # # end
62
+
63
+ # # # end
64
+ # # # <<EOF
65
+ # # # This is the first way of creating
66
+ # # # here document ie. multiple line string.
67
+ # # # EOF
68
+ # # # %w[app web].each do |container|
69
+ # # # options = {
70
+ # # # email: @env_hash['DOCKERHUB_EMAIL'],
71
+ # # # app_name: @env_hash['APP_NAME'] }
72
+ # # #
73
+ # # # template("docker/containers/#{container}/Dockerfile.tt", "docker/containers/#{container}/Dockerfile", options)
74
+ # # # end
75
+ # # end
76
+ # # end
77
+ # # end
@@ -0,0 +1,60 @@
1
+ module Roro
2
+ class CLI < Thor
3
+
4
+ desc "rollon::ruby_gem::with_ci_cd", "Generate files for containerized gem testing, CircleCI, and releasing to RubyGems."
5
+ method_option :rubies, type: :array, banner: "2.5.3 2.4.2"
6
+ map "rollon::ruby_gem::with_ci_cd" => "rollon_ruby_gem_with_ci_cd"
7
+
8
+ def rollon_ruby_gem_with_ci_cd(*args)
9
+ ruby_gem_with_ci_cd(*args)
10
+ end
11
+
12
+ no_commands do
13
+ def ruby_gem_with_ci_cd(*args)
14
+ configure_for_rollon
15
+ directory 'ruby_gem', './', @config.app
16
+ gitignore_sensitive_files
17
+ append_to_file ".gitignore", "Gemfile.lock\n"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ # # def ruby_gem
23
+ # # rubies = options["rubies"] || ["2.5.3", "2.6.0"]
24
+ # # copy_file 'ruby_gem/docker-compose.yml', 'docker-compose.yml'
25
+ # # copy_file 'ruby_gem/config.yml', '.circleci/config.yml'
26
+ # # copy_file 'ruby_gem/setup-gem-credentials.sh', '.circleci/setup-gem-credentials.sh'
27
+ # # directory 'ruby_gem/docker', 'docker', { ruby_version: "2.5"}
28
+
29
+ # # rubies.each do |ruby|
30
+ # # rubydash = ruby.gsub('.', '-')
31
+ # # rubyunderscore = ruby.gsub('.', '_')
32
+ # # doc_loc = "docker/containers/#{rubyunderscore}/Dockerfile"
33
+ # # content = <<-EOM
34
+
35
+ # # app-#{rubydash}:
36
+ # # build:
37
+ # # context: .
38
+ # # dockerfile: #{doc_loc}
39
+ # # command: rake test
40
+ # # EOM
41
+ # # append_to_file 'docker-compose.yml', content
42
+ # # template 'ruby_gem/docker/containers/app/Dockerfile.tt', doc_loc, {ruby_version: ruby}
43
+ # # # append_to_file 'docker-compose.yml', "\n app-#{ruby}:\n build:\n\s\s\s\s\s\scontext:"
44
+ # # end
45
+
46
+ # # # end
47
+ # # # <<EOF
48
+ # # # This is the first way of creating
49
+ # # # here document ie. multiple line string.
50
+ # # # EOF
51
+ # # # %w[app web].each do |container|
52
+ # # # options = {
53
+ # # # email: @env_hash['DOCKERHUB_EMAIL'],
54
+ # # # app_name: @env_hash['APP_NAME'] }
55
+ # # #
56
+ # # # template("docker/containers/#{container}/Dockerfile.tt", "docker/containers/#{container}/Dockerfile", options)
57
+ # # # end
58
+ # # end
59
+ # # end
60
+ # # end
@@ -0,0 +1,7 @@
1
+ require_relative 'ruby_gem/ruby_gem'
2
+
3
+ # module Stories
4
+ # module RubyGem
5
+ # end
6
+ # end
7
+
@@ -1,54 +1,67 @@
1
- module Roro
2
-
3
- class CLI < Thor
1
+ # module Rollon
2
+ # module Story
3
+
4
+ # end
5
+ # end
6
+ # class Rollon::Story::RubyGem < Roro::CLI
7
+ # attr_reader :getsome
8
+ # def initialize
9
+ # @getsome = 'getsome'
10
+ # end
11
+ # end
4
12
 
5
- include Thor::Actions
13
+ # # module Roro
6
14
 
7
- desc "ruby_gem", "Generate files for containerized gem testing, CircleCI, and releasing to RubyGems."
8
- method_option :rubies, type: :array, banner: "2.5.3 2.4.2"
15
+ # # class CLI < Thor
9
16
 
10
- no_commands do
11
- def copy_ruby_gem_files
12
- copy_file 'ruby_gem/config.yml', '.circleci/config.yml'
13
- end
14
- end
15
17
 
16
- def ruby_gem
17
- rubies = options["rubies"] || ["2.5.3", "2.6.0"]
18
- copy_file 'ruby_gem/docker-compose.yml', 'docker-compose.yml'
19
- copy_file 'ruby_gem/config.yml', '.circleci/config.yml'
20
- copy_file 'ruby_gem/setup-gem-credentials.sh', '.circleci/setup-gem-credentials.sh'
21
- directory 'ruby_gem/docker', 'docker', { ruby_version: "2.5"}
18
+ # # no_commands do
19
+
20
+ # # def ruby_gem(*args)
21
+
22
+
23
+ # # end
24
+ # # def copy_ruby_gem_files
25
+ # # copy_file 'ruby_gem/config.yml', '.circleci/config.yml'
26
+ # # end
27
+ # # end
28
+
29
+ # # def ruby_gem
30
+ # # rubies = options["rubies"] || ["2.5.3", "2.6.0"]
31
+ # # copy_file 'ruby_gem/docker-compose.yml', 'docker-compose.yml'
32
+ # # copy_file 'ruby_gem/config.yml', '.circleci/config.yml'
33
+ # # copy_file 'ruby_gem/setup-gem-credentials.sh', '.circleci/setup-gem-credentials.sh'
34
+ # # directory 'ruby_gem/docker', 'docker', { ruby_version: "2.5"}
22
35
 
23
- rubies.each do |ruby|
24
- rubydash = ruby.gsub('.', '-')
25
- rubyunderscore = ruby.gsub('.', '_')
26
- doc_loc = "docker/containers/#{rubyunderscore}/Dockerfile"
27
- content = <<-EOM
36
+ # # rubies.each do |ruby|
37
+ # # rubydash = ruby.gsub('.', '-')
38
+ # # rubyunderscore = ruby.gsub('.', '_')
39
+ # # doc_loc = "docker/containers/#{rubyunderscore}/Dockerfile"
40
+ # # content = <<-EOM
28
41
 
29
- app-#{rubydash}:
30
- build:
31
- context: .
32
- dockerfile: #{doc_loc}
33
- command: rake test
34
- EOM
35
- append_to_file 'docker-compose.yml', content
36
- template 'ruby_gem/docker/containers/app/Dockerfile.tt', doc_loc, {ruby_version: ruby}
37
- # append_to_file 'docker-compose.yml', "\n app-#{ruby}:\n build:\n\s\s\s\s\s\scontext:"
38
- end
42
+ # # app-#{rubydash}:
43
+ # # build:
44
+ # # context: .
45
+ # # dockerfile: #{doc_loc}
46
+ # # command: rake test
47
+ # # EOM
48
+ # # append_to_file 'docker-compose.yml', content
49
+ # # template 'ruby_gem/docker/containers/app/Dockerfile.tt', doc_loc, {ruby_version: ruby}
50
+ # # # append_to_file 'docker-compose.yml', "\n app-#{ruby}:\n build:\n\s\s\s\s\s\scontext:"
51
+ # # end
39
52
 
40
- # end
41
- # <<EOF
42
- # This is the first way of creating
43
- # here document ie. multiple line string.
44
- # EOF
45
- # %w[app web].each do |container|
46
- # options = {
47
- # email: @env_hash['DOCKERHUB_EMAIL'],
48
- # app_name: @env_hash['APP_NAME'] }
49
- #
50
- # template("docker/containers/#{container}/Dockerfile.tt", "docker/containers/#{container}/Dockerfile", options)
51
- # end
52
- end
53
- end
54
- end
53
+ # # # end
54
+ # # # <<EOF
55
+ # # # This is the first way of creating
56
+ # # # here document ie. multiple line string.
57
+ # # # EOF
58
+ # # # %w[app web].each do |container|
59
+ # # # options = {
60
+ # # # email: @env_hash['DOCKERHUB_EMAIL'],
61
+ # # # app_name: @env_hash['APP_NAME'] }
62
+ # # #
63
+ # # # template("docker/containers/#{container}/Dockerfile.tt", "docker/containers/#{container}/Dockerfile", options)
64
+ # # # end
65
+ # # end
66
+ # # end
67
+ # # end
@@ -1,44 +1,82 @@
1
+ ## The FROM instruction below builds our first layer using an official image:
1
2
  FROM ruby:<%= config['ruby_version'] %>
3
+
2
4
  LABEL maintainer="<%= config['dockerhub_email'] %>"
3
5
 
6
+ ## This is a rails app so, we will want to add node and yarn. In order for our
7
+ ## container to trust yarn as a source, we first need to add yarn's public key.
8
+ ## One good way to accomplish this is with apt-key, but apt-key is designed to
9
+ ## send output to the terminal and not to stdout, and thus apt-key will send a
10
+ ## warning message during the build context. One way to deal with the warning
11
+ ## is to set an environment variable telling apt-get to be quiet. To do this,
12
+ ## you'd first write an ENV instruction setting the environment variable, then
13
+ ## write the RUN instruction adding the key to the container, and then you'd
14
+ ## have to write another ENV instruction unsetting the variable. This would be
15
+ ## ugly and inconvenient. Another way to deal with the warning is to just ignore
16
+ ## it. There's no shame in that but ignoring it in the build context might
17
+ ## condition us to ignore it in other contexts. But what if there was a way to
18
+ ## deal with it that allowed you to set that variable just for the build
19
+ ## context? Fortunately there is, using the ARG instruction. Variables set with
20
+ ## ARG instructions stay in the build context while those set with ENV
21
+ ## instructions follow into the container.
22
+
23
+ ## Use an ARG instruction to set a variable disabling the apt-key warning:
24
+ ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
4
25
 
5
- ## Make sure we have yarn properly sourced:
26
+ ## Add yarn's public key using apt-key:
6
27
  RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
28
+
29
+ ## Add yarn to our sources:
7
30
  RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
8
31
 
9
- ## Update OS and download yarm from source specified above:
32
+
33
+ ## Build a layer updating the image while adding node and yarn from the source
34
+ ## above:
10
35
  RUN apt-get update -qq && apt-get install -y build-essential git nodejs yarn
11
36
 
12
- ## Set up our workspace directories:
13
- ENV APP_HOME /usr/src/app/
14
- RUN mkdir ${APP_HOME}
37
+ ## We have two directories we'd like to follow from the build context into
38
+ ## our containers. APP_HOME is where we'll do most of our work and BUNDLE_PATH
39
+ ## is where we want bundler to store our gems.
15
40
 
16
- ## Tell bundler where to store downloaded gems:
41
+ ## Set APP_HOME and BUNDLE_PATH as using ENV instructions:
42
+ ENV APP_HOME /usr/src/app/
17
43
  ENV BUNDLE_PATH /gems
18
- RUN mkdir ${BUNDLE_PATH}}
44
+
45
+ ## Create both as directories to make sure they exist:
46
+ RUN mkdir ${APP_HOME}
47
+ RUN mkdir ${BUNDLE_PATH}
19
48
 
20
49
  ## Tell Docker to create volumes for our workspace and gems
21
50
  ## so other containers can access them.
22
51
  VOLUME ${APP_HOME}
23
- VOLUME /gems
52
+ VOLUME ${BUNDLE_PATH}
53
+
54
+ ## If we copy our entire app using a single COPY instruction, Docker will build
55
+ ## it all as a single new layer. When Docker notices a change to a file, it then
56
+ ## has to rebuild the entire layer. This can slow development. One way to speed
57
+ ## it back up is to break a single big COPY layer into several smaller ones,
58
+ ## with slow-building layers that don't change often underneath smaller,
59
+ ## lighter, qucker oens that might change a lot.
24
60
 
25
- ## To speed up development, copy Gemfile and Gemfile.lock from host
26
- ## and then bundle so changing other parts of the app don't trigger
27
- ## a full gem install.
61
+ ## Build your big, slow gem layer by first copying your Gemfile && Gemfile.lock:
28
62
  COPY Gemfile* ./
29
63
 
64
+ ## Set your work directory:
30
65
  WORKDIR ${APP_HOME}
31
66
 
67
+ ## build the bundle layer, which now only runs if your Gemfile changes:
32
68
  RUN bundle
33
69
 
70
+ ## Now build a layer layer with everything in your app that's likely to change
71
+ ## frequently. If you make a change to any of these files, only this layer has
72
+ ## to rebuild. smaller, lighter layer
73
+ COPY . ${APP_HOME}
74
+
75
+
34
76
  COPY roro/docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
35
77
  RUN chmod +x /usr/bin/docker-entrypoint.sh
36
78
  ENTRYPOINT ["docker-entrypoint.sh"]
37
79
 
38
- COPY . /usr/src/app/
39
-
40
- # RUN chmod +x /usr/src/app/roro/docker-entrypoint.sh
41
- # ENTRYPOINT ["/usr/src/app/roro/docker-entrypoint.sh"]
42
80
 
43
81
 
44
82
 
@@ -24,11 +24,11 @@ VOLUME /gems
24
24
  RUN echo "source 'https://rubygems.org'\ngem 'rails'" > Gemfile
25
25
 
26
26
  ## Bundle to install rails:
27
- RUN bundle install
28
27
 
29
28
  ## Switch to the the work directory from container root:
30
29
  WORKDIR ${APP_HOME}
31
30
 
31
+ RUN bundle install
32
32
  ## Use Rails to generate a new app. We'll configure it later.
33
33
  RUN bundle exec rails new . --skip-webpack-install --skip-bundle
34
34
 
@@ -1,9 +1,9 @@
1
- version: '3.1'
1
+ version: '3.2'
2
2
 
3
3
  services:
4
4
 
5
- app:
5
+ ruby_gem:
6
6
  build:
7
7
  context: .
8
- dockerfile: docker/containers/app/Dockerfile
8
+ dockerfile: roro/containers/gem/Dockerfile
9
9
  command: rake test
@@ -0,0 +1,9 @@
1
+ FROM ruby:<%= config['ruby_version'] %>-alpine
2
+
3
+ RUN apk add --no-cache --update build-base linux-headers git
4
+
5
+ WORKDIR /usr/src/app
6
+ COPY . /usr/src/app/
7
+ RUN gem install bundler
8
+ RUN bundle
9
+ RUN bundle exec rake install
@@ -1,3 +1,3 @@
1
1
  module Roro
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
@@ -37,8 +37,8 @@ Gem::Specification.new do |spec|
37
37
  # spec.bindir = "exe"
38
38
  # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
39
39
  spec.require_paths = ["lib"]
40
-
41
- spec.add_dependency "thor"
40
+ spec.add_dependency "gem-release", "~> 2.1"
41
+ spec.add_dependency "thor", "~> 1.0"
42
42
  spec.add_dependency "os", "1.0.0"
43
43
  spec.add_dependency "sshkit", "1.18.2"
44
44
  spec.add_dependency "handsome_fencer-crypto", "0.1.6"
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - schadenfred
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-20 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gem-release
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: thor
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - ">="
31
+ - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '0'
33
+ version: '1.0'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - ">="
38
+ - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '0'
40
+ version: '1.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: os
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -167,6 +181,7 @@ files:
167
181
  - lib/roro/cli/base/insert_gems.rb
168
182
  - lib/roro/cli/base/insertions.rb
169
183
  - lib/roro/cli/base/utilities.rb
184
+ - lib/roro/cli/cli.rb
170
185
  - lib/roro/cli/configuration.rb
171
186
  - lib/roro/cli/expose.rb
172
187
  - lib/roro/cli/generate/config.rb
@@ -176,10 +191,15 @@ files:
176
191
  - lib/roro/cli/greenfield.rb
177
192
  - lib/roro/cli/obfuscate.rb
178
193
  - lib/roro/cli/rollon.rb
179
- - lib/roro/cli/rollon/database/database.rb
180
- - lib/roro/cli/rollon/database/with_mysql.rb
181
- - lib/roro/cli/rollon/database/with_postgres.rb
182
194
  - lib/roro/cli/rollon/stories.rb
195
+ - lib/roro/cli/rollon/stories/database.rb
196
+ - lib/roro/cli/rollon/stories/rails.rb
197
+ - lib/roro/cli/rollon/stories/rails/database/database.rb
198
+ - lib/roro/cli/rollon/stories/rails/database/with_mysql.rb
199
+ - lib/roro/cli/rollon/stories/rails/database/with_postgres.rb
200
+ - lib/roro/cli/rollon/stories/ruby_gem.rb
201
+ - lib/roro/cli/rollon/stories/ruby_gem/with_ci_cd.rb
202
+ - lib/roro/cli/rollon/stories/stories.rb
183
203
  - lib/roro/cli/roro_configurator.yml
184
204
  - lib/roro/cli/ruby_gem.rb
185
205
  - lib/roro/cli/templates/base/.dockerignore
@@ -211,10 +231,6 @@ files:
211
231
  - lib/roro/cli/templates/jumpstart/docker-compose.yml
212
232
  - lib/roro/cli/templates/jumpstart/docker-entrypoint.sh
213
233
  - lib/roro/cli/templates/livereload/hosts.example
214
- - lib/roro/cli/templates/quickstart/Dockerfile.tt
215
- - lib/roro/cli/templates/quickstart/database.yml
216
- - lib/roro/cli/templates/quickstart/docker-compose.yml
217
- - lib/roro/cli/templates/quickstart/entrypoint.sh
218
234
  - lib/roro/cli/templates/roro/.keep
219
235
  - lib/roro/cli/templates/roro/docker-compose.yml.tt
220
236
  - lib/roro/cli/templates/roro/roro/.keep
@@ -222,12 +238,11 @@ files:
222
238
  - lib/roro/cli/templates/roro/roro/containers/app/.keep
223
239
  - lib/roro/cli/templates/roro/roro/containers/frontend/.keep
224
240
  - lib/roro/cli/templates/roro/roro/docker-entrypoint.sh.tt
225
- - lib/roro/cli/templates/ruby_gem/.gitignore
226
- - lib/roro/cli/templates/ruby_gem/config.yml
241
+ - lib/roro/cli/templates/ruby_gem/.circleci/config.yml
227
242
  - lib/roro/cli/templates/ruby_gem/docker-compose.yml
228
- - lib/roro/cli/templates/ruby_gem/docker/containers/app/Dockerfile.tt
229
- - lib/roro/cli/templates/ruby_gem/docker/env_files/.keep
230
- - lib/roro/cli/templates/ruby_gem/docker/keys/.keep
243
+ - lib/roro/cli/templates/ruby_gem/roro/containers/gem/Dockerfile.tt
244
+ - lib/roro/cli/templates/ruby_gem/roro/env_files/.keep
245
+ - lib/roro/cli/templates/ruby_gem/roro/keys/.keep
231
246
  - lib/roro/cli/templates/ruby_gem/setup-gem-credentials.sh
232
247
  - lib/roro/cli/templates/stories/.keep
233
248
  - lib/roro/cli/templates/stories/with_mysql/_service.yml
@@ -237,7 +252,6 @@ files:
237
252
  - lib/tasks/deploy.rake
238
253
  - roro.gemspec
239
254
  - sandbox/.keep
240
- - tmp/.gitkeep
241
255
  - vendor/bundle/.keep
242
256
  - vendor/cache/actionpack-6.0.3.2.gem
243
257
  - vendor/cache/actionview-6.0.3.2.gem
@@ -253,6 +267,7 @@ files:
253
267
  - vendor/cache/eventmachine-1.2.7.gem
254
268
  - vendor/cache/ffi-1.13.1.gem
255
269
  - vendor/cache/formatador-0.2.5.gem
270
+ - vendor/cache/gem-release-2.1.1.gem
256
271
  - vendor/cache/given_core-3.8.0.gem
257
272
  - vendor/cache/guard-2.16.2.gem
258
273
  - vendor/cache/guard-compat-1.2.1.gem
@@ -1,20 +0,0 @@
1
- FROM ruby:<%= config[:ruby_version] %>
2
-
3
- RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
4
- RUN mkdir /myapp
5
- WORKDIR /myapp
6
- COPY Gemfile /myapp/Gemfile
7
- COPY Gemfile.lock /myapp/Gemfile.lock
8
-
9
- RUN gem install bundler
10
- RUN bundle install
11
- COPY . /myapp
12
-
13
- # Add a script to be executed every time the container starts.
14
- COPY entrypoint.sh /usr/bin/
15
- RUN chmod +x /usr/bin/entrypoint.sh
16
- ENTRYPOINT ["entrypoint.sh"]
17
- EXPOSE 3000
18
-
19
- # Start the main process.
20
- CMD ["rails", "server", "-b", "0.0.0.0"]
@@ -1,85 +0,0 @@
1
- # PostgreSQL. Versions 9.3 and up are supported.
2
- #
3
- # Install the pg driver:
4
- # gem install pg
5
- # On macOS with Homebrew:
6
- # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7
- # On macOS with MacPorts:
8
- # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9
- # On Windows:
10
- # gem install pg
11
- # Choose the win32 build.
12
- # Install PostgreSQL and put its /bin directory on your path.
13
- #
14
- # Configure Using Gemfile
15
- # gem 'pg'
16
- #
17
- default: &default
18
- adapter: postgresql
19
- encoding: unicode
20
- # For details on connection pooling, see Rails configuration guide
21
- # https://guides.rubyonrails.org/configuring.html#database-pooling
22
- pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23
-
24
- development:
25
- <<: *default
26
- database: sandbox_development
27
-
28
- # The specified database role being used to connect to postgres.
29
- # To create additional roles in postgres see `$ createuser --help`.
30
- # When left blank, postgres will use the default role. This is
31
- # the same name as the operating system user that initialized the database.
32
- #username: sandbox
33
-
34
- # The password associated with the postgres role (username).
35
- #password:
36
-
37
- # Connect on a TCP socket. Omitted by default since the client uses a
38
- # domain socket that doesn't need configuration. Windows does not have
39
- # domain sockets, so uncomment these lines.
40
- #host: localhost
41
-
42
- # The TCP port the server listens on. Defaults to 5432.
43
- # If your server runs on a different port number, change accordingly.
44
- #port: 5432
45
-
46
- # Schema search path. The server defaults to $user,public
47
- #schema_search_path: myapp,sharedapp,public
48
-
49
- # Minimum log levels, in increasing order:
50
- # debug5, debug4, debug3, debug2, debug1,
51
- # log, notice, warning, error, fatal, and panic
52
- # Defaults to warning.
53
- #min_messages: notice
54
-
55
- # Warning: The database defined as "test" will be erased and
56
- # re-generated from your development database when you run "rake".
57
- # Do not set this db to the same as development or production.
58
- test:
59
- <<: *default
60
- database: sandbox_test
61
-
62
- # As with config/credentials.yml, you never want to store sensitive information,
63
- # like your database password, in your source code. If your source code is
64
- # ever seen by anyone, they now have access to your database.
65
- #
66
- # Instead, provide the password as a unix environment variable when you boot
67
- # the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
68
- # for a full rundown on how to provide these environment variables in a
69
- # production deployment.
70
- #
71
- # On Heroku and other platform providers, you may have a full connection URL
72
- # available as an environment variable. For example:
73
- #
74
- # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
75
- #
76
- # You can use this database configuration with:
77
- #
78
- # production:
79
- # url: <%= ENV['DATABASE_URL'] %>
80
- #
81
- production:
82
- <<: *default
83
- database: sandbox_production
84
- username: sandbox
85
- password: <%= ENV['SANDBOX_DATABASE_PASSWORD'] %>
@@ -1,17 +0,0 @@
1
- version: '3'
2
- services:
3
- db:
4
- image: postgres
5
- volumes:
6
- - ./tmp/db:/var/lib/postgresql/data
7
- environment:
8
- POSTGRES_PASSWORD: password
9
- web:
10
- build: .
11
- command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
12
- volumes:
13
- - .:/myapp
14
- ports:
15
- - "3000:3000"
16
- depends_on:
17
- - db
@@ -1,8 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- # Remove a potentially pre-existing server.pid for Rails.
5
- rm -f /myapp/tmp/pids/server.pid
6
-
7
- # Then exec the container's main process (what's set as CMD in the Dockerfile).
8
- exec "$@"
@@ -1,8 +0,0 @@
1
- # Also see https://github.com/github/gitignore/blob/master/Ruby.gitignore
2
-
3
- Gemfile.lock
4
- *.gem
5
- .bundle
6
- .env
7
- rdoc
8
- tmp
@@ -1,10 +0,0 @@
1
- FROM ruby:<%= config[:ruby_version] %>-alpine
2
-
3
- RUN apk add --no-cache --update build-base linux-headers \
4
- postgresql-dev nodejs tzdata libxml2-dev libxslt-dev git
5
-
6
- WORKDIR /usr/src/app
7
- COPY . /usr/src/app/
8
- RUN rake install
9
- RUN gem install bundler
10
- RUN bundle