roro 0.3.5 → 0.3.12

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.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +15 -2
  3. data/Guardfile +4 -10
  4. data/lib/roro.rb +0 -1
  5. data/lib/roro/cli.rb +75 -5
  6. data/lib/roro/cli/base/base.rb +2 -1
  7. data/lib/roro/cli/base/base_files.rb +1 -7
  8. data/lib/roro/cli/base/check_dependencies.rb +98 -0
  9. data/lib/roro/cli/base/insert_gems.rb +15 -7
  10. data/lib/roro/cli/base/insertions.rb +3 -1
  11. data/lib/roro/cli/cli.rb +99 -0
  12. data/lib/roro/cli/configuration.rb +69 -0
  13. data/lib/roro/cli/expose.rb +8 -7
  14. data/lib/roro/cli/generate/config.rb +13 -0
  15. data/lib/roro/cli/generate/config/rails.rb +17 -0
  16. data/lib/roro/cli/generate/generate.rb +1 -0
  17. data/lib/roro/cli/generate/generate_keys.rb +47 -0
  18. data/lib/roro/cli/greenfield.rb +20 -31
  19. data/lib/roro/cli/obfuscate.rb +10 -11
  20. data/lib/roro/cli/rollon.rb +67 -21
  21. data/lib/roro/cli/rollon/stories.rb +2 -3
  22. data/{.keep → lib/roro/cli/rollon/stories/database.rb} +0 -0
  23. data/lib/roro/cli/rollon/stories/rails.rb +1 -0
  24. data/lib/roro/cli/{templates/base/roro → rollon/stories/rails}/.keep +0 -0
  25. data/lib/roro/cli/rollon/stories/rails/database.rb +33 -0
  26. data/lib/roro/cli/rollon/stories/rails/database/with_mysql.rb +22 -0
  27. data/lib/roro/cli/rollon/stories/rails/database/with_postgresql.rb +21 -0
  28. data/lib/roro/cli/rollon/stories/ruby_gem.rb +77 -0
  29. data/lib/roro/cli/rollon/stories/ruby_gem/with_ci_cd.rb +81 -0
  30. data/lib/roro/cli/rollon/stories/stories.rb +3 -0
  31. data/lib/roro/cli/roro_configurator.yml +157 -0
  32. data/lib/roro/cli/ruby_gem.rb +60 -47
  33. data/lib/roro/cli/templates/base/.roro_config.yml +15 -0
  34. data/lib/roro/cli/templates/base/Dockerfile.tt +82 -0
  35. data/lib/roro/cli/templates/base/config/database.mysql.yml +19 -0
  36. data/lib/roro/cli/templates/base/config/{database.yml.pg.tt → database.pg.yml} +0 -0
  37. data/lib/roro/cli/templates/greenfield/Dockerfile.tt +29 -7
  38. data/lib/roro/cli/templates/{base/livereload → livereload}/hosts.example +0 -0
  39. data/lib/roro/cli/templates/{base/roro/containers → roro}/.keep +0 -0
  40. data/lib/roro/cli/templates/{greenfield → roro}/docker-compose.yml.tt +18 -13
  41. data/lib/roro/cli/templates/{base/roro/containers/app → roro/roro}/.keep +0 -0
  42. data/lib/roro/cli/templates/{base/roro/containers/frontend → roro/roro/containers}/.keep +0 -0
  43. data/lib/roro/cli/templates/{dockerize/.env → roro/roro/containers/app}/.keep +0 -0
  44. data/lib/roro/cli/templates/{dockerize/.env/development → roro/roro/containers/frontend}/.keep +0 -0
  45. data/lib/roro/cli/templates/{quickstart/entrypoint.sh → roro/roro/docker-entrypoint.sh.tt} +1 -1
  46. data/lib/roro/cli/templates/ruby_gem/.circleci/config.yml +17 -0
  47. data/lib/roro/cli/templates/ruby_gem/docker-compose.yml +6 -4
  48. data/lib/roro/cli/templates/ruby_gem/roro/ci.env.tt +1 -0
  49. data/lib/roro/cli/templates/{dockerize → ruby_gem/roro/containers}/.keep +0 -0
  50. data/lib/roro/cli/templates/ruby_gem/roro/containers/ruby_image/Dockerfile.tt +16 -0
  51. data/lib/roro/cli/templates/ruby_gem/{docker/env_files → roro/keys}/.keep +0 -0
  52. data/lib/roro/cli/templates/{ruby_gem/docker/keys → stories}/.keep +0 -0
  53. data/lib/roro/cli/templates/stories/with_mysql/_service.yml +10 -0
  54. data/lib/roro/cli/templates/stories/with_postgresql/.keep +0 -0
  55. data/lib/roro/cli/templates/stories/with_postgresql/_service.yml +7 -0
  56. data/lib/roro/version.rb +1 -1
  57. data/roro.gemspec +3 -4
  58. data/sandbox/.keep +0 -0
  59. data/vendor/cache/concurrent-ruby-1.1.7.gem +0 -0
  60. data/vendor/cache/gem-release-2.1.1.gem +0 -0
  61. metadata +69 -66
  62. data/lib/roro/cli/base/configuration.rb +0 -118
  63. data/lib/roro/cli/generate_keys.rb +0 -79
  64. data/lib/roro/cli/rollon/rollon_as_dockerize.rb +0 -42
  65. data/lib/roro/cli/rollon/rollon_as_quickstart.rb +0 -17
  66. data/lib/roro/cli/rollon/rollon_as_roro.rb +0 -30
  67. data/lib/roro/cli/templates/base/circleci/config.yml.tt +0 -70
  68. data/lib/roro/cli/templates/base/docker-compose.yml.tt +0 -53
  69. data/lib/roro/cli/templates/base/pg/config/database.yml.pg.tt +0 -20
  70. data/lib/roro/cli/templates/base/pg/database.yml.pg.tt +0 -20
  71. data/lib/roro/cli/templates/base/roro/containers/app/Dockerfile.tt +0 -32
  72. data/lib/roro/cli/templates/base/roro/containers/app/development.env.tt +0 -1
  73. data/lib/roro/cli/templates/base/roro/containers/app/docker-entrypoint.sh +0 -8
  74. data/lib/roro/cli/templates/base/roro/containers/app/test.env.tt +0 -1
  75. data/lib/roro/cli/templates/base/roro/containers/database/development.env.tt +0 -4
  76. data/lib/roro/cli/templates/base/roro/containers/database/test.env.tt +0 -4
  77. data/lib/roro/cli/templates/dockerize/.env/development/database +0 -3
  78. data/lib/roro/cli/templates/dockerize/.env/development/web +0 -1
  79. data/lib/roro/cli/templates/dockerize/Dockerfile.tt +0 -23
  80. data/lib/roro/cli/templates/dockerize/docker-compose.yml.tt +0 -60
  81. data/lib/roro/cli/templates/dockerize/docker-entrypoint.sh +0 -9
  82. data/lib/roro/cli/templates/quickstart/Dockerfile.tt +0 -20
  83. data/lib/roro/cli/templates/quickstart/database.yml +0 -85
  84. data/lib/roro/cli/templates/quickstart/docker-compose.yml +0 -17
  85. data/lib/roro/cli/templates/ruby_gem/.gitignore +0 -8
  86. data/lib/roro/cli/templates/ruby_gem/config.yml +0 -122
  87. data/lib/roro/cli/templates/ruby_gem/docker/containers/app/Dockerfile.tt +0 -10
  88. data/roro-0.3.4.gem +0 -0
  89. data/vendor/cache/concurrent-ruby-1.1.6.gem +0 -0
@@ -1,118 +0,0 @@
1
-
2
- module Roro
3
-
4
- class CLI < Thor
5
-
6
- no_commands do
7
-
8
- def get_configuration_variables(hash={})
9
- options["interactive"] ? set_interactively : set_from_defaults
10
- hash.each { |k,v| @env_hash[k] = v } unless hash.nil?
11
- @env_hash[:deploy_tag] = "${CIRCLE_SHA1:0:7}"
12
- @env_hash[:server_port] = "22"
13
- @env_hash[:server_user] = "root"
14
- @env_hash
15
- end
16
-
17
- def set_from_defaults
18
- @env_hash = configuration_hash
19
- @env_hash.map do |key, hash|
20
- @env_hash[key] = hash.values.last
21
- end
22
- @env_hash
23
- end
24
-
25
- def set_interactively
26
- @env_hash = configuration_hash
27
- @env_hash.map do |key, prompt|
28
- answer = ask("Please provide #{prompt.keys.first} or hit enter to accept: \[ #{prompt.values.first} \]")
29
- @env_hash[key] = (answer == "") ? prompt.values.first : answer
30
- end
31
- end
32
-
33
- def confirm_dependencies
34
- dependencies = [
35
- {
36
- system_query: "which docker",
37
- warning: "Docker isn't installed",
38
- suggestion: "https://docs.docker.com/install/"
39
- }, {
40
- system_query: "which docker-compose",
41
- warning: "Docker Compose isn't installed",
42
- suggestion: "https://docs.docker.com/compose/install/"
43
-
44
- }, {
45
- system_query: "docker info",
46
- warning: "the Docker daemon isn't running",
47
- suggestion: "https://docs.docker.com/config/daemon/#start-the-daemon-manually"
48
- }
49
- ]
50
-
51
- dependencies.each do |dependency|
52
- confirm_dependency(dependency)
53
- end
54
- end
55
-
56
-
57
-
58
- def confirm_dependency(options)
59
- msg = []
60
- msg << ""
61
- msg << delineator
62
- msg << "It looks like #{options[:warning]}. The following bash command returns false:"
63
- msg << "\t$ #{options[:system_query]}"
64
- msg << "Please try these instructions:"
65
- msg << ("\t" + options[:suggestion])
66
- msg << delineator
67
- conditional = options[:conditional] ? eval(options[:conditional]) : system(options[:system_query])
68
- if conditional == false
69
- raise(Roro::Error.new(msg.join("\n\n")))
70
- end
71
- end
72
-
73
-
74
- private
75
-
76
- def configuration_hash
77
- {
78
- app_name: {
79
- "the name of your app" => `pwd`.split('/').last.strip!
80
- },
81
- ruby_version: {
82
- "the version of ruby you'd like" => `ruby -v`.scan(/\d.\d/).first
83
- },
84
- server_host: {
85
- "the ip address of your server" => "ip-address-of-your-server"
86
- },
87
- database_container: {
88
- "the name of your database container" => "database"
89
- },
90
- frontend_container: {
91
- "the name of your frontend container" => "frontend"
92
- },
93
- server_container: {
94
- "the name of your server container" => "nginx"
95
- },
96
- dockerhub_email: {
97
- "your Docker Hub email" => "your-docker-hub-email"
98
- },
99
- dockerhub_user: {
100
- "your Docker Hub username" => "your-docker-hub-user-name"
101
- },
102
- dockerhub_org: {
103
- "your Docker Hub organization name" => "your-docker-hub-org-name"
104
- },
105
- dockerhub_password: {
106
- "your Docker Hub password" => "your-docker-hub-password"
107
- },
108
- postgres_user: {
109
- "your Postgres username" => "postgres"
110
- },
111
- postgres_password: {
112
- "your Postgres password" => "your-postgres-password"
113
- }
114
- }
115
- end
116
- end
117
- end
118
- end
@@ -1,79 +0,0 @@
1
- require 'openssl'
2
- require 'base64'
3
- require 'handsome_fencer/crypto'
4
-
5
- module Roro
6
-
7
- class CLI < Thor
8
-
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
- confirm_files_decrypted?(environment)
25
- create_file "docker/keys/#{environment}.key", encoded_key
26
- end
27
- end
28
-
29
- no_commands do
30
-
31
- def encoded_key
32
- @cipher = OpenSSL::Cipher.new 'AES-128-CBC'
33
- @salt = '8 octets'
34
- @new_key = @cipher.random_key
35
- Base64.encode64(@new_key)
36
- end
37
-
38
- def gather_environments
39
- environments = []
40
- ['.env', '.env.enc'].each do |extension|
41
-
42
- HandsomeFencer::Crypto.source_files('.', extension).each do |env_file|
43
- environments << env_file.split('/').last.split(extension).last
44
- end
45
- end
46
- environments.uniq
47
- end
48
-
49
- def confirm_files_decrypted?(environment)
50
- orphan_encrypted = []
51
- HandsomeFencer::Crypto.source_files('.', '.env.enc').each do |file|
52
- orphan_encrypted << file unless File.exist? file.split('.enc').first
53
- end
54
-
55
- if !orphan_encrypted.empty?
56
- raise Roro::Error.new("You have an encrypted files (.env.enc) #{orphan_encrypted} that do not have corresponding decrypted files (.env). Please decrypt or remove these encrypted files before generating a new key for #{environment}.")
57
- end
58
- true
59
- end
60
- end
61
- end
62
-
63
- # desc "generate keys", "Generate keys on a per-environment basis"
64
- #
65
- # method_option :environment, type: :string, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "development, staging"
66
- #
67
-
68
- # def generate_keys
69
- # default_environments = %w[circleci development production]
70
- # environments = args.first ? [args.first] : default_environments
71
- # environments.each do |environment|
72
- # @cipher = OpenSSL::Cipher.new 'AES-128-CBC'
73
- # @salt = '8 octets'
74
- # @new_key = @cipher.random_key
75
- #
76
- # create_file "docker/keys/#{environment}.key", Base64.encode64(@new_key)
77
- # end
78
- # end
79
- end
@@ -1,42 +0,0 @@
1
- module Roro
2
-
3
- class CLI < Thor
4
-
5
- no_commands do
6
-
7
- def rollon_as_dockerize
8
- rollon_dockerize_files
9
- system 'docker-compose build'
10
- system 'docker-compose run --no-deps web bin/rails webpacker:install'
11
- system 'docker-compose up'
12
- end
13
-
14
- def
15
-
16
- def configure_for_pg
17
- service = [
18
- " database:",
19
- " image: postgres",
20
- " env_file:",
21
- " - .env/development/database",
22
- " volumes:",
23
- " - db_data:var/lib/postgresql/data"
24
- ].join("\n")
25
-
26
- @env_hash[:database_service] = service
27
- end
28
-
29
- def rollon_dockerize_files
30
- directory 'dockerize', '.', @env_hash
31
- copy_dockerignore
32
- if ask('Configure $stdout.sync for docker?', choices).eql?('y')
33
- config_std_out_true
34
- end
35
- if ask('Configure your app to use Postgresql?', choices).eql?('y')
36
- copy_database_yml_pg
37
- insert_pg_gem_into_gemfile
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,17 +0,0 @@
1
- module Roro
2
- class CLI < Thor
3
-
4
- no_commands do
5
-
6
- def rollon_as_quickstart
7
- copy_file "quickstart/docker-compose.yml", 'docker-compose.yml'
8
- copy_file "quickstart/entrypoint.sh", 'entrypoint.sh'
9
- copy_file "quickstart/database.yml", "config/database.yml"
10
- template "quickstart/Dockerfile", 'Dockerfile', @env_hash
11
-
12
- insert_pg_gem_into_gemfile
13
- system 'sudo chown -R $USER .'
14
- end
15
- end
16
- end
17
- end
@@ -1,30 +0,0 @@
1
- module Roro
2
-
3
- class CLI < Thor
4
-
5
- no_commands do
6
-
7
- def rollon_as_roro
8
- if Dir['./*'].empty?
9
- raise Roro::Error.new("Oops -- Roro can't roll itself onto a Rails app if it doesn't exist. Please either change into a directory with a Rails app or generate a new one using '$ roro greenfield'.")
10
- end
11
- if ask('Configure $stdout.sync for docker?', choices).eql?('y')
12
- config_std_out_true
13
- end
14
- if ask('Configure .gitignore for roro?', choices).eql?('y')
15
- gitignore_sensitive_files
16
- end
17
- if ask('Add RoRo to your Gemfile?', choices).eql?('y')
18
- insert_roro_gem_into_gemfile
19
- end
20
- if ask('Add handsome_fencer-test to your Gemfile?', choices).eql?('y')
21
- insert_hfci_gem_into_gemfile
22
- end
23
- if ask("Backup 'config/database.yml'?").eql?('y')
24
- FileUtils.mv 'config/database.yml', "config/database.yml.backup"
25
- end
26
- copy_base_files
27
- end
28
- end
29
- end
30
- end
@@ -1,70 +0,0 @@
1
- defaults: &defaults
2
- working_directory: /tmp
3
-
4
- version: 2
5
-
6
- jobs:
7
-
8
- build:
9
- machine: true
10
- steps:
11
- - checkout
12
- - run: gem install handsome_fencer-circle_c_i
13
- - run: handsome_fencer-circle_c_i expose circleci
14
- - run: handsome_fencer-circle_c_i expose development
15
- - run: echo 'source docker/env_files/circleci.env' >> $BASH_ENV
16
- - run: docker-compose up -d <%= config[:app_name] %> --build
17
- - run: docker-compose exec <%= config[:app_name] %> bin/rails db:create db:migrate
18
- - run: docker-compose exec <%= config[:app_name] %> bin/rails test
19
-
20
- push:
21
- machine: true
22
- steps:
23
- - checkout
24
- - run: gem install handsome_fencer-circle_c_i
25
- - run: handsome_fencer-circle_c_i expose circleci
26
- - run: handsome_fencer-circle_c_i expose development
27
- - run: echo 'source docker/env_files/circleci.env' >> $BASH_ENV
28
- - run: docker-compose build <%= config[:app_name] %> web
29
- - run: docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS
30
- - run: docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS
31
- - run:
32
- name: Tag <%= config[:app_name] %> image
33
- command: docker tag $(docker images | grep project_<%= config[:app_name] %> | awk '{ print $3 }') ${DOCKERHUB_ORG_NAME}/${APP_NAME}_app:$DEPLOY_TAG
34
- - run:
35
- name: Tag web image
36
- command: docker tag $(docker images | grep project_web | awk '{ print $3 }') ${DOCKERHUB_ORG_NAME}/${APP_NAME}_web:$DEPLOY_TAG
37
-
38
-
39
- - run: docker push ${DOCKERHUB_ORG_NAME}/${APP_NAME}_app:$DEPLOY_TAG
40
- - run: docker push ${DOCKERHUB_ORG_NAME}/${APP_NAME}_web:$DEPLOY_TAG
41
-
42
- deploy:
43
- machine: true
44
- steps:
45
- - checkout
46
- - add_ssh_keys
47
- - run: gem install handsome_fencer-circle_c_i
48
- - run: handsome_fencer-circle_c_i expose circleci
49
- - run: handsome_fencer-circle_c_i expose development
50
- - run: echo 'source docker/env_files/circleci.env' >> $BASH_ENV
51
-
52
- - run: rake --rakefile .circleci/Rakefile
53
-
54
- workflows:
55
- version: 2
56
- build-and-deploy:
57
- jobs:
58
- - build
59
- - push:
60
- requires:
61
- - build
62
- filters:
63
- branches:
64
- only: master
65
- - deploy:
66
- requires:
67
- - push
68
- filters:
69
- branches:
70
- only: master
@@ -1,53 +0,0 @@
1
- version: '3.2'
2
-
3
- services:
4
- chrome:
5
- image: selenium/standalone-chrome-debug
6
- volumes:
7
- - /dev/shm:/dev/shm
8
- <%= config[:app_name] %>:
9
- build:
10
- context: .
11
- dockerfile: roro/containers/<%= config[:app_name] %>/Dockerfile
12
-
13
- depends_on:
14
- - <%= config[:database_container] %>
15
- ports:
16
- - "35729:35729"
17
- - "3000:3000"
18
- volumes:
19
- - <%= config[:app_name] %>-data:/usr/src/<%= config[:app_name] %>
20
- - gem_cache:/gems
21
- env_file:
22
- - roro/containers/<%= config[:database_container] %>/development.env
23
- - roro/containers/<%= config[:app_name] %>/development.env
24
- command: [ "bin/rails", "s" ]
25
-
26
- stdin_open: true
27
- tty: true
28
- secrets:
29
- - host_ssh_key
30
-
31
- <%= config[:database_container] %>:
32
- image: postgres
33
-
34
- env_file:
35
- - roro/containers/<%= config[:database_container] %>/development.env
36
-
37
- volumes:
38
- - <%= config[:database_container] %>-data:/var/lib/postgresql/data
39
-
40
- web:
41
- depends_on:
42
- - <%= config[:app_name] %>
43
- build:
44
- context: .
45
- dockerfile: roro/containers/web/Dockerfile
46
- volumes:
47
- <%= config[:database_container] %>-data:
48
- gem_cache:
49
- <%= config[:app_name] %>-data:
50
-
51
- secrets:
52
- host_ssh_key:
53
- file: ~/.ssh/id_rsa
@@ -1,20 +0,0 @@
1
- default: &default
2
- adapter: postgresql
3
- encoding: unicode
4
- host: <%= ENV.fetch('DATABASE_HOST') %>
5
- username: <%= ENV.fetch('POSTGRES_USER') %>
6
- password: <%= ENV.fetch('POSTGRES_PASSWORD') %>
7
- database: <%= ENV.fetch('POSTGRES_DB') %>
8
- pool: 5
9
- variables:
10
- statement_timeout: 5000
11
-
12
- development:
13
- <<: *default
14
-
15
- test:
16
- <<: *default
17
-
18
-
19
- production:
20
- <<: *default
@@ -1,20 +0,0 @@
1
- default: &default
2
- adapter: postgresql
3
- encoding: unicode
4
- host: <%= ENV.fetch('DATABASE_HOST') %>
5
- username: <%= ENV.fetch('POSTGRES_USER') %>
6
- password: <%= ENV.fetch('POSTGRES_PASSWORD') %>
7
- database: <%= ENV.fetch('POSTGRES_DB') %>
8
- pool: 5
9
- variables:
10
- statement_timeout: 5000
11
-
12
- development:
13
- <<: *default
14
-
15
- test:
16
- <<: *default
17
-
18
-
19
- production:
20
- <<: *default