roro 0.3.4 → 0.3.9

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +15 -2
  3. data/Guardfile +3 -6
  4. data/lib/roro.rb +1 -1
  5. data/lib/roro/cli.rb +75 -6
  6. data/lib/roro/cli/base/base.rb +2 -1
  7. data/lib/roro/cli/base/base_files.rb +4 -18
  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/base/utilities.rb +22 -0
  12. data/lib/roro/cli/cli.rb +99 -0
  13. data/lib/roro/cli/configuration.rb +69 -0
  14. data/lib/roro/cli/expose.rb +8 -7
  15. data/lib/roro/cli/generate/config.rb +13 -0
  16. data/lib/roro/cli/generate/config/rails.rb +17 -0
  17. data/lib/roro/cli/generate/generate.rb +1 -0
  18. data/lib/roro/cli/generate/generate_keys.rb +47 -0
  19. data/lib/roro/cli/greenfield.rb +22 -91
  20. data/lib/roro/cli/obfuscate.rb +10 -11
  21. data/lib/roro/cli/rollon.rb +74 -18
  22. data/lib/roro/cli/rollon/stories.rb +2 -0
  23. data/{.keep → lib/roro/cli/rollon/stories/database.rb} +0 -0
  24. data/lib/roro/cli/rollon/stories/rails.rb +1 -0
  25. data/lib/roro/cli/{templates/base/roro → rollon/stories/rails}/.keep +0 -0
  26. data/lib/roro/cli/rollon/stories/rails/database.rb +33 -0
  27. data/lib/roro/cli/rollon/stories/rails/database/with_mysql.rb +22 -0
  28. data/lib/roro/cli/rollon/stories/rails/database/with_postgresql.rb +21 -0
  29. data/lib/roro/cli/rollon/stories/ruby_gem.rb +77 -0
  30. data/lib/roro/cli/rollon/stories/ruby_gem/with_ci_cd.rb +81 -0
  31. data/lib/roro/cli/rollon/stories/stories.rb +3 -0
  32. data/lib/roro/cli/roro_configurator.yml +157 -0
  33. data/lib/roro/cli/ruby_gem.rb +60 -47
  34. data/lib/roro/cli/templates/base/.dockerignore +48 -10
  35. data/lib/roro/cli/templates/base/.roro_config.yml +15 -0
  36. data/lib/roro/cli/templates/base/Dockerfile.tt +82 -0
  37. data/lib/roro/cli/templates/base/config/database.mysql.yml +19 -0
  38. data/lib/roro/cli/templates/base/config/{database.yml → database.pg.yml} +0 -0
  39. data/lib/roro/cli/templates/greenfield/Dockerfile.tt +29 -7
  40. data/lib/roro/cli/templates/{base/livereload → livereload}/hosts.example +0 -0
  41. data/lib/roro/cli/templates/{base/roro/containers → roro}/.keep +0 -0
  42. data/lib/roro/cli/templates/{dockerize/docker-compose.yml → roro/docker-compose.yml.tt} +18 -18
  43. data/lib/roro/cli/templates/{base/roro/containers/app → roro/roro}/.keep +0 -0
  44. data/lib/roro/cli/templates/{base/roro/containers/frontend → roro/roro/containers}/.keep +0 -0
  45. data/lib/roro/cli/templates/{dockerize/.env → roro/roro/containers/app}/.keep +0 -0
  46. data/lib/roro/cli/templates/{dockerize/.env/development → roro/roro/containers/frontend}/.keep +0 -0
  47. data/lib/roro/cli/templates/{quickstart/entrypoint.sh → roro/roro/docker-entrypoint.sh.tt} +1 -1
  48. data/lib/roro/cli/templates/ruby_gem/.circleci/config.yml +17 -0
  49. data/lib/roro/cli/templates/ruby_gem/docker-compose.yml +6 -4
  50. data/lib/roro/cli/templates/ruby_gem/roro/ci.env.tt +1 -0
  51. data/lib/roro/cli/templates/{dockerize → ruby_gem/roro/containers}/.keep +0 -0
  52. data/lib/roro/cli/templates/ruby_gem/roro/containers/ruby_image/Dockerfile.tt +16 -0
  53. data/lib/roro/cli/templates/ruby_gem/{docker/env_files → roro/keys}/.keep +0 -0
  54. data/lib/roro/cli/templates/{ruby_gem/docker/keys → stories}/.keep +0 -0
  55. data/lib/roro/cli/templates/stories/with_mysql/_service.yml +10 -0
  56. data/lib/roro/cli/templates/stories/with_postgresql/.keep +0 -0
  57. data/lib/roro/cli/templates/stories/with_postgresql/_service.yml +7 -0
  58. data/lib/roro/version.rb +1 -1
  59. data/roro.gemspec +5 -4
  60. data/sandbox/.keep +0 -0
  61. data/vendor/cache/concurrent-ruby-1.1.7.gem +0 -0
  62. data/vendor/cache/gem-release-2.1.1.gem +0 -0
  63. data/vendor/cache/mocha-1.11.2.gem +0 -0
  64. metadata +86 -55
  65. data/lib/roro/cli/base/configuration.rb +0 -63
  66. data/lib/roro/cli/generate_keys.rb +0 -79
  67. data/lib/roro/cli/rollon/as_dockerize.rb +0 -28
  68. data/lib/roro/cli/rollon/as_quickstart.rb +0 -17
  69. data/lib/roro/cli/rollon/as_roro.rb +0 -30
  70. data/lib/roro/cli/rollon/use_cases.rb +0 -3
  71. data/lib/roro/cli/templates/base/circleci/config.yml.tt +0 -70
  72. data/lib/roro/cli/templates/base/docker-compose.yml.tt +0 -53
  73. data/lib/roro/cli/templates/base/roro/containers/app/Dockerfile.tt +0 -32
  74. data/lib/roro/cli/templates/base/roro/containers/app/development.env.tt +0 -1
  75. data/lib/roro/cli/templates/base/roro/containers/app/docker-entrypoint.sh +0 -8
  76. data/lib/roro/cli/templates/base/roro/containers/app/test.env.tt +0 -1
  77. data/lib/roro/cli/templates/base/roro/containers/database/development.env.tt +0 -4
  78. data/lib/roro/cli/templates/base/roro/containers/database/test.env.tt +0 -4
  79. data/lib/roro/cli/templates/dockerize/.env/development/database +0 -3
  80. data/lib/roro/cli/templates/dockerize/.env/development/web +0 -1
  81. data/lib/roro/cli/templates/dockerize/Dockerfile.tt +0 -23
  82. data/lib/roro/cli/templates/dockerize/docker-entrypoint.sh +0 -9
  83. data/lib/roro/cli/templates/greenfield/Gemfile +0 -2
  84. data/lib/roro/cli/templates/greenfield/config/database.yml.example +0 -16
  85. data/lib/roro/cli/templates/greenfield/docker-compose.yml +0 -17
  86. data/lib/roro/cli/templates/greenfield/docker-entrypoint.sh +0 -8
  87. data/lib/roro/cli/templates/quickstart/Dockerfile.tt +0 -20
  88. data/lib/roro/cli/templates/quickstart/database.yml +0 -85
  89. data/lib/roro/cli/templates/quickstart/docker-compose.yml +0 -17
  90. data/lib/roro/cli/templates/ruby_gem/.gitignore +0 -8
  91. data/lib/roro/cli/templates/ruby_gem/config.yml +0 -122
  92. data/lib/roro/cli/templates/ruby_gem/docker/containers/app/Dockerfile.tt +0 -10
  93. data/vendor/cache/concurrent-ruby-1.1.6.gem +0 -0
@@ -1,13 +1,51 @@
1
- # Git
2
- .git # <label id="chapter.fine-tuning-our-rails-image.dockerignore.git-history" />
3
- .gitignore # <label id="chapter.fine-tuning-our-rails-image.dockerignore.gitignore" />
1
+ .git
2
+ .gitignore
3
+ README.md
4
4
 
5
- # Logs
6
- log/* # <label id="chapter.fine-tuning-our-rails-image.dockerignore.log_dir" />
5
+ #
6
+ # OS X
7
+ #
8
+ .DS_Store
9
+ .AppleDouble
10
+ .LSOverride
11
+ # Icon must end with two \r
12
+ Icon
13
+ # Thumbnails
14
+ ._*
15
+ # Files that might appear on external disk
16
+ .Spotlight-V100
17
+ .Trashes
18
+ # Directories potentially created on remote AFP share
19
+ .AppleDB
20
+ .AppleDesktop
21
+ Network Trash Folder
22
+ Temporary Items
23
+ .apdisk
7
24
 
8
- # Temp files
9
- tmp/* # <label id="chapter.fine-tuning-our-rails-image.dockerignore.tmp_dir" />
25
+ #
26
+ # Rails
27
+ #
28
+ .env
29
+ .env.sample
30
+ *.rbc
31
+ capybara-*.html
32
+ log
33
+ tmp
34
+ db/*.sqlite3
35
+ db/*.sqlite3-journal
36
+ public/system
37
+ coverage/
38
+ spec/tmp
39
+ **.orig
10
40
 
11
- # Editor temp files
12
- *.swp # <label id="chapter.fine-tuning-our-rails-image.dockerignore.vim_swp_files" />
13
- *.swo # <label id="chapter.fine-tuning-our-rails-image.dockerignore.vim_swo_files" />
41
+ .bundle
42
+
43
+ .ruby-version
44
+ .ruby-gemset
45
+
46
+ .rvmrc
47
+
48
+ # if using bower-rails ignore default bower_components path bower.json files
49
+ vendor/assets/bower_components
50
+ *.bowerrc
51
+ bower.json
@@ -0,0 +1,15 @@
1
+ ---
2
+ main_app_name: greenfield
3
+ database_host: database
4
+ ruby_version: '2.7'
5
+ frontend_service: frontend
6
+ webserver_service: nginx
7
+ database_service: database
8
+ database_vendor: mysql
9
+ mysql_env_vars:
10
+ MYSQL_ROOT_PASSWORD: root
11
+ MYSQL_PASSWORD: root
12
+ MYSQL_USERNAME: root
13
+ MYSQL_DATABASE_PORT: '3306'
14
+ thor_actions:
15
+ insert_hfci_gem_into_gemfile: y
@@ -0,0 +1,82 @@
1
+ ## The FROM instruction below builds our first layer using an official image:
2
+ FROM ruby:<%= config['ruby_version'] %>
3
+
4
+ LABEL maintainer="<%= config['dockerhub_email'] %>"
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
25
+
26
+ ## Add yarn's public key using apt-key:
27
+ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
28
+
29
+ ## Add yarn to our sources:
30
+ RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
31
+
32
+
33
+ ## Build a layer updating the image while adding node and yarn from the source
34
+ ## above:
35
+ RUN apt-get update -qq && apt-get install -y build-essential git nodejs yarn
36
+
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.
40
+
41
+ ## Set APP_HOME and BUNDLE_PATH as using ENV instructions:
42
+ ENV APP_HOME /usr/src/app/
43
+ ENV BUNDLE_PATH /gems
44
+
45
+ ## Create both as directories to make sure they exist:
46
+ RUN mkdir ${APP_HOME}
47
+ RUN mkdir ${BUNDLE_PATH}
48
+
49
+ ## Tell Docker to create volumes for our workspace and gems
50
+ ## so other containers can access them.
51
+ VOLUME ${APP_HOME}
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.
60
+
61
+ ## Build your big, slow gem layer by first copying your Gemfile && Gemfile.lock:
62
+ COPY Gemfile* ./
63
+
64
+ ## Set your work directory:
65
+ WORKDIR ${APP_HOME}
66
+
67
+ ## build the bundle layer, which now only runs if your Gemfile changes:
68
+ RUN bundle
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
+
76
+ COPY roro/docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
77
+ RUN chmod +x /usr/bin/docker-entrypoint.sh
78
+ ENTRYPOINT ["docker-entrypoint.sh"]
79
+
80
+
81
+
82
+
@@ -0,0 +1,19 @@
1
+ default: &default
2
+ adapter: mysql2
3
+ encoding: utf8
4
+ pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
5
+ host: <%= ENV.fetch('DATABASE_HOST') %>
6
+ username: <%= ENV.fetch('MYSQL_USERNAME') %>
7
+ password: <%= ENV.fetch('MYSQL_PASSWORD') %>
8
+ database: <%= ENV.fetch('MYSQL_DATABASE') %>
9
+ port: <%= ENV.fetch('MYSQL_DATABASE_PORT') %>
10
+ socket: /var/run/mysqld/mysqlx.sock
11
+
12
+ development:
13
+ <<: *default
14
+
15
+ test:
16
+ <<: *default
17
+
18
+ production:
19
+ <<: *default
@@ -1,21 +1,43 @@
1
- FROM ruby:<%= config[:ruby_version] %> AS stage1
1
+ FROM ruby:<%= config['ruby_version'] %> AS builder
2
2
 
3
+ ## Make sure we have yarn properly sourced:
3
4
  RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
4
5
  RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
6
+
7
+ ## Update OS and download yarm from source specified above:
5
8
  RUN apt-get update -qq && apt-get install -y build-essential git nodejs yarn
6
9
 
10
+ ## Set up our workspace directories:
11
+ ENV APP_HOME /usr/src/app/
12
+ RUN mkdir ${APP_HOME}
7
13
 
14
+ ## Tell bundler where to store downloaded gems:
8
15
  ENV BUNDLE_PATH /gems
9
- ENV APP_HOME /usr/src/app/
10
- RUN mkdir $APP_HOME
11
- WORKDIR $APP_HOME
16
+ RUN mkdir ${BUNDLE_PATH}}
17
+
18
+ ## Tell Docker to create volumes for our workspace and gems
19
+ ## so other containers can access them.
20
+ VOLUME ${APP_HOME}
21
+ VOLUME /gems
12
22
 
23
+ ## Create a Gemfile with just the Rails gem inside:
13
24
  RUN echo "source 'https://rubygems.org'\ngem 'rails'" > Gemfile
14
25
 
15
- RUN bundle
16
- RUN bundle exec rails new greenfield --skip-bundle --skip-webpack-install
26
+ ## Bundle to install rails:
27
+
28
+ ## Switch to the the work directory from container root:
29
+ WORKDIR ${APP_HOME}
30
+
31
+ RUN bundle install
32
+ ## Use Rails to generate a new app. We'll configure it later.
33
+ RUN bundle exec rails new . --skip-webpack-install --skip-bundle
34
+
35
+ ## Tell docker not to create a layer:
17
36
  FROM scratch AS export-stage
18
37
 
19
- COPY --from=stage1 /usr/src/app/greenfield .
38
+ ## Copy the generated files onto the host. Note that because we are in a
39
+ ## new container, we don't have access to the previous ${APP_HOME}
40
+ ## variable and so we must hard code it as our source:
41
+ COPY --from=builder /usr/src/app/ .
20
42
 
21
43
 
@@ -1,51 +1,50 @@
1
- version: '3'
1
+ version: '3.2'
2
2
 
3
3
  services:
4
4
 
5
5
  web:
6
- build: .
6
+ build:
7
+ context: .
8
+ dockerfile: roro/containers/app/Dockerfile
7
9
  depends_on:
8
10
  - database
9
- - webpack_dev_server
10
11
  - redis
11
- # entrypoint: ./docker-entrypoint.sh
12
- command: ["bin/rails", "s", "-b", "0.0.0.0"]
13
12
 
13
+ command: ["bin/rails", "s", "-b", "0.0.0.0"]
14
14
  ports:
15
15
  - "3000:3000"
16
16
  - "4000:4000"
17
17
  volumes:
18
- - .:/usr/src/app
18
+ - app:/usr/src/app
19
19
  - gem_cache:/gems
20
20
  env_file:
21
- - .env/development/web
22
- - .env/development/database
21
+ - roro/containers/app/development.env
22
+ - roro/containers/database/development.env
23
23
  environment:
24
24
  - WEBPACKER_DEV_SERVER_HOST=webpack_dev_server
25
25
 
26
26
  webpack_dev_server:
27
- build: .
27
+ build:
28
+ context: .
29
+ dockerfile: roro/containers/app/Dockerfile
30
+
31
+
28
32
  command: ./bin/webpack-dev-server
29
33
  ports:
30
34
  - 3035:3035
31
35
  volumes:
32
- - .:/usr/src/app
36
+ - app:/usr/src/app
33
37
  - gem_cache:/gems
34
38
  env_file:
35
- - .env/development/database
36
- - .env/development/web
39
+ - roro/containers/app/development.env
40
+ - roro/containers/database/development.env
37
41
  environment:
38
42
  - WEBPACKER_DEV_SERVER_HOST=0.0.0.0
39
43
 
40
44
  redis:
41
45
  image: redis
42
46
 
43
- database:
44
- image: postgres
45
- env_file:
46
- - .env/development/database
47
- volumes:
48
- - db_data:/var/lib/postgresql/data
47
+ <%= yaml_from_template("stories/with_#{config['database_vendor']}/_service.yml") %>
49
48
 
50
49
  system_tests:
51
50
  image: selenium/standalone-chrome-debug
@@ -58,3 +57,4 @@ services:
58
57
  volumes:
59
58
  db_data:
60
59
  gem_cache:
60
+ app:
@@ -2,7 +2,7 @@
2
2
  set -e
3
3
 
4
4
  # Remove a potentially pre-existing server.pid for Rails.
5
- rm -f /myapp/tmp/pids/server.pid
5
+ rm -f /usr/src/app/tmp/pids/server.pid
6
6
 
7
7
  # Then exec the container's main process (what's set as CMD in the Dockerfile).
8
8
  exec "$@"
@@ -0,0 +1,17 @@
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 roro
13
+ - run: roro expose ci
14
+ - run: echo 'source roro/containers/gem/ci.env' >> $BASH_ENV
15
+ - run: setup_gem_credentials.sh
16
+ - run: gem install gem-release -k
17
+ - run: gem release
@@ -1,9 +1,11 @@
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
9
- command: rake test
8
+ dockerfile: roro/containers/ruby_image/Dockerfile
9
+ environment:
10
+ - RUBY_IMAGE=${RUBY_IMAGE}
11
+ command: bundle exec rake test
@@ -0,0 +1 @@
1
+ RUBYGEMS_API_KEY=<%= config['rubygems_api_key'] %>
@@ -0,0 +1,16 @@
1
+ ARG RUBY_IMAGE=ruby:<%= config['ruby_version'] %>-alpine
2
+ FROM $RUBY_IMAGE
3
+
4
+ RUN apk add --no-cache --update build-base linux-headers git
5
+
6
+ ENV APP_HOME /usr/src/app/
7
+
8
+ RUN mkdir ${APP_HOME}
9
+
10
+
11
+ WORKDIR ${APP_HOME}
12
+
13
+
14
+ COPY . ${APP_HOME}
15
+ RUN gem update bundler
16
+ RUN bundle
@@ -0,0 +1,10 @@
1
+ database:
2
+ image: mysql:5.7
3
+ env_file:
4
+ - roro/containers/database/development.env
5
+ - roro/containers/app/development.env
6
+ volumes:
7
+ - db_data:/var/lib/mysql
8
+ restart: always
9
+ ports:
10
+ - '3307:3306'
@@ -0,0 +1,7 @@
1
+ database:
2
+ image: postgres
3
+ env_file:
4
+ - roro/containers/database/development.env
5
+ - roro/containers/app/development.env
6
+ volumes:
7
+ - db_data:/var/lib/postgresql/data
@@ -1,3 +1,3 @@
1
1
  module Roro
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.9"
3
3
  end
@@ -37,14 +37,15 @@ 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
- spec.add_dependency "handsome_fencer-crypto", "0.1.6"
44
+ spec.add_dependency "handsome_fencer-crypto"
45
+ spec.add_dependency "byebug"
45
46
  spec.add_development_dependency "bundler"
46
47
  spec.add_development_dependency "rake", ">= 12.3"
47
48
  spec.add_development_dependency "handsome_fencer-test", "0.1.1"
48
- spec.add_development_dependency "byebug"
49
+ spec.add_development_dependency "mocha"
49
50
 
50
51
  end
File without changes